@@ -18,7 +18,6 @@ import { memoize } from './memoize';
18
18
import { Spinner } from './spinner' ;
19
19
20
20
interface PackageManagerOptions {
21
- silent : string ;
22
21
saveDev : string ;
23
22
install : string ;
24
23
installAll ?: string ;
@@ -79,28 +78,24 @@ export class PackageManagerUtils {
79
78
cwd ?: string ,
80
79
) : Promise < boolean > {
81
80
const packageManagerArgs = this . getArguments ( ) ;
82
- const installArgs : string [ ] = [
83
- packageManagerArgs . install ,
84
- packageName ,
85
- packageManagerArgs . silent ,
86
- ] ;
81
+ const installArgs : string [ ] = [ packageManagerArgs . install , packageName ] ;
87
82
88
83
if ( save === 'devDependencies' ) {
89
84
installArgs . push ( packageManagerArgs . saveDev ) ;
90
85
}
91
86
92
- return this . run ( [ ...installArgs , ...extraArgs ] , cwd ) ;
87
+ return this . run ( [ ...installArgs , ...extraArgs ] , { cwd, silent : true } ) ;
93
88
}
94
89
95
90
/** Install all packages. */
96
91
async installAll ( extraArgs : string [ ] = [ ] , cwd ?: string ) : Promise < boolean > {
97
92
const packageManagerArgs = this . getArguments ( ) ;
98
- const installArgs : string [ ] = [ packageManagerArgs . silent ] ;
93
+ const installArgs : string [ ] = [ ] ;
99
94
if ( packageManagerArgs . installAll ) {
100
95
installArgs . push ( packageManagerArgs . installAll ) ;
101
96
}
102
97
103
- return this . run ( [ ...installArgs , ...extraArgs ] , cwd ) ;
98
+ return this . run ( [ ...installArgs , ...extraArgs ] , { cwd, silent : true } ) ;
104
99
}
105
100
106
101
/** Install a single package temporary. */
@@ -160,15 +155,13 @@ export class PackageManagerUtils {
160
155
switch ( this . name ) {
161
156
case PackageManager . Yarn :
162
157
return {
163
- silent : '--silent' ,
164
158
saveDev : '--dev' ,
165
159
install : 'add' ,
166
160
prefix : '--modules-folder' ,
167
161
noLockfile : '--no-lockfile' ,
168
162
} ;
169
163
case PackageManager . Pnpm :
170
164
return {
171
- silent : '--silent' ,
172
165
saveDev : '--save-dev' ,
173
166
install : 'add' ,
174
167
installAll : 'install' ,
@@ -177,7 +170,6 @@ export class PackageManagerUtils {
177
170
} ;
178
171
default :
179
172
return {
180
- silent : '--quiet' ,
181
173
saveDev : '--save-dev' ,
182
174
install : 'install' ,
183
175
installAll : 'install' ,
@@ -187,15 +179,21 @@ export class PackageManagerUtils {
187
179
}
188
180
}
189
181
190
- private async run ( args : string [ ] , cwd = process . cwd ( ) ) : Promise < boolean > {
182
+ private async run (
183
+ args : string [ ] ,
184
+ options : { cwd ?: string ; silent ?: boolean } = { } ,
185
+ ) : Promise < boolean > {
186
+ const { cwd = process . cwd ( ) , silent = false } = options ;
187
+
191
188
const spinner = new Spinner ( ) ;
192
189
spinner . start ( 'Installing packages...' ) ;
193
190
194
191
return new Promise ( ( resolve ) => {
195
192
const bufferedOutput : { stream : NodeJS . WriteStream ; data : Buffer } [ ] = [ ] ;
196
193
197
194
const childProcess = spawn ( this . name , args , {
198
- stdio : 'pipe' ,
195
+ // Always pipe stderr to allow for failures to be reported
196
+ stdio : silent ? [ 'ignore' , 'ignore' , 'pipe' ] : 'pipe' ,
199
197
shell : true ,
200
198
cwd,
201
199
} ) . on ( 'close' , ( code : number ) => {
0 commit comments