Skip to content

Commit 807542a

Browse files
committed
implicitly install karma-<testingFramework>'s peer dependencies on test init command
1 parent e743965 commit 807542a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/commands/test-init.ts

+12
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ class TestInitCommand implements ICommand {
3737
'save-dev': true,
3838
optional: false,
3939
});
40+
41+
let modulePath = path.join(projectDir, "node_modules", mod);
42+
let modulePackageJsonPath = path.join(modulePath, "package.json");
43+
let modulePackageJsonContent = this.$fs.readJson(modulePackageJsonPath);
44+
let modulePeerDependencies = modulePackageJsonContent.peerDependencies || {};
45+
46+
for (let peerDependency in modulePeerDependencies) {
47+
let dependencyVersion = modulePeerDependencies[peerDependency] || "*";
48+
await this.$npm.install(`${peerDependency}@${dependencyVersion}`, projectDir, {
49+
'save-dev': true
50+
});
51+
}
4052
}
4153

4254
await this.$pluginsService.add('nativescript-unit-test-runner', this.$projectData);

0 commit comments

Comments
 (0)