88
99import { logging } from '@angular-devkit/core' ;
1010import { spawnSync } from 'child_process' ;
11- import {
12- existsSync ,
13- mkdtempSync ,
14- readFileSync ,
15- realpathSync ,
16- } from 'fs' ;
11+ import { existsSync , mkdtempSync , readFileSync , realpathSync } from 'fs' ;
1712import { tmpdir } from 'os' ;
1813import { join , resolve } from 'path' ;
1914import * as rimraf from 'rimraf' ;
@@ -45,21 +40,26 @@ export function installPackage(
4540
4641 logger . info ( colors . green ( `Installing packages for tooling via ${ packageManager } .` ) ) ;
4742
48- const { status } = spawnSync (
43+ const { status, stderr } = spawnSync (
4944 packageManager ,
5045 [
5146 ...installArgs ,
5247 ...extraArgs ,
5348 ] ,
5449 {
55- stdio : 'inherit' ,
50+ stdio : 'pipe' ,
51+ encoding : 'utf8' ,
5652 shell : true ,
5753 cwd,
5854 } ,
5955 ) ;
6056
6157 if ( status !== 0 ) {
62- throw new Error ( 'Package install failed, see above.' ) ;
58+ let errors = stderr . trim ( ) ;
59+ if ( errors . length ) {
60+ errors += '\n' ;
61+ }
62+ throw new Error ( errors + `Package install failed${ errors . length ? ', see above' : '' } .` ) ;
6363 }
6464
6565 logger . info ( colors . green ( `Installed packages for tooling via ${ packageManager } .` ) ) ;
@@ -76,7 +76,7 @@ export function installTempPackage(
7676 process . on ( 'exit' , ( ) => {
7777 try {
7878 rimraf . sync ( tempPath ) ;
79- } catch { }
79+ } catch { }
8080 } ) ;
8181
8282 // setup prefix/global modules path
@@ -132,10 +132,7 @@ export function runTempPackageBin(
132132 throw new Error ( `Cannot locate bin for temporary package: ${ packageNameNoVersion } .` ) ;
133133 }
134134
135- const argv = [
136- binPath ,
137- ...args ,
138- ] ;
135+ const argv = [ binPath , ...args ] ;
139136
140137 const { status, error } = spawnSync ( 'node' , argv , {
141138 stdio : 'inherit' ,
0 commit comments