@@ -18,7 +18,6 @@ import { memoize } from './memoize';
1818import { Spinner } from './spinner' ;
1919
2020interface PackageManagerOptions {
21- silent : string ;
2221 saveDev : string ;
2322 install : string ;
2423 installAll ?: string ;
@@ -79,28 +78,24 @@ export class PackageManagerUtils {
7978 cwd ?: string ,
8079 ) : Promise < boolean > {
8180 const packageManagerArgs = this . getArguments ( ) ;
82- const installArgs : string [ ] = [
83- packageManagerArgs . install ,
84- packageName ,
85- packageManagerArgs . silent ,
86- ] ;
81+ const installArgs : string [ ] = [ packageManagerArgs . install , packageName ] ;
8782
8883 if ( save === 'devDependencies' ) {
8984 installArgs . push ( packageManagerArgs . saveDev ) ;
9085 }
9186
92- return this . run ( [ ...installArgs , ...extraArgs ] , cwd ) ;
87+ return this . run ( [ ...installArgs , ...extraArgs ] , { cwd, silent : true } ) ;
9388 }
9489
9590 /** Install all packages. */
9691 async installAll ( extraArgs : string [ ] = [ ] , cwd ?: string ) : Promise < boolean > {
9792 const packageManagerArgs = this . getArguments ( ) ;
98- const installArgs : string [ ] = [ packageManagerArgs . silent ] ;
93+ const installArgs : string [ ] = [ ] ;
9994 if ( packageManagerArgs . installAll ) {
10095 installArgs . push ( packageManagerArgs . installAll ) ;
10196 }
10297
103- return this . run ( [ ...installArgs , ...extraArgs ] , cwd ) ;
98+ return this . run ( [ ...installArgs , ...extraArgs ] , { cwd, silent : true } ) ;
10499 }
105100
106101 /** Install a single package temporary. */
@@ -160,15 +155,13 @@ export class PackageManagerUtils {
160155 switch ( this . name ) {
161156 case PackageManager . Yarn :
162157 return {
163- silent : '--silent' ,
164158 saveDev : '--dev' ,
165159 install : 'add' ,
166160 prefix : '--modules-folder' ,
167161 noLockfile : '--no-lockfile' ,
168162 } ;
169163 case PackageManager . Pnpm :
170164 return {
171- silent : '--silent' ,
172165 saveDev : '--save-dev' ,
173166 install : 'add' ,
174167 installAll : 'install' ,
@@ -177,7 +170,6 @@ export class PackageManagerUtils {
177170 } ;
178171 default :
179172 return {
180- silent : '--quiet' ,
181173 saveDev : '--save-dev' ,
182174 install : 'install' ,
183175 installAll : 'install' ,
@@ -187,15 +179,21 @@ export class PackageManagerUtils {
187179 }
188180 }
189181
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+
191188 const spinner = new Spinner ( ) ;
192189 spinner . start ( 'Installing packages...' ) ;
193190
194191 return new Promise ( ( resolve ) => {
195192 const bufferedOutput : { stream : NodeJS . WriteStream ; data : Buffer } [ ] = [ ] ;
196193
197194 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' ,
199197 shell : true ,
200198 cwd,
201199 } ) . on ( 'close' , ( code : number ) => {
0 commit comments