Skip to content

Commit

Permalink
Added catch to refreshNotices call;
Browse files Browse the repository at this point in the history
Type of main updated;
Refresh doesn't force a cache update
  • Loading branch information
Otavio Macedo committed Feb 22, 2022
1 parent 6b89ea1 commit bf55bb2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ export class CdkToolkit {
}
}

public async list(selectors: string[], options: { long?: boolean } = { }) {
public async list(selectors: string[], options: { long?: boolean, json?: boolean } = { }): Promise<number> {
const stacks = await this.selectStacksForList(selectors);

// if we are in "long" mode, emit the array as-is (JSON/YAML)
Expand All @@ -404,7 +404,8 @@ export class CdkToolkit {
environment: stack.environment,
});
}
return long; // will be YAML formatted output
data(serializeStructure(long, options.json ?? false));
return 0;
}

// just print stack IDs
Expand Down
8 changes: 5 additions & 3 deletions packages/aws-cdk/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ if (!process.stdout.isTTY) {
}

async function initCommandLine() {
void refreshNotices().then(_ => debug('Notices refreshed'));
void refreshNotices()
.then(_ => debug('Notices refreshed'))
.catch(e => debug(`Notices refresh failed: ${e}`));

const argv = await parseCommandLineArguments();
if (argv.verbose) {
Expand Down Expand Up @@ -325,7 +327,7 @@ async function initCommandLine() {
}
}

async function main(command: string, args: any): Promise<number | string | {} | void> {
async function main(command: string, args: any): Promise<number | void> {
const toolkitStackName: string = ToolkitInfo.determineName(configuration.settings.get(['toolkitStackName']));
debug(`Toolkit stack: ${chalk.bold(toolkitStackName)}`);

Expand Down Expand Up @@ -363,7 +365,7 @@ async function initCommandLine() {

case 'ls':
case 'list':
return cli.list(args.STACKS, { long: args.long });
return cli.list(args.STACKS, { long: args.long, json: argv.json });

case 'diff':
const enableDiffNoFail = isFeatureEnabled(configuration, cxapi.ENABLE_DIFF_NO_FAIL);
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/notices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface DisplayNoticesProps {
}

export async function refreshNotices() {
const dataSource = dataSourceReference(true);
const dataSource = dataSourceReference(false);
return dataSource.fetch();
}

Expand Down

0 comments on commit bf55bb2

Please sign in to comment.