Skip to content

Commit d34bdc9

Browse files
committed
fix single function deployment
1 parent 6ecc5ad commit d34bdc9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ class ServerlessPythonRequirements {
151151
.then(cleanup)
152152
.then(removeVendorHelper);
153153

154+
const setupArtifactPathCapturing = () => {
155+
// Reference:
156+
// https://github.com/serverless/serverless/blob/9591d5a232c641155613d23b0f88ca05ea51b436/lib/plugins/package/lib/packageService.js#L139
157+
// The packageService#packageFunction does set artifact path back to the function config.
158+
// As long as the function config's "package" attribute wasn't undefined, we can still use it
159+
// later to access the artifact path.
160+
for (const functionName in this.serverless.service.functions) {
161+
if (!serverless.service.functions[functionName].package) {
162+
serverless.service.functions[functionName].package = {}
163+
}
164+
}
165+
}
166+
154167
const before = () => {
155168
if (!isFunctionRuntimePython(arguments)) {
156169
return;
@@ -160,7 +173,8 @@ class ServerlessPythonRequirements {
160173
.then(pyprojectTomlToRequirements)
161174
.then(addVendorHelper)
162175
.then(installAllRequirements)
163-
.then(packRequirements);
176+
.then(packRequirements)
177+
.then(setupArtifactPathCapturing);
164178
};
165179

166180
const after = () => {

0 commit comments

Comments
 (0)