Skip to content

Commit

Permalink
fix(aws-cdk): cli always throws when init-templates are not available
Browse files Browse the repository at this point in the history
this happens on any command, not just init
  • Loading branch information
mrgrain committed Jan 12, 2023
1 parent fa9eef0 commit 35e707f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/aws-cdk/lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,17 @@ interface ProjectInfo {

export async function availableInitTemplates(): Promise<InitTemplate[]> {
return new Promise(async resolve => {
const templatesDir = path.join(rootDir(), 'lib', 'init-templates');
const templateNames = await listDirectory(templatesDir);
const templates = new Array<InitTemplate>();
for (const templateName of templateNames) {
templates.push(await InitTemplate.fromName(templatesDir, templateName));
try {
const templatesDir = path.join(rootDir(), 'lib', 'init-templates');
const templateNames = await listDirectory(templatesDir);
const templates = new Array<InitTemplate>();
for (const templateName of templateNames) {
templates.push(await InitTemplate.fromName(templatesDir, templateName));
}
resolve(templates);
} catch {
resolve([]);
}
resolve(templates);
});
}
export async function availableInitLanguages(): Promise<string[]> {
Expand Down

0 comments on commit 35e707f

Please sign in to comment.