Skip to content

Commit 953c437

Browse files
author
John Reeves
committed
fix(serverless#281): Fixes the bug
This works at least for our needs. As part of `copyDependencies`, we copy any artifacts if a function specifies one into .build/.serverless/$(basename artifact) if it is a relative path. It seems absolute paths already worked but it makes 0 sense to use those.
1 parent 8d98a51 commit 953c437

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/index.ts

+18
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,23 @@ export class TypeScriptPlugin {
276276
if (!fs.existsSync(outPkgPath)) {
277277
await this.linkOrCopy(path.resolve('package.json'), outPkgPath, 'file')
278278
}
279+
280+
const { service } = this.serverless
281+
if (service.package.individually) {
282+
for (const [_name, functionObject] of Object.entries(service.functions)) {
283+
const oldHome = functionObject.package.artifact
284+
if (!oldHome || path.isAbsolute(oldHome)) {
285+
continue
286+
}
287+
const newHome = path.join(
288+
path.join(this.getRealServicePath(), BUILD_FOLDER, SERVERLESS_FOLDER),
289+
path.basename(oldHome)
290+
)
291+
this.serverless.cli.log(`TS: copying ${oldHome} to ${newHome}`)
292+
await fs.copy(oldHome, newHome)
293+
functionObject.package.artifact = newHome
294+
}
295+
}
279296
}
280297

281298
/**
@@ -312,6 +329,7 @@ export class TypeScriptPlugin {
312329
return
313330
}
314331

332+
// It seems like this does nothing because the paths are already set so they point inside the .serverless folder.
315333
if (service.package.individually) {
316334
const functionNames = service.getAllFunctions()
317335
functionNames.forEach(name => {

0 commit comments

Comments
 (0)