From 21c706a86f13359020f07e0c68324b5c4692f069 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Tue, 14 May 2019 11:47:40 -0700 Subject: [PATCH] Fix `error.timedOut` not working with `execa.sync()` (#249) --- index.js | 2 +- test.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 4c2cbb1f03..2fd84c5c7d 100644 --- a/index.js +++ b/index.js @@ -431,7 +431,7 @@ module.exports.sync = (command, args, options) => { code: result.status, joinedCommand, parsed, - timedOut: false, + timedOut: result.error && result.error.errno === 'ETIMEDOUT', isCanceled: false, killed: result.signal !== null }); diff --git a/test.js b/test.js index 5d54b01eb9..d79be2abc0 100644 --- a/test.js +++ b/test.js @@ -395,6 +395,14 @@ test('timeout kills the process if it times out', async t => { t.true(timedOut); }); +test('timeout kills the process if it times out, in sync mode', async t => { + const {killed, timedOut} = await t.throws(() => { + execa.sync('forever', {timeout: 1, message: TIMEOUT_REGEXP}); + }); + t.false(killed); + t.true(timedOut); +}); + test('timeout does not kill the process if it does not time out', async t => { const {timedOut} = await execa('delay', ['500'], {timeout: 1e8}); t.false(timedOut);