Skip to content

Commit 78b5635

Browse files
committed
add exception handling when installing packages already present in the project
1 parent 807542a commit 78b5635

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/commands/test-init.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,16 @@ class TestInitCommand implements ICommand {
4545

4646
for (let peerDependency in modulePeerDependencies) {
4747
let dependencyVersion = modulePeerDependencies[peerDependency] || "*";
48-
await this.$npm.install(`${peerDependency}@${dependencyVersion}`, projectDir, {
49-
'save-dev': true
50-
});
48+
49+
// catch errors when a peerDependency is already installed
50+
// e.g karma is installed; karma-jasmine depends on karma and will try to install it again
51+
try {
52+
await this.$npm.install(`${peerDependency}@${dependencyVersion}`, projectDir, {
53+
'save-dev': true
54+
});
55+
} catch (e) {
56+
this.$logger.info(e.message);
57+
}
5158
}
5259
}
5360

0 commit comments

Comments
 (0)