@@ -14,17 +14,17 @@ async function getPkgManager(root) {
1414 try {
1515 await fs . readFile ( path . join ( root , 'yarn.lock' ) , 'utf8' ) ;
1616 return {
17- pkgMananger : 'yarn' ,
17+ pkgManager : 'yarn' ,
1818 cmd : 'add' ,
19- flag : '--dev' ,
19+ flags : [ '--dev' ] ,
2020 logMsg : ( pkg ) =>
2121 `requireWithInstall - installing "${ pkg } " with "yarn" - saving as a devDependency`
2222 } ;
2323 } catch ( err ) {
2424 return {
25- pkgMananger : 'npm' ,
25+ pkgManager : 'npm' ,
2626 cmd : 'install' ,
27- flag : '--no-save' ,
27+ flags : [ '--no-save' , '--force' ] ,
2828 logMsg : ( pkg ) =>
2929 `requireWithInstall - installing "${ pkg } " with "npm" - save as a devDependency to avoid this`
3030 } ;
@@ -45,15 +45,15 @@ async function requireWithInstall(dependency, gasket) {
4545
4646 if ( modulePath ) return require ( modulePath ) ;
4747
48- const { pkgMananger , cmd, flag , logMsg } = await getPkgManager ( root ) ;
48+ const { pkgManager , cmd, flags , logMsg } = await getPkgManager ( root ) ;
4949 const pkg = dependency . match ( rePackage ) [ 0 ] ;
5050
51- const manager = new PackageManager ( { packageManager : pkgMananger , dest : root } ) ;
51+ const manager = new PackageManager ( { packageManager : pkgManager , dest : root } ) ;
5252 logger . info ( logMsg ( pkg ) ) ;
5353 try {
54- await manager . exec ( cmd , [ pkg , flag ] ) ;
54+ await manager . exec ( cmd , [ pkg , ... flags ] ) ;
5555 } catch ( err ) {
56- logger . error ( `requireWithInstall - Failed to install "${ pkg } " using "${ pkgMananger } "` ) ;
56+ logger . error ( `requireWithInstall - Failed to install "${ pkg } " using "${ pkgManager } "` ) ;
5757 throw err ;
5858 }
5959 return require ( resolve ( dependency , resolveOptions ) ) ;
0 commit comments