From d33de2b04336d3c78076809b2d07b0c6fde0db2f Mon Sep 17 00:00:00 2001 From: Mark Terrel Date: Wed, 25 Nov 2020 15:31:40 -0700 Subject: [PATCH] [BREAKING] Remove faulty emulated ENOENT error on Windows (#446) --- index.js | 2 -- test/error.js | 15 +++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index d94125310c..c8739e4549 100644 --- a/index.js +++ b/index.js @@ -147,8 +147,6 @@ const execa = (file, args, options) => { const handlePromiseOnce = onetime(handlePromise); - crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed); - handleInput(spawned, parsed.options.input); spawned.all = makeAllStream(spawned, parsed.options); diff --git a/test/error.js b/test/error.js index 386c6508c3..85e489f141 100644 --- a/test/error.js +++ b/test/error.js @@ -73,8 +73,8 @@ test('error.shortMessage does not contain stdout/stderr', async t => { }); test('Original error.message is kept', async t => { - const {originalMessage} = await t.throwsAsync(execa('wrong command')); - t.is(originalMessage, 'spawn wrong command ENOENT'); + const {originalMessage} = await t.throwsAsync(execa('noop', {cwd: 1})); + t.regex(originalMessage, /The "options.cwd" property must be of type string. Received type number/); }); test('failed is false on success', async t => { @@ -204,7 +204,10 @@ test('error.code is undefined on success', async t => { t.is(code, undefined); }); -test('error.code is defined on failure if applicable', async t => { - const {code} = await t.throwsAsync(execa('invalid')); - t.is(code, 'ENOENT'); -}); +// Windows doesn't throw ENOENT on invalid command +if (process.platform !== 'win32') { + test('error.code is defined on failure if applicable', async t => { + const {code} = await t.throwsAsync(execa('invalid')); + t.is(code, 'ENOENT'); + }); +}