Skip to content

Commit 85ef481

Browse files
committed
Update getFromEnv logic to use ?? instead of || to allow for overriding of truthy values with falsey ones
Additionally, cast the `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` check to a number to allow for values of 0 or 1
1 parent c4fbc64 commit 85ef481

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/install/installer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));
3333
const removeFolderAsync = util.promisify(removeFolder);
3434

3535
export async function installBrowsersWithProgressBar(packagePath: string) {
36-
if (getFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD')) {
36+
// PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD should have a value of 0 or 1
37+
if (!!Number(getFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD'))) {
3738
browserFetcher.logPolitely('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
3839
return false;
3940
}

src/utils/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export function isUnderTest(): boolean {
9797

9898
export function getFromENV(name: string) {
9999
let value = process.env[name];
100-
value = value || process.env[`npm_config_${name.toLowerCase()}`];
101-
value = value || process.env[`npm_package_config_${name.toLowerCase()}`];
100+
value = value ?? process.env[`npm_config_${name.toLowerCase()}`];
101+
value = value ?? process.env[`npm_package_config_${name.toLowerCase()}`];
102102
return value;
103103
}
104104

0 commit comments

Comments
 (0)