Skip to content

Commit 2e8d9a6

Browse files
committed
fix(@angular/cli): Propagate package manager errors when install fails
This change makes it easier to determine why a package manager is refusing to install an update.
1 parent c5d6f9f commit 2e8d9a6

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

  • packages/angular/cli/src/commands/update

‎packages/angular/cli/src/commands/update/cli.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import {
2020
Options,
2121
} from '../../command-builder/command-module';
2222
import { SchematicEngineHost } from '../../command-builder/utilities/schematic-engine-host';
23-
import type { InstalledPackage, PackageManager, PackageManifest } from '../../package-managers';
23+
import {
24+
type InstalledPackage,
25+
type PackageManager,
26+
PackageManagerError,
27+
type PackageManifest,
28+
} from '../../package-managers';
2429
import { colors } from '../../utilities/color';
2530
import { disableVersionCheck } from '../../utilities/environment-options';
2631
import { assertIsError } from '../../utilities/error';
@@ -596,7 +601,16 @@ export default class UpdateCommandModule extends CommandModule<UpdateCommandArgs
596601
ignorePeerDependencies,
597602
});
598603
} catch (e) {
599-
throw new CommandError('Unable to install packages');
604+
let message = 'Unable to install packages';
605+
if (e instanceof PackageManagerError) {
606+
const stdout = e.stdout.trim();
607+
const stderr = e.stderr.trim();
608+
message += `: ${colors.bold(e.message)}${
609+
stdout ? `\n\n${colors.bold('[STDOUT]')}: ${stdout}` : ''
610+
}${stderr ? `\n\n${colors.bold('[STDERR]')}: ${colors.red(stderr)}` : ''}`;
611+
}
612+
613+
throw new CommandError(message);
600614
}
601615
},
602616
},

0 commit comments

Comments
 (0)