File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ import * as removeFolder from 'rimraf';
22
22
import * as lockfile from 'proper-lockfile' ;
23
23
import * as browserPaths from '../utils/browserPaths' ;
24
24
import * as browserFetcher from './browserFetcher' ;
25
- import { getFromENV } from '../utils/utils' ;
25
+ import { getAsBooleanFromENV } from '../utils/utils' ;
26
26
27
27
const fsMkdirAsync = util . promisify ( fs . mkdir . bind ( fs ) ) ;
28
28
const fsReaddirAsync = util . promisify ( fs . readdir . bind ( fs ) ) ;
@@ -34,7 +34,7 @@ const removeFolderAsync = util.promisify(removeFolder);
34
34
35
35
export async function installBrowsersWithProgressBar ( packagePath : string ) {
36
36
// PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD should have a value of 0 or 1
37
- if ( ! ! Number ( getFromENV ( 'PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD' ) ) ) {
37
+ if ( getAsBooleanFromENV ( 'PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD' ) ) {
38
38
browserFetcher . logPolitely ( 'Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set' ) ;
39
39
return false ;
40
40
}
Original file line number Diff line number Diff line change @@ -95,13 +95,18 @@ export function isUnderTest(): boolean {
95
95
return _isUnderTest ;
96
96
}
97
97
98
- export function getFromENV ( name : string ) {
98
+ export function getFromENV ( name : string ) : string | undefined {
99
99
let value = process . env [ name ] ;
100
- value = typeof value === ' undefined' ? process . env [ `npm_config_${ name . toLowerCase ( ) } ` ] : value ;
101
- value = typeof value === ' undefined' ? process . env [ `npm_package_config_${ name . toLowerCase ( ) } ` ] : value ;
100
+ value = value === undefined ? process . env [ `npm_config_${ name . toLowerCase ( ) } ` ] : value ;
101
+ value = value === undefined ? process . env [ `npm_package_config_${ name . toLowerCase ( ) } ` ] : value ;
102
102
return value ;
103
103
}
104
104
105
+ export function getAsBooleanFromENV ( name : string ) : boolean {
106
+ const value = getFromENV ( name ) ;
107
+ return ! ! value && value !== 'false' && value !== '0' ;
108
+ }
109
+
105
110
export async function mkdirIfNeeded ( filePath : string ) {
106
111
// This will harmlessly throw on windows if the dirname is the root directory.
107
112
await mkdirAsync ( path . dirname ( filePath ) , { recursive : true } ) . catch ( ( ) => { } ) ;
You can’t perform that action at this time.
0 commit comments