Skip to content

Commit 0098cb6

Browse files
alan-agius4clydin
authored andcommitted
fix(@angular/cli): handle null stderr during npm install
1 parent 560d19c commit 0098cb6

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

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

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

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

43-
const { status, stderr } = spawnSync(
44-
packageManager,
45-
[
46-
...installArgs,
47-
...extraArgs,
48-
],
49-
{
50-
stdio: 'pipe',
51-
encoding: 'utf8',
52-
shell: true,
53-
cwd,
54-
},
55-
);
43+
const { status, stderr, stdout } = spawnSync(packageManager, [...installArgs, ...extraArgs], {
44+
stdio: 'pipe',
45+
encoding: 'utf8',
46+
shell: true,
47+
cwd,
48+
});
5649

5750
if (status !== 0) {
58-
let errors = stderr.trim();
59-
if (errors.length) {
60-
errors += '\n';
51+
let error = (stderr || stdout).trim();
52+
if (error) {
53+
error += '\n';
6154
}
62-
throw new Error(errors + `Package install failed${errors.length ? ', see above' : ''}.`);
55+
throw new Error(error + `Package install failed${error ? ', see above' : ''}.`);
6356
}
6457

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

0 commit comments

Comments
 (0)