Skip to content

Commit c0adaa6

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 c0adaa6

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+
assertIsError(e);
605+
let message = `Unable to install packages: ${colors.bold(e.message)}`;
606+
if (e instanceof PackageManagerError) {
607+
const stdout = e.stdout?.trim();
608+
const stderr = e.stderr?.trim();
609+
if (stdout) message += `\n\n${colors.bold('[STDOUT]')}: ${stdout}`;
610+
if (stderr) message += `\n\n${colors.bold('[STDERR]')}: ${stderr}`;
611+
}
612+
613+
throw new CommandError(message);
600614
}
601615
},
602616
},

0 commit comments

Comments
 (0)