Skip to content

Commit 9e115a7

Browse files
authored
Merge pull request #209 from elastic-coders/fix-sls-1.17
Use package.disable to prevent packaging with SLS <= 1.17.
2 parents 8cd26b5 + 2bd5a61 commit 9e115a7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/packageModules.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ const fs = require('fs');
88
const glob = require('glob');
99
const semver = require('semver');
1010

11-
function setArtifactPath(func, artifactPath) {
11+
function setArtifactPath(funcName, func, artifactPath) {
1212
const version = this.serverless.getVersion();
1313

1414
// Serverless changed the artifact path location in version 1.18
1515
if (semver.lt(version, '1.18.0')) {
1616
func.artifact = artifactPath;
17+
func.package = _.assign({}, func.package, { disable: true });
18+
this.serverless.cli.log(`${funcName} is packaged by the webpack plugin. Ignore messages from SLS.`);
1719
} else {
1820
func.package = {
1921
artifact: artifactPath,
@@ -87,7 +89,7 @@ module.exports = {
8789
this.serverless.cli.log(`Zip ${_.isEmpty(entryFunction) ? 'service' : 'function'}: ${modulePath} [${_.now() - startZip} ms]`))
8890
.then(artifactPath => {
8991
if (_.get(this.serverless, 'service.package.individually')) {
90-
setArtifactPath.call(this, entryFunction.func, path.relative(this.serverless.config.servicePath, artifactPath));
92+
setArtifactPath.call(this, entryFunction.funcName, entryFunction.func, path.relative(this.serverless.config.servicePath, artifactPath));
9193
}
9294
return artifactPath;
9395
});
@@ -98,7 +100,7 @@ module.exports = {
98100
const allFunctionNames = this.serverless.service.getAllFunctions();
99101
_.forEach(allFunctionNames, funcName => {
100102
const func = this.serverless.service.getFunction(funcName);
101-
setArtifactPath.call(this, func, path.relative(this.serverless.config.servicePath, artifacts[0]));
103+
setArtifactPath.call(this, funcName, func, path.relative(this.serverless.config.servicePath, artifacts[0]));
102104
});
103105
// For Google set the service artifact path
104106
if (_.get(this.serverless, 'service.provider.name') === 'google') {

tests/packageModules.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ describe('packageModules', () => {
321321
.then(() => BbPromise.all([
322322
expect(func1).to.have.a.nested.property('artifact').that.equals(expectedArtifactPath),
323323
expect(func2).to.have.a.nested.property('artifact').that.equals(expectedArtifactPath),
324+
expect(func1).to.have.a.nested.property('package.disable').that.is.true,
325+
expect(func2).to.have.a.nested.property('package.disable').that.is.true,
324326
]));
325327
}));
326328
});

0 commit comments

Comments
 (0)