mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
fix deploy function with service artifact
This commit is contained in:
parent
ea9c7659e2
commit
42d48892c2
@ -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);
|
||||
|
||||
@ -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`;
|
||||
|
||||
@ -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
4508
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user