fix: update getFromEnv logic to validate that value is undefined (instead of falsey) before redefining it (#4226)

Additionally, cast the `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` check to a number to allow for values of 0 or 1
This commit is contained in:
Maja Wichrowska 2020-10-23 11:52:25 -07:00 committed by GitHub
parent c97af3ee91
commit ea910a4ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View file

@ -33,7 +33,8 @@ const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));
const removeFolderAsync = util.promisify(removeFolder);
export async function installBrowsersWithProgressBar(packagePath: string) {
if (getFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD')) {
// PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD should have a value of 0 or 1
if (!!Number(getFromENV('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD'))) {
browserFetcher.logPolitely('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
return false;
}

View file

@ -97,8 +97,8 @@ export function isUnderTest(): boolean {
export function getFromENV(name: string) {
let value = process.env[name];
value = value || process.env[`npm_config_${name.toLowerCase()}`];
value = value || process.env[`npm_package_config_${name.toLowerCase()}`];
value = typeof value === 'undefined' ? process.env[`npm_config_${name.toLowerCase()}`] : value;
value = typeof value === 'undefined' ? process.env[`npm_package_config_${name.toLowerCase()}`] : value;
return value;
}