8
8
9
9
import { logging } from '@angular-devkit/core' ;
10
10
import { 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' ;
17
12
import { tmpdir } from 'os' ;
18
13
import { join , resolve } from 'path' ;
19
14
import * as rimraf from 'rimraf' ;
@@ -45,21 +40,26 @@ export function installPackage(
45
40
46
41
logger . info ( colors . green ( `Installing packages for tooling via ${ packageManager } .` ) ) ;
47
42
48
- const { status } = spawnSync (
43
+ const { status, stderr } = spawnSync (
49
44
packageManager ,
50
45
[
51
46
...installArgs ,
52
47
...extraArgs ,
53
48
] ,
54
49
{
55
- stdio : 'inherit' ,
50
+ stdio : 'pipe' ,
51
+ encoding : 'utf8' ,
56
52
shell : true ,
57
53
cwd,
58
54
} ,
59
55
) ;
60
56
61
57
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' : '' } .` ) ;
63
63
}
64
64
65
65
logger . info ( colors . green ( `Installed packages for tooling via ${ packageManager } .` ) ) ;
@@ -76,7 +76,7 @@ export function installTempPackage(
76
76
process . on ( 'exit' , ( ) => {
77
77
try {
78
78
rimraf . sync ( tempPath ) ;
79
- } catch { }
79
+ } catch { }
80
80
} ) ;
81
81
82
82
// setup prefix/global modules path
@@ -132,10 +132,7 @@ export function runTempPackageBin(
132
132
throw new Error ( `Cannot locate bin for temporary package: ${ packageNameNoVersion } .` ) ;
133
133
}
134
134
135
- const argv = [
136
- binPath ,
137
- ...args ,
138
- ] ;
135
+ const argv = [ binPath , ...args ] ;
139
136
140
137
const { status, error } = spawnSync ( 'node' , argv , {
141
138
stdio : 'inherit' ,
0 commit comments