Skip to content

Commit

Permalink
fix(@angular/cli): only show add/update package install output on errors
Browse files Browse the repository at this point in the history
Closes #16014
Closes #16027
  • Loading branch information
clydin authored and dgp1130 committed Nov 20, 2019
1 parent 46ae172 commit c762e3c
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions packages/angular/cli/tasks/install-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

import { logging } from '@angular-devkit/core';
import { spawnSync } from 'child_process';
import {
existsSync,
mkdtempSync,
readFileSync,
realpathSync,
} from 'fs';
import { existsSync, mkdtempSync, readFileSync, realpathSync } from 'fs';
import { tmpdir } from 'os';
import { join, resolve } from 'path';
import * as rimraf from 'rimraf';
Expand Down Expand Up @@ -45,21 +40,26 @@ export function installPackage(

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

const { status } = spawnSync(
const { status, stderr } = spawnSync(
packageManager,
[
...installArgs,
...extraArgs,
],
{
stdio: 'inherit',
stdio: 'pipe',
encoding: 'utf8',
shell: true,
cwd,
},
);

if (status !== 0) {
throw new Error('Package install failed, see above.');
let errors = stderr.trim();
if (errors.length) {
errors += '\n';
}
throw new Error(errors + `Package install failed${errors.length ? ', see above' : ''}.`);
}

logger.info(colors.green(`Installed packages for tooling via ${packageManager}.`));
Expand All @@ -76,7 +76,7 @@ export function installTempPackage(
process.on('exit', () => {
try {
rimraf.sync(tempPath);
} catch { }
} catch {}
});

// setup prefix/global modules path
Expand Down Expand Up @@ -132,10 +132,7 @@ export function runTempPackageBin(
throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);
}

const argv = [
binPath,
...args,
];
const argv = [binPath, ...args];

const { status, error } = spawnSync('node', argv, {
stdio: 'inherit',
Expand Down

0 comments on commit c762e3c

Please sign in to comment.