Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lambda-nodejs): pnpm exec command #14954

Merged
merged 3 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/lib/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class PackageManager {
public static PNPM = new PackageManager({
lockFile: 'pnpm-lock.yaml',
installCommand: ['pnpm', 'install'],
runCommand: ['pnpm', 'run'],
runCommand: ['pnpm', 'exec'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting The "pnpm exec" command currently only works with the "-r" option with only exec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try:

pnpm --version

cd aws-cdk/packages/@aws-cdk/aws-lambda-nodejs

pnpm exec esbuild -- --bundle test/integ-handlers/ts-handler.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK it's working. For some reason not in the Docker image...

});

public static fromLockFile(lockFilePath: string): PackageManager {
Expand Down Expand Up @@ -60,6 +60,7 @@ export class PackageManager {
os.platform() === 'win32' ? `${runCommand}.cmd` : runCommand,
...runArgs,
bin,
...(this.lockFile === PackageManager.PNPM.lockFile ? ['--'] : []),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required to pass parameters to bin command

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's introduce argsSeparator?: string in PackageManager.

].join(' ');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('from a pnpm-lock.yaml', () => {
const packageManager = PackageManager.fromLockFile('/path/to/pnpm-lock.yaml');
expect(packageManager).toEqual(PackageManager.PNPM);

expect(packageManager.runBinCommand('my-bin')).toBe('pnpm run my-bin');
expect(packageManager.runBinCommand('my-bin')).toBe('pnpm exec my-bin --');
});

test('defaults to NPM', () => {
Expand Down