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:
parent
c97af3ee91
commit
ea910a4ce2
|
|
@ -33,7 +33,8 @@ const fsWriteFileAsync = util.promisify(fs.writeFile.bind(fs));
|
||||||
const removeFolderAsync = util.promisify(removeFolder);
|
const removeFolderAsync = util.promisify(removeFolder);
|
||||||
|
|
||||||
export async function installBrowsersWithProgressBar(packagePath: string) {
|
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');
|
browserFetcher.logPolitely('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,8 @@ export function isUnderTest(): boolean {
|
||||||
|
|
||||||
export function getFromENV(name: string) {
|
export function getFromENV(name: string) {
|
||||||
let value = process.env[name];
|
let value = process.env[name];
|
||||||
value = value || process.env[`npm_config_${name.toLowerCase()}`];
|
value = typeof value === 'undefined' ? process.env[`npm_config_${name.toLowerCase()}`] : value;
|
||||||
value = value || process.env[`npm_package_config_${name.toLowerCase()}`];
|
value = typeof value === 'undefined' ? process.env[`npm_package_config_${name.toLowerCase()}`] : value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue