zkochan / packages

Zoltan Kochan's npm packages
MIT License
99 stars 26 forks source link

safe-execa throw unexpected error in shell mode #171

Closed await-ovo closed 1 year ago

await-ovo commented 1 year ago

Code to reproduce the issue:

Here is steps to reproduce:

  1. pnpm add safe-execa
  2. touch exec.mjs with follow contents:
import execa from 'safe-execa'
(async () => {
  await execa.default('echo "hi"', [],  {    
    stdio: 'inherit',
    shell: true,
  })
})()
  1. node ./exec.mjs will see the error below:
xxxx/test-pnpm/test-publish/node_modules/.pnpm/@zkochan+which@2.0.3/node_modules/@zkochan/which/which.js:10
  Object.assign(new Error(`not found: ${cmd}`), { code: 'ENOENT' })
                ^

Error: not found: echo "hi"

Expected behavior:

should execute command successfully.

Additional information:

node -v prints: v16.15.1 safe-execa version: v0.1.2 Windows, macOS, or Linux?: macOS

After some research, I found that which.sync will throw a error like this:

TypeError: (opt.path || process.env.PATH || "").split is not a function
    at getPathInfo (/xxxx/test/test-pnpm/test-publish/node_modules/.pnpm/@zkochan+which@2.0.3/node_modules/@zkochan/which/which.js:19:56)

it seems that @zkochan/which only accept string path option.