Skip to content

Commit b7b07d5

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/cli): use spawned process error when it's available
In some cases when an error occurs in the spawned process the `error` property will be populated instead of `stderr` or `stdout`. See: https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options
1 parent 0098cb6 commit b7b07d5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/angular/cli/tasks/install-package.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ export function installPackage(
4040

4141
logger.info(colors.green(`Installing packages for tooling via ${packageManager}.`));
4242

43-
const { status, stderr, stdout } = spawnSync(packageManager, [...installArgs, ...extraArgs], {
43+
const { status, stderr, stdout, error } = spawnSync(packageManager, [...installArgs, ...extraArgs], {
4444
stdio: 'pipe',
4545
encoding: 'utf8',
4646
shell: true,
4747
cwd,
4848
});
4949

5050
if (status !== 0) {
51-
let error = (stderr || stdout).trim();
52-
if (error) {
53-
error += '\n';
51+
let errorMessage = ((error && error.message) || stderr || stdout || '').trim();
52+
if (errorMessage) {
53+
errorMessage += '\n';
5454
}
55-
throw new Error(error + `Package install failed${error ? ', see above' : ''}.`);
55+
throw new Error(errorMessage + `Package install failed${errorMessage ? ', see above' : ''}.`);
5656
}
5757

5858
logger.info(colors.green(`Installed packages for tooling via ${packageManager}.`));

0 commit comments

Comments
 (0)