Skip to content
Myr

ensure `execa` rejects and not throws when the core spawn throws and error

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sindre Sorhus · committed by Sindre Sorhus · parent e10d263 · Browse files · 3 files+10 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−4 removed

  • other:+10 added−4 removed

3 files+10 added−4 removed

modified:fixtures/non-executable-1 removed
1#!/usr/bin/env node2'use strict';3console.log(process.argv[2]);
modified:index.js+7 added-1 removed
142 unmodified lines
143144 var parsed = handleArgs(cmd, args, opts);145 var encoding = parsed.opts.encoding;146 var maxBuffer = parsed.opts.maxBuffer;147 var spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);147148 var spawned;149 try {150 spawned = childProcess.spawn(parsed.cmd, parsed.args, parsed.opts);151 } catch (err) {152 return Promise.reject(err);153 }154155 var promise = Promise.all([156 processDone(spawned),157 getStream(spawned, 'stdout', encoding, maxBuffer),158 getStream(spawned, 'stderr', encoding, maxBuffer)
93 unmodified lines
modified:test.js+3 added-2 removed
165 unmodified lines
166 t.is(stdout, 'foo');167});168169if (process.platform !== 'win32') {170 test('execa() throws if running non executable', async t => {171 t.throws(() => m('non-executable'));170 test('execa() rejects if running non-executable', t => {171 const cp = m('non-executable');172 t.throws(cp);173 });174}175176test('err.killed is true if process was killed directly', async t => {
109 unmodified lines