File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,15 +57,16 @@ export async function addModules(
5757 ...names : Array < string >
5858) : Promise < string > {
5959 let nameArgs : Array < string > = [ ] ;
60+ let installCommand : string ;
6061
6162 if ( packageManager === 'npm' ) {
63+ installCommand = 'npm install' ;
6264 nameArgs = names . length > 0 ? [ '-S' , ...names ] : [ '--also=dev --prod' ] ;
6365 } else {
66+ installCommand = names . length > 0 ? 'yarn add' : 'yarn install' ;
6467 nameArgs = [ ...names ] ;
6568 }
6669
67- const installCommand = packageManager === 'npm' ? 'npm install' : 'yarn add' ;
68-
6970 return exec ( dir , [ installCommand ] . concat ( nameArgs ) . join ( ' ' ) ) ;
7071}
7172
Original file line number Diff line number Diff line change @@ -483,12 +483,13 @@ export class Runner {
483483 * @memberof Runner
484484 */
485485 public async packageInstall ( options : PMOperationOptions ) : Promise < boolean > {
486+ const pm = options . packageManager ;
486487 try {
487- this . appState . pushOutput ( `Now running "npm install..."` ) ;
488+ this . appState . pushOutput ( `Now running "${ pm } install..."` ) ;
488489 this . appState . pushOutput ( await window . ElectronFiddle . addModules ( options ) ) ;
489490 return true ;
490491 } catch ( error ) {
491- this . appState . pushError ( ' Failed to run "npm install".' , error ) ;
492+ this . appState . pushError ( ` Failed to run "${ pm } install".` , error ) ;
492493 }
493494
494495 return false ;
Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ describe('npm', () => {
158158 it ( 'attempts to installs all modules' , async ( ) => {
159159 addModules ( { dir : '/my/directory' , packageManager : 'yarn' } ) ;
160160
161- expect ( exec ) . toHaveBeenCalledWith < any > ( '/my/directory' , 'yarn add ' ) ;
161+ expect ( exec ) . toHaveBeenCalledWith < any > ( '/my/directory' , 'yarn install ' ) ;
162162 } ) ;
163163 } ) ;
164164 } ) ;
You can’t perform that action at this time.
0 commit comments