-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Generate yarn.lock if cdk --init is used with yarn #4795
Description
Use Case
$ yarn global add cdk
$ cdk init --language=typescript
Executing npm install...The expected behavior would be to run yarn install, to generate a yarn.lock instead of a package-lock.json
Proposed Solution
The issue is detecting whether cdk init was called from a npm or yarn global directory. Simply checking that yarn is installed is a tad overeager.
The cleanest solution would be to attempt to run yarn global bin. If this returns a valid path, and that path.join(yarnBinPath, 'cdk') exists, we can assume that the user yarn global install cdkd.
EDIT : We could be even stricter and match path.join(yarnBinPath, 'cdk') with process.argv[1], since it should look something like ['node', 'path/to/cdk', 'init']
After that, swap 'npm' with 'yarn', done:
aws-cdk/packages/aws-cdk/lib/init.ts
Line 264 in af56996
| const command = 'npm'; |
We could also add an option to init to forcefully provide command.
Other
Related to #871. Proposed yarn create @aws-cdk/deploy shouldn't generate a package-lock.json.
- 👋 I may be able to implement this feature request
-
⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request