diff --git a/packages/aws-cdk/README.md b/packages/aws-cdk/README.md index 0ac2e08947ec8..f50fb6509b1f9 100644 --- a/packages/aws-cdk/README.md +++ b/packages/aws-cdk/README.md @@ -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" }, diff --git a/packages/aws-cdk/lib/cli.ts b/packages/aws-cdk/lib/cli.ts index b7c2931d233ae..1a20ed9edf279 100644 --- a/packages/aws-cdk/lib/cli.ts +++ b/packages/aws-cdk/lib/cli.ts @@ -56,6 +56,7 @@ async function parseCommandLineArguments() { .env('CDK') .usage('Usage: cdk -a 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' }) diff --git a/packages/aws-cdk/lib/settings.ts b/packages/aws-cdk/lib/settings.ts index ddb28be756292..7a213111f6c9f 100644 --- a/packages/aws-cdk/lib/settings.ts +++ b/packages/aws-cdk/lib/settings.ts @@ -265,6 +265,7 @@ export class Settings { return new Settings({ app: argv.app, browser: argv.browser, + build: argv.build, context, debug: argv.debug, tags, diff --git a/packages/aws-cdk/test/settings.test.ts b/packages/aws-cdk/test/settings.test.ts index aef16e6bac946..8c2c894ae4634 100644 --- a/packages/aws-cdk/test/settings.test.ts +++ b/packages/aws-cdk/test/settings.test.ts @@ -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'); +}); \ No newline at end of file