@@ -291,20 +291,23 @@ module.exports = {
291291 addModulesToPackageJson ( prodModules , modulePackage ) ;
292292 this . serverless . utils . writeFileSync ( modulePackageJson , JSON . stringify ( modulePackage , null , 2 ) ) ;
293293
294- // Copy modules
295- // const startCopy = _.now();
296- // return BbPromise.fromCallback(callback => fse.copy(path.join(compositeModulePath, 'node_modules'), path.join(modulePath, 'node_modules'), callback))
297- // .tap(() => this.options.verbose && this.serverless.cli.log(`Copy modules: ${modulePath} [${_.now() - startCopy} ms]`))
298- // .then(() => {
299- // // Prune extraneous packages - removes not needed ones
300- // const startPrune = _.now();
301- // return BbPromise.fromCallback(callback => {
302- // childProcess.exec('npm prune', {
303- // cwd: modulePath
304- // }, callback);
305- // })
306- // .tap(() => this.options.verbose && this.serverless.cli.log(`Prune: ${modulePath} [${_.now() - startPrune} ms]`));
307- // });
294+ // Copy modules only if not google-cloud-functions
295+ // GCF Auto installs the package json
296+ if ( _ . get ( this . serverless , 'service.provider.name' ) !== 'google' ) {
297+ const startCopy = _ . now ( ) ;
298+ return BbPromise . fromCallback ( callback => fse . copy ( path . join ( compositeModulePath , 'node_modules' ) , path . join ( modulePath , 'node_modules' ) , callback ) )
299+ . tap ( ( ) => this . options . verbose && this . serverless . cli . log ( `Copy modules: ${ modulePath } [${ _ . now ( ) - startCopy } ms]` ) )
300+ . then ( ( ) => {
301+ // Prune extraneous packages - removes not needed ones
302+ const startPrune = _ . now ( ) ;
303+ return BbPromise . fromCallback ( callback => {
304+ childProcess . exec ( 'npm prune' , {
305+ cwd : modulePath
306+ } , callback ) ;
307+ } )
308+ . tap ( ( ) => this . options . verbose && this . serverless . cli . log ( `Prune: ${ modulePath } [${ _ . now ( ) - startPrune } ms]` ) ) ;
309+ } ) ;
310+ }
308311 } )
309312 . return ( ) ;
310313 } ) ;
0 commit comments