diff --git a/index.js b/index.js index 1ca516a857..271c93db73 100644 --- a/index.js +++ b/index.js @@ -431,7 +431,7 @@ module.exports.sync = (command, args, options) => { const error = makeError(result, { 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 bcc850aac8..7055c6d1d3 100644 --- a/test.js +++ b/test.js @@ -393,6 +393,14 @@ test('timeout kills the process if it times out', async t => { t.true(error.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 error = await execa('delay', ['500'], {timeout: 1e8}); t.false(error.timedOut);