Skip to content

Commit

Permalink
fix(serverless#281): Fixes the bug
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
John Reeves committed Oct 27, 2022
1 parent 8d98a51 commit 953c437
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,23 @@ export class TypeScriptPlugin {
if (!fs.existsSync(outPkgPath)) {
await this.linkOrCopy(path.resolve('package.json'), outPkgPath, 'file')
}

const { service } = this.serverless
if (service.package.individually) {
for (const [_name, functionObject] of Object.entries(service.functions)) {
const oldHome = functionObject.package.artifact
if (!oldHome || path.isAbsolute(oldHome)) {
continue
}
const newHome = path.join(
path.join(this.getRealServicePath(), BUILD_FOLDER, SERVERLESS_FOLDER),
path.basename(oldHome)
)
this.serverless.cli.log(`TS: copying ${oldHome} to ${newHome}`)
await fs.copy(oldHome, newHome)
functionObject.package.artifact = newHome
}
}
}

/**
Expand Down Expand Up @@ -312,6 +329,7 @@ export class TypeScriptPlugin {
return
}

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

0 comments on commit 953c437

Please sign in to comment.