Skip to content

Commit

Permalink
fix(lambda-nodejs): incorrect working directory for local bundling
Browse files Browse the repository at this point in the history
Execute local bundling from the directory containing the entry file.

Without this change, in a monorepo with multiple `package.json` files
Parcel doesn't look for the right one.

Also fix a regression introduced in aws#9632 for the working directory in
the container.
  • Loading branch information
jogold committed Aug 20, 2020
1 parent b1d0ac0 commit 13619c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/bundlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class LocalBundler implements cdk.ILocalBundling {
process.stderr, // redirect stdout to stderr
'inherit', // inherit stderr
],
cwd: path.dirname(path.join(this.props.projectRoot, this.props.relativeEntryPath)),
});
return true;
}
Expand Down Expand Up @@ -107,7 +108,7 @@ export class DockerBundler {
image,
command: ['bash', '-c', command],
environment: props.environment,
workingDirectory: path.dirname(path.join(cdk.AssetStaging.BUNDLING_INPUT_DIR, props.relativeEntryPath)),
workingDirectory: path.dirname(path.join(cdk.AssetStaging.BUNDLING_INPUT_DIR, props.relativeEntryPath)).replace(/\\/g, '/'), // Always use POSIX paths in the container,
};
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-lambda-nodejs/test/bundling.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ test('Local bundling', () => {
],
expect.objectContaining({
env: expect.objectContaining({ KEY: 'value' }),
cwd: '/project/folder',
}),
);

Expand Down

0 comments on commit 13619c1

Please sign in to comment.