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

feat(cli): add --build option #19663

Merged
merged 5 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion packages/aws-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ Some of the interesting keys that can be used in the JSON configuration files:
```json5
{
"app": "node bin/main.js", // Command to start the CDK app (--app='node bin/main.js')
"build": "mvn package", // Specify pre-synth build (no command line option)
"build": "mvn package", // Specify pre-synth build (--build='mvn package')
"context": { // Context entries (--context=key=value)
"key": "value"
},
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function parseCommandLineArguments() {
.env('CDK')
.usage('Usage: cdk -a <cdk-app> COMMAND')
.option('app', { type: 'string', alias: 'a', desc: 'REQUIRED: command-line for executing your app or a cloud assembly directory (e.g. "node bin/my-app.js")', requiresArg: true })
.option('build', { type: 'string', desc: 'Command-line for a pre-synth build' })
.option('context', { type: 'array', alias: 'c', desc: 'Add contextual string parameter (KEY=VALUE)', nargs: 1, requiresArg: true })
.option('plugin', { type: 'array', alias: 'p', desc: 'Name or path of a node package that extend the CDK features. Can be specified multiple times', nargs: 1 })
.option('trace', { type: 'boolean', desc: 'Print trace for stack warnings' })
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export class Settings {
return new Settings({
app: argv.app,
browser: argv.browser,
build: argv.build,
context,
debug: argv.debug,
tags,
Expand Down
11 changes: 11 additions & 0 deletions packages/aws-cdk/test/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,14 @@ test('should include outputs-file in settings', () => {
// THEN
expect(settings.get(['outputsFile'])).toEqual('my-outputs-file.json');
});

test('providing a build arg', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
_: [Command.SYNTH],
build: 'mvn package',
});

// THEN
expect(settings.get(['build'])).toEqual('mvn package');
});