Skip to content

Commit

Permalink
feat(cli): Support disabling version check
Browse files Browse the repository at this point in the history
If AWS_CDK_DISABLE_VERSION_CHECK is defined, skip checking for newer
versions.

fixes #10974
  • Loading branch information
christophgysin committed Oct 20, 2020
1 parent dd81e77 commit 116428b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/aws-cdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,9 @@ Some of the interesting keys that can be used in the JSON configuration files:
"versionReporting": false, // Opt-out of version reporting (--no-version-reporting)
}
```

#### Environment

The following environment variables affect aws-cdk:

- `AWS_CDK_DISABLE_VERSION_CHECK`: If set, disable automatic check for newer versions.
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export async function latestVersionIfHigher(currentVersion: string, cacheFile: V
}

export async function displayVersionMessage(): Promise<void> {
if (!process.stdout.isTTY) {
if (!process.stdout.isTTY || process.env.AWS_CDK_DISABLE_VERSION_CHECK) {
return;
}

Expand Down
7 changes: 7 additions & 0 deletions packages/aws-cdk/test/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ test('No Version specified for storage in the TTL file', async () => {
const storedVersion = fs.readFileSync(cacheFile, 'utf8');
expect(storedVersion).toBe('');
});

test('Skip version check if environment variable is set', async () => {
process.env.AWS_CDK_DISABLE_VERSION_CHECK = '1';
const cache = new VersionCheckTTL(tmpfile(), 0);
await cache.update();
expect(await latestVersionIfHigher('0.0.0', cache)).toBeNull();
});

0 comments on commit 116428b

Please sign in to comment.