Skip to content

Commit e5efb8f

Browse files
author
Frank Schmid
committed
Changed to early exit semantics in packaging for google
1 parent 8ede2a7 commit e5efb8f

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lib/packExternalModules.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -291,23 +291,25 @@ module.exports = {
291291
addModulesToPackageJson(prodModules, modulePackage);
292292
this.serverless.utils.writeFileSync(modulePackageJson, JSON.stringify(modulePackage, null, 2));
293293

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-
});
294+
// GOOGLE: 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+
return BbPromise.resolve();
310298
}
299+
300+
const startCopy = _.now();
301+
return BbPromise.fromCallback(callback => fse.copy(path.join(compositeModulePath, 'node_modules'), path.join(modulePath, 'node_modules'), callback))
302+
.tap(() => this.options.verbose && this.serverless.cli.log(`Copy modules: ${modulePath} [${_.now() - startCopy} ms]`))
303+
.then(() => {
304+
// Prune extraneous packages - removes not needed ones
305+
const startPrune = _.now();
306+
return BbPromise.fromCallback(callback => {
307+
childProcess.exec('npm prune', {
308+
cwd: modulePath
309+
}, callback);
310+
})
311+
.tap(() => this.options.verbose && this.serverless.cli.log(`Prune: ${modulePath} [${_.now() - startPrune} ms]`));
312+
});
311313
})
312314
.return();
313315
});

0 commit comments

Comments
 (0)