Skip to content

Commit

Permalink
Make displayversion lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Feb 14, 2025
1 parent a529ae8 commit 441fc04
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/aws-cdk/lib/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
debug(`Error while checking for platform warnings: ${e}`);
}

debug('CDK toolkit version:', version.DISPLAY_VERSION);
debug('CDK toolkit version:', version.displayVersion());
debug('Command line arguments:', argv);

const configuration = new Configuration({
Expand Down Expand Up @@ -494,7 +494,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
});
case 'version':
ioHost.currentAction = 'version';
return result(version.DISPLAY_VERSION);
return result(version.displayVersion());

default:
throw new ToolkitError('Unknown command: ' + command);
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/cli/util/yargs-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function yargsNegativeAlias<T extends { [x in S | L]: boolean | undefined
* @returns the current version of the CLI
*/
export function cliVersion(): string {
return version.DISPLAY_VERSION;
return version.displayVersion();
}

/**
Expand Down
4 changes: 3 additions & 1 deletion packages/aws-cdk/lib/cli/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const UPGRADE_DOCUMENTATION_LINKS: Record<number, string> = {
1: 'https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html',
};

export const DISPLAY_VERSION = `${versionNumber()} (build ${commit()})`;
export function displayVersion() {
return `${versionNumber()} (build ${commit()})`;
}

export function isDeveloperBuild(): boolean {
return versionNumber() === '0.0.0';
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/commands/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const verifications: Array<() => boolean | Promise<boolean>> = [
// ### Verifications ###

function displayVersionInformation() {
info(`ℹ️ CDK Version: ${chalk.green(version.DISPLAY_VERSION)}`);
info(`ℹ️ CDK Version: ${chalk.green(version.displayVersion())}`);
return true;
}

Expand Down

0 comments on commit 441fc04

Please sign in to comment.