Skip to content

Commit 5726c45

Browse files
author
Elad Ben-Israel
authored
feat(toolkit): print available templates when --language is omitted (#1159)
When --language is omitted from a call to "cdk init", instead of just printing the supported languages, we now print all options, including template types.
1 parent e9b4a33 commit 5726c45

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/aws-cdk/bin/cdk.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ async function initCommandLine() {
206206
if (args.list) {
207207
return await printAvailableTemplates(language);
208208
} else {
209-
return await cliInit(args.TEMPLATE || 'default', language);
209+
return await cliInit(args.TEMPLATE, language);
210210
}
211211

212212
default:

packages/aws-cdk/lib/init.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,15 @@ const CDK_HOME = process.env.CDK_HOME ? path.resolve(process.env.CDK_HOME) : pat
1818
/**
1919
* Initialize a CDK package in the current directory
2020
*/
21-
export async function cliInit(type: string, language: string | undefined, canUseNetwork?: boolean) {
22-
const template = (await availableInitTemplates).find(t => t.hasName(type));
21+
export async function cliInit(type?: string, language?: string, canUseNetwork?: boolean) {
22+
if (!type && !language) {
23+
await printAvailableTemplates();
24+
return;
25+
}
26+
27+
type = type || 'default'; // "default" is the default type (and maps to "app")
28+
29+
const template = (await availableInitTemplates).find(t => t.hasName(type!));
2330
if (!template) {
2431
await printAvailableTemplates(language);
2532
throw new Error(`Unknown init template: ${type}`);

0 commit comments

Comments
 (0)