Skip to content

Commit

Permalink
fix(cli): fix the behaviour for the --generate-only flag (#5253)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy authored and mergify[bot] committed Nov 29, 2019
1 parent d1f0dd5 commit ecbe0b6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,10 @@ async function initCommandLine() {

case 'init':
const language = configuration.settings.get(['language']);
const generateOnly = configuration.settings.get(['generate-only']);
if (args.list) {
return await printAvailableTemplates(language);
} else {
return await cliInit(args.TEMPLATE, language, undefined, generateOnly);
return await cliInit(args.TEMPLATE, language, undefined, args.generateOnly);
}
case 'version':
return data(version.DISPLAY_VERSION);
Expand Down
1 change: 0 additions & 1 deletion packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ export class Settings {
versionReporting: argv.versionReporting,
staging: argv.staging,
output: argv.output,
generateOnly: argv.generateOnly,
});
}

Expand Down
22 changes: 22 additions & 0 deletions packages/aws-cdk/test/integ/init/test-generate-only.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
#------------------------------------------------------------------
# setup
#------------------------------------------------------------------
set -e
scriptdir=$(cd $(dirname $0) && pwd)
source ${scriptdir}/common.bash

header "--generate-only"

#------------------------------------------------------------------

echo "Trying --generate-only"

setup

cdk init -l javascript --generate-only

if [ -d .git ]
then
fail "git shouldn't have been initialized"
fi
12 changes: 12 additions & 0 deletions packages/aws-cdk/test/test.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ export = {
// Check that package.json and bin/ got created in the current directory
test.equal(true, await fs.pathExists('package.json'));
test.equal(true, await fs.pathExists('bin'));
test.equal(true, await fs.pathExists('.git'));

test.done();
},

async '--generate-only should skip git init'(test: Test) {
await cliInit('app', 'javascript', false, true);

// Check that package.json and bin/ got created in the current directory
test.equal(true, await fs.pathExists('package.json'));
test.equal(true, await fs.pathExists('bin'));
test.equal(false, await fs.pathExists('.git'));

test.done();
},
Expand Down

0 comments on commit ecbe0b6

Please sign in to comment.