File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 11/* @flow */
2+ /* eslint-disable max-len */
23
34import type { Reporter } from '../../reporters/index.js' ;
45import type Config from '../../config.js' ;
Original file line number Diff line number Diff line change @@ -19,16 +19,18 @@ export const exec = promisify(child.exec);
1919
2020function validate ( program : string , opts ?: Object = { } ) {
2121 if ( program . includes ( '/' ) ) {
22- return true ;
22+ return ;
2323 }
2424
25- const cwd = opts . cwd || process . cwd ( ) ;
26- const pathext = process . env . PATHEXT || '' ;
25+ if ( process . platform === 'win32' && process . env . PATHEXT ) {
26+ const cwd = opts . cwd || process . cwd ( ) ;
27+ const pathext = process . env . PATHEXT ;
2728
28- for ( const ext of pathext . split ( ';' ) ) {
29- const candidate = path . join ( cwd , `${ program } ${ ext } ` ) ;
30- if ( fs . existsSync ( candidate ) ) {
31- throw new Error ( `Potentially dangerous call to "${ program } " in ${ cwd } ` ) ;
29+ for ( const ext of pathext . split ( ';' ) ) {
30+ const candidate = path . join ( cwd , `${ program } ${ ext } ` ) ;
31+ if ( fs . existsSync ( candidate ) ) {
32+ throw new Error ( `Potentially dangerous call to "${ program } " in ${ cwd } ` ) ;
33+ }
3234 }
3335 }
3436}
You can’t perform that action at this time.
0 commit comments