Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): cannot set environment variable CI=false #32749

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/util/yargs-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function yargsNegativeAlias<T extends { [x in S | L]: boolean | undefined
* @returns true if the current process is running in a CI environment
*/
export function isCI(): boolean {
return process.env.CI !== undefined;
return process.env.CI !== undefined && process.env.CI !== 'false' && process.env.CI !== '0';
}

/**
Expand Down
14 changes: 14 additions & 0 deletions packages/aws-cdk/test/util/yargs-helpers.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { isCI } from '../../lib/util/yargs-helpers';

test.each([
['true', true],
['1', true],
['false', false],
['0', false],
// The following ones are unexpected but this is the legacy behavior we're preserving.
['banana', true],
['', false],
])('test parsing of falsey CI values: %p parses as %p', (envvar, ci) => {
process.env.CI = envvar;
expect(isCI()).toEqual(ci);
});
Loading