fix deploy function with service artifact

This commit is contained in:
Eslam A. Hefnawy 2017-07-07 19:22:42 +07:00
parent ea9c7659e2
commit 42d48892c2
4 changed files with 4454 additions and 87 deletions

View File

@ -69,7 +69,8 @@ class AwsDeployFunction {
deployFunction() {
const artifactFileName = this.provider.naming
.getFunctionArtifactName(this.options.function);
let artifactFilePath = path.join(this.packagePath, artifactFileName);
let artifactFilePath = this.serverless.service.package.artifact ||
path.join(this.packagePath, artifactFileName);
// check if an artifact is used in function package level
const functionObject = this.serverless.service.getFunction(this.options.function);

View File

@ -82,6 +82,14 @@ module.exports = {
return BbPromise.resolve(filePath);
}
// use the artifact in service config if provided
if (this.serverless.service.package.artifact) {
const filePath = path.join(this.serverless.config.servicePath,
this.serverless.service.package.artifact);
funcPackageConfig.artifact = filePath;
return BbPromise.resolve(filePath);
}
const exclude = this.getExcludes(funcPackageConfig.exclude);
const include = this.getIncludes(funcPackageConfig.include);
const zipFileName = `${functionName}.zip`;

View File

@ -295,5 +295,27 @@ describe('#packageService()', () => {
expect(zipServiceStub).to.not.have.been.called,
]));
});
it('should return service artifact file path', () => {
const servicePath = 'test';
const funcName = 'test-func';
serverless.config.servicePath = servicePath;
serverless.service.functions = {};
serverless.service.package = {
artifact: 'artifact.zip',
};
serverless.service.functions[funcName] = {
name: `test-proj-${funcName}`,
};
return expect(packagePlugin.packageFunction(funcName)).to.eventually
.equal('test/artifact.zip')
.then(() => BbPromise.all([
expect(getExcludesStub).to.not.have.been.called,
expect(getIncludesStub).to.not.have.been.called,
expect(zipServiceStub).to.not.have.been.called,
]));
});
});
});

4508
package-lock.json generated

File diff suppressed because it is too large Load Diff