diff --git a/src/cli/commands/policies.js b/src/cli/commands/policies.js index 78be35b9c8..c1ac6709db 100644 --- a/src/cli/commands/policies.js +++ b/src/cli/commands/policies.js @@ -1,4 +1,5 @@ /* @flow */ +/* eslint-disable max-len */ import type {Reporter} from '../../reporters/index.js'; import type Config from '../../config.js'; diff --git a/src/util/child.js b/src/util/child.js index f0238de7c8..71840c4c19 100644 --- a/src/util/child.js +++ b/src/util/child.js @@ -19,16 +19,18 @@ export const exec = promisify(child.exec); function validate(program: string, opts?: Object = {}) { if (program.includes('/')) { - return true; + return; } - const cwd = opts.cwd || process.cwd(); - const pathext = process.env.PATHEXT || ''; + if (process.platform === 'win32' && process.env.PATHEXT) { + const cwd = opts.cwd || process.cwd(); + const pathext = process.env.PATHEXT; - for (const ext of pathext.split(';')) { - const candidate = path.join(cwd, `${program}${ext}`); - if (fs.existsSync(candidate)) { - throw new Error(`Potentially dangerous call to "${program}" in ${cwd}`); + for (const ext of pathext.split(';')) { + const candidate = path.join(cwd, `${program}${ext}`); + if (fs.existsSync(candidate)) { + throw new Error(`Potentially dangerous call to "${program}" in ${cwd}`); + } } } }