@@ -407,11 +407,38 @@ Emulate only the body of the API Gateway event.
407407 }
408408 }
409409
410+ _getYarnInstallCommand ( program , codeDirectory ) {
411+ const installOptions = [
412+ '-s' ,
413+ 'install' ,
414+ '--production'
415+ ]
416+
417+ if ( program . optionalDependencies === false ) {
418+ installOptions . push ( '--ignore-optional' )
419+ }
420+
421+ if ( ! program . dockerImage ) {
422+ installOptions . push ( '--cwd' , codeDirectory )
423+ }
424+
425+ return {
426+ packageManager : 'yarn' ,
427+ installOptions
428+ }
429+ }
430+
410431 _packageInstall ( program , codeDirectory ) {
411432 // Run on windows:
412433 // https://nodejs.org/api/child_process.html#child_process_spawning_bat_and_cmd_files_on_windows
413434
414- const { packageManager, installOptions } = this . _getNpmInstallCommand ( program , codeDirectory )
435+ const { packageManager, installOptions } = ( ( ) => {
436+ // default npm
437+ if ( program . packageManager === 'yarn' ) {
438+ return this . _getYarnInstallCommand ( program , codeDirectory )
439+ }
440+ return this . _getNpmInstallCommand ( program , codeDirectory )
441+ } ) ( )
415442
416443 const paramsOnContainer = ( ( ) => {
417444 // with docker
@@ -459,7 +486,7 @@ Emulate only the body of the API Gateway event.
459486 env : process . env
460487 } , ( err ) => {
461488 if ( err ) return reject ( err )
462- resolve ( )
489+ resolve ( packageManager )
463490 } )
464491 } )
465492 }
@@ -701,7 +728,8 @@ they may not work as expected in the Lambda environment.
701728 await this . _fileCopy ( program , lambdaSrcDirectory , codeDirectory , true )
702729 if ( ! program . keepNodeModules ) {
703730 console . log ( '=> Running package install' )
704- await this . _packageInstall ( program , codeDirectory )
731+ const usedPackageManager = await this . _packageInstall ( program , codeDirectory )
732+ console . log ( `(Package manager used was '${ usedPackageManager } '.)` )
705733 }
706734 await this . _postInstallScript ( program , codeDirectory )
707735 console . log ( '=> Zipping deployment package' )
0 commit comments