Skip to content

Commit 7d07bf3

Browse files
committed
fix: allow install/uninstall package methods to accept non-existent packages and still complete as many as possible
1 parent b9b7f1b commit 7d07bf3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/blueprint.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,13 @@ export default class Blueprint extends Command {
409409
public installPackages(pkgNames: string[], dev?: boolean): void {
410410
debug(`installing ${ pkgNames.join(', ') }`);
411411
if (this.shouldUseYarn()) {
412-
run(`yarn add ${ dev ? '--dev' : '' } ${ pkgNames.join(' ') }`);
412+
pkgNames.forEach((pkgName) => {
413+
try {
414+
run(`yarn add ${ dev ? '--dev' : '' } ${ pkgName }`);
415+
} catch (e) {
416+
// Yarn fails the entire command if one package doesn't exist, so we run each separately
417+
}
418+
});
413419
} else {
414420
run(`npm install ${ dev ? '-D' : '-S' } ${ pkgNames.join(' ') }`);
415421
}
@@ -433,7 +439,13 @@ export default class Blueprint extends Command {
433439
public uninstallPackages(pkgNames: string[]): void {
434440
debug(`uninstalling ${ pkgNames.join(', ') }`);
435441
if (this.shouldUseYarn()) {
436-
run(`yarn remove ${ pkgNames.join(' ') }`);
442+
pkgNames.forEach((pkgName) => {
443+
try {
444+
run(`yarn remove ${ pkgName }`);
445+
} catch (e) {
446+
// Yarn fails the entire command if one package doesn't exist, so we run each separately
447+
}
448+
});
437449
} else {
438450
run(`npm uninstall -S ${ pkgNames.join(' ') }`);
439451
}

0 commit comments

Comments
 (0)