Skip to content
Myr

test.js

This file

Path

test.js

837 lines · 26.3 KiB · JavaScript

Last changed by

Fix shape of exceptions rejected by `execa()` (#276)ehmickybefore adoption49c74ac

History of this file

Take it

fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df

line 1why, one step back
1import path from 'path';

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 2why, one step back
2import fs from 'fs';

add `input` optionJames Talmagebefore adoption605a674

line 3why, one step back
3import stream from 'stream';

add tests (#48)James Talmagebefore adoptionb15483a

line 4why, one step back
4import childProcess from 'child_process';

initSindre Sorhusbefore adoptionbc16d6b

line 5
5import test from 'ava';

make `execa.spawn()` use the same argument normalization as `execa()`Sindre Sorhusbefore adoptiond6e3220

line 6why, one step back
6import getStream from 'get-stream';

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

line 7why, one step back
7import isRunning from 'is-running';

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 8why, one step back
8import tempfile from 'tempfile';

Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c

line 9why, one step back
9import pEvent from 'p-event';

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 10why, one step back
10import execa from '.';

initSindre Sorhusbefore adoptionbc16d6b

line 11
11

fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df

line 12why, one step back
12process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;

Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117

line 13why, one step back
13process.env.FOO = 'foo';

fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df

line 14why, one step back
14

Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4

line 15why, one step back
15const TIMEOUT_REGEXP = /timed out after/;

Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671

line 16why, one step back
16

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 17why, one step back
17const getExitRegExp = exitMessage => new RegExp(`failed with exit code ${exitMessage}`);

Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4

line 18why, one step back
18

initSindre Sorhusbefore adoptionbc16d6b

line 19
19test('execa()', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 20why, one step back
20 const {stdout} = await execa('noop', ['foo']);

initSindre Sorhusbefore adoptionbc16d6b

lines 21–23
21 t.is(stdout, 'foo');
22});23

Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235

lines 24–25why, one step back
24if (process.platform === 'win32') {
25 test('execa() - cmd file', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 26why, one step back
26 const {stdout} = await execa('hello.cmd');

Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235

lines 27–28why, one step back
27 t.is(stdout, 'Hello World');
28 });

Add `/q` option to `cmd` as well as `cmd.exe` on Windows (#203)Guillaume Martignybefore adoption10c73dc

lines 29–33why, one step back
29
30 test('execa() - run cmd command', async t => {31 const {stdout} = await execa('cmd', ['/c', 'hello.cmd']);32 t.is(stdout, 'Hello World');33 });

Turn off echo on Windows - fixes #116 (#118)Sam Verschuerenbefore adoptionff76235

lines 34–35why, one step back
34}
35

initSindre Sorhusbefore adoptionbc16d6b

line 36
36test('buffer', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 37why, one step back
37 const {stdout} = await execa('noop', ['foo'], {encoding: null});

initSindre Sorhusbefore adoptionbc16d6b

lines 38–41
38 t.true(Buffer.isBuffer(stdout));
39 t.is(stdout.toString(), 'foo');40});41

Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911

line 42why, one step back
42test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 43–44why, one step back
43 const {all} = await execa('noop-132');
44 t.is(all, '132');

Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911

lines 45–47why, one step back
45});
4647test('stdout/stderr/all available on errors', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 48–51why, one step back
48 const {stdout, stderr, all} = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});
49 t.is(typeof stdout, 'string');50 t.is(typeof stderr, 'string');51 t.is(typeof all, 'string');

add `stdout`/`stderr` to errorsSindre Sorhusbefore adoption0ea8aaf

lines 52–53why, one step back
52});
53

Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da

lines 54–67why, one step back
54test('stdout/stderr/all are undefined if ignored', async t => {
55 const {stdout, stderr, all} = await execa('noop', {stdio: 'ignore'});56 t.is(stdout, undefined);57 t.is(stderr, undefined);58 t.is(all, undefined);59});6061test('stdout/stderr/all are undefined if ignored in sync mode', t => {62 const {stdout, stderr, all} = execa.sync('noop', {stdio: 'ignore'});63 t.is(stdout, undefined);64 t.is(stderr, undefined);65 t.is(all, undefined);66});67

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

lines 68–71why, one step back
68const WRONG_COMMAND = process.platform === 'win32' ?
69 '\'wrong\' is not recognized as an internal or external command,\r\noperable program or batch file.' :70 '';71

Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da

lines 72–74why, one step back
72test('stdout/stderr/all on process errors', async t => {
73 const {stdout, stderr, all} = await t.throwsAsync(execa('wrong command'));74 t.is(stdout, '');

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

lines 75–76why, one step back
75 t.is(stderr, WRONG_COMMAND);
76 t.is(all, WRONG_COMMAND);

Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da

lines 77–83why, one step back
77});
7879test('stdout/stderr/all on process errors, in sync mode', t => {80 const {stdout, stderr, all} = t.throws(() => {81 execa.sync('wrong command');82 });83 t.is(stdout, '');

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

line 84why, one step back
84 t.is(stderr, WRONG_COMMAND);

Make `stdout` and `stderr` properties `undefined` instead of `null` (#246)ehmickybefore adoptionc8a53da

lines 85–87why, one step back
85 t.is(all, undefined);
86});87

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 88–89why, one step back
88test('pass `stdout` to a file descriptor', async t => {
89 const file = tempfile('.txt');

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 90why, one step back
90 await execa('fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 91–95why, one step back
91 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');
92});9394test('pass `stderr` to a file descriptor', async t => {95 const file = tempfile('.txt');

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 96why, one step back
96 await execa('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 97why, one step back
97 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');

Do not output stderr and stdout on stdio inherit - fixes #70 (#79)Sam Verschuerenbefore adoption2a12986

lines 98–99why, one step back
98});
99

add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c

line 100why, one step back
100test('execa.sync()', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 101why, one step back
101 const {stdout} = execa.sync('noop', ['foo']);

add `execa.sync()` (#7)Sindre Sorhusbefore adoption9345d2c

lines 102–104why, one step back
102 t.is(stdout, 'foo');
103});104

Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b

line 105why, one step back
105test('execa.sync() throws error if written to stderr', t => {

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

lines 106–107why, one step back
106 t.throws(() => {
107 execa.sync('foo');

Make error messages more consistent (#230)ehmickybefore adoption5f8bd52

line 108why, one step back
108 }, process.platform === 'win32' ? /failed with exit code 1/ : /spawnSync foo ENOENT/);

Throw error in sync method - fixes #66 (#67)Sam Verschuerenbefore adoptionc8c9c7b

lines 109–110why, one step back
109});
110

Improve tests for the `reject` option (#233)ehmickybefore adoptione55dc8b

line 111why, one step back
111test('skip throwing when using reject option', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 112–113why, one step back
112 const {exitCode} = await execa('fail', {reject: false});
113 t.is(exitCode, 2);

Enhance error object in sync methods - fixes #98 (#107)Sam Verschuerenbefore adoptiond31cc91

lines 114–115why, one step back
114});
115

Improve tests for the `reject` option (#233)ehmickybefore adoptione55dc8b

line 116why, one step back
116test('skip throwing when using reject option in sync mode', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 117–118why, one step back
117 const {exitCode} = execa.sync('fail', {reject: false});
118 t.is(exitCode, 2);

Improve tests for the `reject` option (#233)ehmickybefore adoptione55dc8b

lines 119–120why, one step back
119});
120

Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835

lines 121–122why, one step back
121test('kill("SIGKILL") should terminate cleanly', async t => {
122 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 123–133why, one step back
123 await pEvent(subprocess, 'message');
124125 subprocess.kill('SIGKILL');126127 const {signal} = await t.throwsAsync(subprocess);128 t.is(signal, 'SIGKILL');129});130131// `SIGTERM` cannot be caught on Windows, and it always aborts the process (like `SIGKILL` on Unix).132// Therefore, this feature and those tests do not make sense on Windows.133if (process.platform !== 'win32') {

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 134why, one step back
134 test('`forceKillAfterTimeout: false` should not kill after a timeout', async t => {

Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835

line 135why, one step back
135 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 136–137why, one step back
136 await pEvent(subprocess, 'message');
137

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 138why, one step back
138 subprocess.kill('SIGTERM', {forceKillAfterTimeout: false});

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 139–143why, one step back
139
140 t.true(isRunning(subprocess.pid));141 subprocess.kill('SIGKILL');142 });143

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 144why, one step back
144 test('`forceKillAfterTimeout: number` should kill after a timeout', async t => {

Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835

line 145why, one step back
145 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 146–147why, one step back
146 await pEvent(subprocess, 'message');
147

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 148why, one step back
148 subprocess.kill('SIGTERM', {forceKillAfterTimeout: 50});

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 149–153why, one step back
149
150 const {signal} = await t.throwsAsync(subprocess);151 t.is(signal, 'SIGKILL');152 });153

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 154why, one step back
154 test('`forceKillAfterTimeout: true` should kill after a timeout', async t => {

Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835

lines 155–156why, one step back
155 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});
156 await pEvent(subprocess, 'message');

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

line 157why, one step back
157

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 158why, one step back
158 subprocess.kill('SIGTERM', {forceKillAfterTimeout: true});

Refactor tests of `kill()` (#284)ehmickybefore adoption7e2c835

lines 159–165why, one step back
159
160 const {signal} = await t.throwsAsync(subprocess);161 t.is(signal, 'SIGKILL');162 });163164 test('kill() with no arguments should kill after a timeout', async t => {165 const subprocess = execa('node', ['fixtures/no-killable'], {stdio: ['ipc']});

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 166–172why, one step back
166 await pEvent(subprocess, 'message');
167168 subprocess.kill();169170 const {signal} = await t.throwsAsync(subprocess);171 t.is(signal, 'SIGKILL');172 });

Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9

line 173why, one step back
173

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 174why, one step back
174 test('`forceKillAfterTimeout` should not be a float', t => {

Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9

line 175why, one step back
175 t.throws(() => {

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 176why, one step back
176 execa('noop').kill('SIGTERM', {forceKillAfterTimeout: 0.5});

Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9

lines 177–179why, one step back
177 }, {instanceOf: TypeError, message: /non-negative integer/});
178 });179

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 180why, one step back
180 test('`forceKillAfterTimeout` should not be negative', t => {

Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9

line 181why, one step back
181 t.throws(() => {

Merge `forceKill` and `forceKillAfter` options (#285)ehmickybefore adoption0336882

line 182why, one step back
182 execa('noop').kill('SIGTERM', {forceKillAfterTimeout: -1});

Refactor `kill()` again (#280)ehmickybefore adoption1b38dc9

lines 183–184why, one step back
183 }, {instanceOf: TypeError, message: /non-negative integer/});
184 });

Add feature to retry process killing after specified duration (#208)zokker13before adoption0bd5596

lines 185–186why, one step back
185}
186

Fix `stripFinalNewline` not applied on `error.stdout|stderr|all` (#240)ehmickybefore adoption943f040

lines 187–192why, one step back
187test('stripFinalNewline: true', async t => {
188 const {stdout} = await execa('noop', ['foo']);189 t.is(stdout, 'foo');190});191192test('stripFinalNewline: false', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 193why, one step back
193 const {stdout} = await execa('noop', ['foo'], {stripFinalNewline: false});

initSindre Sorhusbefore adoptionbc16d6b

line 194
194 t.is(stdout, 'foo\n');

Fix `stripFinalNewline` not applied on `error.stdout|stderr|all` (#240)ehmickybefore adoption943f040

lines 195–207why, one step back
195});
196197test('stripFinalNewline on failure', async t => {198 const {stderr} = await t.throwsAsync(execa('noop-throw', ['foo'], {stripFinalNewline: true}));199 t.is(stderr, 'foo');200});201202test('stripFinalNewline in sync mode', t => {203 const {stdout} = execa.sync('noop', ['foo'], {stripFinalNewline: true});204 t.is(stdout, 'foo');205});206207test('stripFinalNewline in sync mode on failure', t => {

Make `error.killed` more consistent (#248)ehmickybefore adoptionfd064a7

lines 208–210why, one step back
208 const {stderr} = t.throws(() => {
209 execa.sync('noop-throw', ['foo'], {stripFinalNewline: true});210 });

Fix `stripFinalNewline` not applied on `error.stdout|stderr|all` (#240)ehmickybefore adoption943f040

line 211why, one step back
211 t.is(stderr, 'foo');

initSindre Sorhusbefore adoptionbc16d6b

lines 212–213
212});
213

Improve test for `options.preferLocal` (#216)ehmickybefore adoption575d464

lines 214–215why, one step back
214test('preferLocal option', async t => {
215 await execa('ava', ['--version'], {env: {PATH: ''}});

Make error messages more consistent (#230)ehmickybefore adoption5f8bd52

line 216why, one step back
216 const errorRegExp = process.platform === 'win32' ? /failed with exit code 1/ : /spawn ava ENOENT/;

Improve test for `options.preferLocal` (#216)ehmickybefore adoption575d464

line 217why, one step back
217 await t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: {PATH: ''}}), errorRegExp);

add `input` optionJames Talmagebefore adoption605a674

lines 218–219why, one step back
218});
219

Fix test for `options.localDir` (#218)ehmickybefore adoption0070738

lines 220–226why, one step back
220test('localDir option', async t => {
221 const command = process.platform === 'win32' ? 'echo %PATH%' : 'echo $PATH';222 const {stdout} = await execa(command, {shell: true, localDir: '/test'});223 const envPaths = stdout.split(path.delimiter).map(envPath =>224 envPath.replace(/\\/g, '/').replace(/^[^/]+/, '')225 );226 t.true(envPaths.some(envPath => envPath === '/test/node_modules/.bin'));

Add test for #73Sindre Sorhusbefore adoptionc7481f4

lines 227–228why, one step back
227});
228

add `input` optionJames Talmagebefore adoption605a674

line 229why, one step back
229test('input option can be a String', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 230why, one step back
230 const {stdout} = await execa('stdin', {input: 'foobar'});

add `input` optionJames Talmagebefore adoption605a674

lines 231–234why, one step back
231 t.is(stdout, 'foobar');
232});233234test('input option can be a Buffer', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 235why, one step back
235 const {stdout} = await execa('stdin', {input: 'testing12'});

add `input` optionJames Talmagebefore adoption605a674

lines 236–239why, one step back
236 t.is(stdout, 'testing12');
237});238239test('input can be a Stream', async t => {

[BREAKING] ES2015ify and require Node.js 4Sindre Sorhusbefore adoption8a7a51c

line 240why, one step back
240 const s = new stream.PassThrough();

add `input` optionJames Talmagebefore adoption605a674

lines 241–242why, one step back
241 s.write('howdy');
242 s.end();

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 243why, one step back
243 const {stdout} = await execa('stdin', {input: s});

add `input` optionJames Talmagebefore adoption605a674

lines 244–246why, one step back
244 t.is(stdout, 'howdy');
245});246

return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba

line 247why, one step back
247test('you can write to child.stdin', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 248why, one step back
248 const child = execa('stdin');

return the child process instead of a promise. (#18)James Talmagebefore adoption99f10ba

lines 249–252why, one step back
249 child.stdin.end('unicorns');
250 t.is((await child).stdout, 'unicorns');251});252

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

line 253why, one step back
253test('input option can be a String - sync', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 254why, one step back
254 const {stdout} = execa.sync('stdin', {input: 'foobar'});

add `input` optionJames Talmagebefore adoption605a674

lines 255–257why, one step back
255 t.is(stdout, 'foobar');
256});257

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

line 258why, one step back
258test('input option can be a Buffer - sync', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 259why, one step back
259 const {stdout} = execa.sync('stdin', {input: Buffer.from('testing12', 'utf8')});

add `input` optionJames Talmagebefore adoption605a674

line 260why, one step back
260 t.is(stdout, 'testing12');

Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87

lines 261–262why, one step back
261});
262

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

lines 263–268why, one step back
263test('stdin errors are handled', async t => {
264 const child = execa('noop');265 child.stdin.emit('error', new Error('test'));266 await t.throwsAsync(child, /test/);267});268

Improve error messages when an `error` event is emitted (#269)ehmickybefore adoption2307d95

lines 269–271why, one step back
269test('child process errors are handled', async t => {
270 const child = execa('noop');271 child.emit('error', new Error('test'));

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

line 272why, one step back
272 await t.throwsAsync(child, /test/);

Improve error messages when an `error` event is emitted (#269)ehmickybefore adoption2307d95

lines 273–274why, one step back
273});
274

Use spawn instead of execFile (#27)James Talmagebefore adoption31a8d87

line 275why, one step back
275test('opts.stdout:ignore - stdout will not collect data', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 276why, one step back
276 const {stdout} = await execa('stdin', {

fix XO lint issuesSindre Sorhusbefore adoption342096c

line 277why, one step back
277 input: 'hello',

Improve the TS types and don't accept `null` in the `stdio` optionSindre Sorhusbefore adoption4692dcd

line 278why, one step back
278 stdio: [undefined, 'ignore', undefined]

fix XO lint issuesSindre Sorhusbefore adoption342096c

line 279why, one step back
279 });

Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504

line 280why, one step back
280 t.is(stdout, undefined);

add `input` optionJames Talmagebefore adoption605a674

lines 281–284why, one step back
281});
282283test('helpful error trying to provide an input stream in sync mode', t => {284 t.throws(

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

lines 285–287why, one step back
285 () => {
286 execa.sync('stdin', {input: new stream.PassThrough()});287 },

add `input` optionJames Talmagebefore adoption605a674

lines 288–289why, one step back
288 /The `input` option cannot be a stream in sync mode/
289 );

Child process errors should reject the promise right away (#270)ehmickybefore adoption3b8df50

lines 290–295why, one step back
290});
291292test('child process errors rejects promise right away', async t => {293 const child = execa('forever');294 child.emit('error', new Error('test'));295 await t.throwsAsync(child, /test/);

Attach pid and kill() to returned promise (#11)Luke Horvatbefore adoption9da5484

lines 296–298why, one step back
296});
297298test('execa() returns a promise with kill() and pid', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 299–301why, one step back
299 const {kill, pid} = execa('noop', ['foo']);
300 t.is(typeof kill, 'function');301 t.is(typeof pid, 'number');

initSindre Sorhusbefore adoptionbc16d6b

line 302
302});

add max-buffer support (#37)James Talmagebefore adoption6288806

line 303why, one step back
303

Fix shape of exceptions rejected by `execa()` (#276)ehmickybefore adoption49c74ac

lines 304–312why, one step back
304test('child_process.spawn() propagated errors have correct shape', t => {
305 const cp = execa('noop', {uid: -1});306 t.notThrows(() => {307 cp.catch(() => {});308 cp.unref();309 cp.on('error', () => {});310 });311});312

Make errors more consistent (#266)ehmickybefore adoptione5ed8de

line 313why, one step back
313test('child_process.spawn() errors are propagated', async t => {

Fix tests on Mac (#283)ehmickybefore adoption55337f7

lines 314–315why, one step back
314 const {failed} = await t.throwsAsync(execa('noop', {uid: -1}));
315 t.true(failed);

Make errors more consistent (#266)ehmickybefore adoptione5ed8de

lines 316–317why, one step back
316});
317

Fix shape of exceptions thrown by `execa.sync()` (#277)ehmickybefore adoption048b23e

lines 318–320why, one step back
318test('child_process.spawnSync() errors are propagated with a correct shape', t => {
319 const {failed} = t.throws(() => {320 execa.sync('noop', {timeout: -1});

Make errors more consistent (#266)ehmickybefore adoptione5ed8de

line 321why, one step back
321 });

Fix shape of exceptions thrown by `execa.sync()` (#277)ehmickybefore adoption048b23e

line 322why, one step back
322 t.true(failed);

Make errors more consistent (#266)ehmickybefore adoptione5ed8de

lines 323–324why, one step back
323});
324

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

line 325why, one step back
325test('maxBuffer affects stdout', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 326why, one step back
326 await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

lines 327–329why, one step back
327 const {stdout, all} = await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /max-buffer stdout/);
328 t.is(stdout, '.'.repeat(10));329 t.is(all, '.'.repeat(10));

add max-buffer support (#37)James Talmagebefore adoption6288806

lines 330–331why, one step back
330});
331

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

line 332why, one step back
332test('maxBuffer affects stderr', async t => {

Improve error handling of streams (#271)ehmickybefore adoptionbad2140

lines 333–336why, one step back
333 await t.notThrowsAsync(execa('max-buffer', ['stderr', '10'], {maxBuffer: 10}));
334 const {stderr, all} = await t.throwsAsync(execa('max-buffer', ['stderr', '11'], {maxBuffer: 10}), /max-buffer stderr/);335 t.is(stderr, '.'.repeat(10));336 t.is(all, '.'.repeat(10));

add max-buffer support (#37)James Talmagebefore adoption6288806

line 337why, one step back
337});

Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76

line 338why, one step back
338

Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa

line 339why, one step back
339test('do not buffer stdout when `buffer` set to `false`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 340why, one step back
340 const promise = execa('max-buffer', ['stdout', '10'], {buffer: false});

Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa

lines 341–342why, one step back
341 const [result, stdout] = await Promise.all([
342 promise,

Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911

lines 343–344why, one step back
343 getStream(promise.stdout),
344 getStream(promise.all)

Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa

lines 345–351why, one step back
345 ]);
346347 t.is(result.stdout, undefined);348 t.is(stdout, '.........\n');349});350351test('do not buffer stderr when `buffer` set to `false`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 352why, one step back
352 const promise = execa('max-buffer', ['stderr', '10'], {buffer: false});

Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa

lines 353–354why, one step back
353 const [result, stderr] = await Promise.all([
354 promise,

Add `.all` property with interleaved stdout and stderr (#171)Tommaso Sottebefore adoption7f8d911

lines 355–356why, one step back
355 getStream(promise.stderr),
356 getStream(promise.all)

Add `buffer` option to be able to disable buffering (#133)Spencerbefore adoption50384aa

lines 357–360why, one step back
357 ]);
358359 t.is(result.stderr, undefined);360 t.is(stderr, '.........\n');

Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76

lines 361–362why, one step back
361});
362

Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4

line 363why, one step back
363test('allow unknown exit code', async t => {

Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2

lines 364–366why, one step back
364 const {exitCode, exitCodeName} = await t.throwsAsync(execa('exit', ['255']), {message: /exit code 255 \(Unknown system error -255\)/});
365 t.is(exitCode, 255);366 t.is(exitCodeName, 'Unknown system error -255');

Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4

lines 367–368why, one step back
367});
368

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 369why, one step back
369test('execa() does not return code and failed properties on success', async t => {

Remove `error.code` (#250)ehmickybefore adoptionbc0984e

line 370why, one step back
370 const {exitCode, exitCodeName, failed} = await execa('noop', ['foo']);

Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2

lines 371–372why, one step back
371 t.is(exitCode, 0);
372 t.is(exitCodeName, 'SUCCESS');

Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76

line 373why, one step back
373 t.false(failed);

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 374why, one step back
374});

Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2

line 375why, one step back
375

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 376–378why, one step back
376test('execa() returns code and failed properties', async t => {
377 const {exitCode, exitCodeName, failed} = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});378 t.is(exitCode, 2);

Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2

line 379why, one step back
379 const expectedName = process.platform === 'win32' ? 'Unknown system error -2' : 'ENOENT';

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 380–381why, one step back
380 t.is(exitCodeName, expectedName);
381 t.true(failed);

Add `reject` option (#40)Kevin Mårtenssonbefore adoption9bafd76

line 382why, one step back
382});

Add test for `../` paths (#43)James Talmagebefore adoption56a20b1

line 383why, one step back
383

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 384why, one step back
384test('use relative path with \'..\' chars', async t => {

Add test for `../` paths (#43)James Talmagebefore adoption56a20b1

line 385why, one step back
385 const pathViaParentDir = path.join('..', path.basename(__dirname), 'fixtures', 'noop');

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 386why, one step back
386 const {stdout} = await execa(pathViaParentDir, ['foo']);

Add test for `../` paths (#43)James Talmagebefore adoption56a20b1

lines 387–388why, one step back
387 t.is(stdout, 'foo');
388});

add tests (#48)James Talmagebefore adoptionb15483a

line 389why, one step back
389

add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263

line 390why, one step back
390if (process.platform !== 'win32') {

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

line 391why, one step back
391 test('execa() rejects if running non-executable', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 392why, one step back
392 const cp = execa('non-executable');

Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671

line 393why, one step back
393 await t.throwsAsync(cp);

add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263

line 394why, one step back
394 });

Fix non-executable execution with `input` option (#212)Yanis Bensonbefore adoptiona428249

lines 395–398why, one step back
395
396 test('execa() rejects with correct error and doesn\'t throw if running non-executable with input', async t => {397 await t.throwsAsync(execa('non-executable', {input: 'Hey!'}), /EACCES/);398 });

add test case for throwing on non-executables (#49)Markus Wolfbefore adoptione10d263

lines 399–400why, one step back
399}
400

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 401why, one step back
401test('error.killed is true if process was killed directly', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 402why, one step back
402 const cp = execa('forever');

add tests (#48)James Talmagebefore adoptionb15483a

line 403why, one step back
403

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 404why, one step back
404 cp.kill();

add tests (#48)James Talmagebefore adoptionb15483a

line 405why, one step back
405

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 406–407why, one step back
406 const {killed} = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});
407 t.true(killed);

add tests (#48)James Talmagebefore adoptionb15483a

lines 408–409why, one step back
408});
409

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 410why, one step back
410test('error.killed is false if process was killed indirectly', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 411why, one step back
411 const cp = execa('forever');

add tests (#48)James Talmagebefore adoptionb15483a

line 412why, one step back
412

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 413why, one step back
413 process.kill(cp.pid, 'SIGINT');

add tests (#48)James Talmagebefore adoptionb15483a

line 414why, one step back
414

Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4

lines 415–416why, one step back
415 // `process.kill()` is emulated by Node.js on Windows
416 const message = process.platform === 'win32' ? /failed with exit code 1/ : /was killed with SIGINT/;

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 417–418why, one step back
417 const {killed} = await t.throwsAsync(cp, {message});
418 t.false(killed);

add tests (#48)James Talmagebefore adoptionb15483a

lines 419–420why, one step back
419});
420

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

line 421why, one step back
421test('result.killed is false if not killed', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 422–423why, one step back
422 const {killed} = await execa('noop');
423 t.false(killed);

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

lines 424–426why, one step back
424});
425426test('result.killed is false if not killed, in sync mode', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 427–428why, one step back
427 const {killed} = execa.sync('noop');
428 t.false(killed);

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

lines 429–430why, one step back
429});
430

Make `error.killed` more consistent (#248)ehmickybefore adoptionfd064a7

lines 431–442why, one step back
431test('result.killed is false on process error', async t => {
432 const {killed} = await t.throwsAsync(execa('wrong command'));433 t.false(killed);434});435436test('result.killed is false on process error, in sync mode', t => {437 const {killed} = t.throws(() => {438 execa.sync('wrong command');439 });440 t.false(killed);441});442

add tests (#48)James Talmagebefore adoptionb15483a

lines 443–444why, one step back
443if (process.platform === 'darwin') {
444 test.cb('sanity check: child_process.exec also has killed.false if killed indirectly', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 445why, one step back
445 const {pid} = childProcess.exec('forever', error => {

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

lines 446–447why, one step back
446 t.truthy(error);
447 t.false(error.killed);

add tests (#48)James Talmagebefore adoptionb15483a

lines 448–450why, one step back
448 t.end();
449 });450

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 451why, one step back
451 process.kill(pid, 'SIGINT');

add tests (#48)James Talmagebefore adoptionb15483a

lines 452–455why, one step back
452 });
453}454455if (process.platform !== 'win32') {

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 456why, one step back
456 test('error.signal is SIGINT', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 457why, one step back
457 const cp = execa('forever');

add tests (#48)James Talmagebefore adoptionb15483a

line 458why, one step back
458

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 459why, one step back
459 process.kill(cp.pid, 'SIGINT');

add tests (#48)James Talmagebefore adoptionb15483a

line 460why, one step back
460

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 461–462why, one step back
461 const {signal} = await t.throwsAsync(cp, {message: /was killed with SIGINT/});
462 t.is(signal, 'SIGINT');

add tests (#48)James Talmagebefore adoptionb15483a

lines 463–464why, one step back
463 });
464

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 465why, one step back
465 test('error.signal is SIGTERM', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 466why, one step back
466 const cp = execa('forever');

add tests (#48)James Talmagebefore adoptionb15483a

line 467why, one step back
467

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 468why, one step back
468 process.kill(cp.pid, 'SIGTERM');

add tests (#48)James Talmagebefore adoptionb15483a

line 469why, one step back
469

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 470–471why, one step back
470 const {signal} = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});
471 t.is(signal, 'SIGTERM');

add tests (#48)James Talmagebefore adoptionb15483a

line 472why, one step back
472 });

Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c

line 473why, one step back
473

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 474why, one step back
474 test('custom error.signal', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 475–476why, one step back
475 const {signal} = await t.throwsAsync(execa('forever', {killSignal: 'SIGHUP', timeout: 1, message: TIMEOUT_REGEXP}));
476 t.is(signal, 'SIGHUP');

Fix `killSignal` option (#93)Kevin Mårtenssonbefore adoption2cbcc5c

line 477why, one step back
477 });

add tests (#48)James Talmagebefore adoptionb15483a

lines 478–479why, one step back
478}
479

Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504

line 480why, one step back
480test('result.signal is undefined for successful execution', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 481–482why, one step back
481 const {signal} = await execa('noop');
482 t.is(signal, undefined);

add tests (#48)James Talmagebefore adoptionb15483a

lines 483–484why, one step back
483});
484

Replace `null` by `undefined` (#193)ehmickybefore adoptiondca1504

line 485why, one step back
485test('result.signal is undefined if process failed, but was not killed', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 486–487why, one step back
486 const {signal} = await t.throwsAsync(execa('exit', [2]), {message: getExitRegExp('2')});
487 t.is(signal, undefined);

add tests (#48)James Talmagebefore adoptionb15483a

lines 488–489why, one step back
488});
489

Remove `error.code` (#250)ehmickybefore adoptionbc0984e

lines 490–492why, one step back
490async function testExitCode(t, num) {
491 const {exitCode} = await t.throwsAsync(execa('exit', [`${num}`]), {message: getExitRegExp(num)});492 t.is(exitCode, num);

add tests (#48)James Talmagebefore adoptionb15483a

lines 493–494why, one step back
493}
494

Remove `error.code` (#250)ehmickybefore adoptionbc0984e

lines 495–497why, one step back
495test('error.exitCode is 2', testExitCode, 2);
496test('error.exitCode is 3', testExitCode, 3);497test('error.exitCode is 4', testExitCode, 4);

add tests (#48)James Talmagebefore adoptionb15483a

line 498why, one step back
498

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 499why, one step back
499test('timeout kills the process if it times out', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 500–502why, one step back
500 const {killed, timedOut} = await t.throwsAsync(execa('forever', {timeout: 1, message: TIMEOUT_REGEXP}));
501 t.false(killed);502 t.true(timedOut);

Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d

lines 503–504why, one step back
503});
504

Fix `error.timedOut` not working with `execa.sync()` (#249)ehmickybefore adoption21c706a

lines 505–512why, one step back
505test('timeout kills the process if it times out, in sync mode', async t => {
506 const {killed, timedOut} = await t.throws(() => {507 execa.sync('forever', {timeout: 1, message: TIMEOUT_REGEXP});508 });509 t.false(killed);510 t.true(timedOut);511});512

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 513why, one step back
513test('timeout does not kill the process if it does not time out', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 514–515why, one step back
514 const {timedOut} = await execa('delay', ['500'], {timeout: 1e8});
515 t.false(timedOut);

Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d

lines 516–517why, one step back
516});
517

Fix randomly failing CI tests (#231)ehmickybefore adoption4fb924c

line 518why, one step back
518test('timedOut is false if no timeout was set', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 519–520why, one step back
519 const {timedOut} = await execa('noop');
520 t.false(timedOut);

Reimplement missing features. Fixes #30 & #32 (#68)James Talmagebefore adoptione96350d

lines 521–522why, one step back
521});
522

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

line 523why, one step back
523test('timedOut will be false if no timeout was set and zero exit code in sync mode', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 524–525why, one step back
524 const {timedOut} = execa.sync('noop');
525 t.false(timedOut);

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

lines 526–527why, one step back
526});
527

add tests (#48)James Talmagebefore adoptionb15483a

line 528why, one step back
528async function errorMessage(t, expected, ...args) {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 529why, one step back
529 await t.throwsAsync(execa('exit', args), {message: expected});

add tests (#48)James Talmagebefore adoptionb15483a

lines 530–531why, one step back
530}
531

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 532why, one step back
532errorMessage.title = (message, expected) => `error.message matches: ${expected}`;

add tests (#48)James Talmagebefore adoptionb15483a

line 533why, one step back
533

Improve returned `error.message` (#180)ehmickybefore adoption1fd9db4

lines 534–535why, one step back
534test(errorMessage, /Command failed with exit code 2.*: exit 2 foo bar/, 2, 'foo', 'bar');
535test(errorMessage, /Command failed with exit code 3.*: exit 3 baz quz/, 3, 'baz', 'quz');

add tests (#48)James Talmagebefore adoptionb15483a

line 536why, one step back
536

Rename `.cmd` to `.command` (#194)Satya Rohithbefore adoption95c8a14

line 537why, one step back
537async function command(t, expected, ...args) {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 538–539why, one step back
538 const {command: failCommand} = await t.throwsAsync(execa('fail', args));
539 t.is(failCommand, `fail${expected}`);

add tests (#48)James Talmagebefore adoptionb15483a

line 540why, one step back
540

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 541–542why, one step back
541 const {command} = await execa('noop', args);
542 t.is(command, `noop${expected}`);

add tests (#48)James Talmagebefore adoptionb15483a

lines 543–544why, one step back
543}
544

Rename `.cmd` to `.command` (#194)Satya Rohithbefore adoption95c8a14

line 545why, one step back
545command.title = (message, expected) => `command is: ${JSON.stringify(expected)}`;

add tests (#48)James Talmagebefore adoptionb15483a

line 546why, one step back
546

Rename `.cmd` to `.command` (#194)Satya Rohithbefore adoption95c8a14

lines 547–549why, one step back
547test(command, ' foo bar', 'foo', 'bar');
548test(command, ' baz quz', 'baz', 'quz');549test(command, '');

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

line 550why, one step back
550

Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444

lines 551–554why, one step back
551// When child process exits before parent process
552async function spawnAndExit(t, cleanup, detached) {553 await t.notThrowsAsync(execa('sub-process-exit', [cleanup, detached]));554}

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

line 555why, one step back
555

Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444

lines 556–564why, one step back
556test('spawnAndExit', spawnAndExit, false, false);
557test('spawnAndExit cleanup', spawnAndExit, true, false);558test('spawnAndExit detached', spawnAndExit, false, true);559test('spawnAndExit cleanup detached', spawnAndExit, true, true);560561// When parent process exits before child process562async function spawnAndKill(t, signal, cleanup, detached, isKilled) {563 const subprocess = execa('sub-process', [cleanup, detached], {stdio: ['ignore', 'ignore', 'ignore', 'ipc']});564

Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c

lines 565–567why, one step back
565 const pid = await pEvent(subprocess, 'message');
566 t.true(Number.isInteger(pid));567 t.true(isRunning(pid));

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

line 568why, one step back
568

Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c

line 569why, one step back
569 process.kill(subprocess.pid, signal);

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

line 570why, one step back
570

Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c

line 571why, one step back
571 await t.throwsAsync(subprocess);

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

line 572why, one step back
572

Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c

lines 573–574why, one step back
573 t.false(isRunning(subprocess.pid));
574 t.is(isRunning(pid), !isKilled);

Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444

lines 575–578why, one step back
575
576 if (!isKilled) {577 process.kill(pid, 'SIGKILL');578 }

Add `cleanup` option (#53)Friedel Ziegelmayerbefore adoptiondbd9acd

lines 579–580why, one step back
579}
580

Fix test for `options.cleanup` (#224)ehmickybefore adoptionc0d058c

lines 581–587why, one step back
581// Without `options.cleanup`:
582// - on Windows subprocesses are killed if `options.detached: false`, but not583// if `options.detached: true`584// - on Linux subprocesses are never killed regardless of `options.detached`585// With `options.cleanup`, subprocesses are always killed586// - `options.cleanup` with SIGKILL is a noop, since it cannot be handled587const exitIfWindows = process.platform === 'win32';

Improve `cleanup` option (code quality, tests, documentation) (#225)ehmickybefore adoption659f444

lines 588–595why, one step back
588test('spawnAndKill SIGTERM', spawnAndKill, 'SIGTERM', false, false, exitIfWindows);
589test('spawnAndKill SIGKILL', spawnAndKill, 'SIGKILL', false, false, exitIfWindows);590test('spawnAndKill cleanup SIGTERM', spawnAndKill, 'SIGTERM', true, false, true);591test('spawnAndKill cleanup SIGKILL', spawnAndKill, 'SIGKILL', true, false, exitIfWindows);592test('spawnAndKill detached SIGTERM', spawnAndKill, 'SIGTERM', false, true, false);593test('spawnAndKill detached SIGKILL', spawnAndKill, 'SIGKILL', false, true, false);594test('spawnAndKill cleanup detached SIGTERM', spawnAndKill, 'SIGTERM', true, true, false);595test('spawnAndKill cleanup detached SIGKILL', spawnAndKill, 'SIGKILL', true, true, false);

fix support for the `shell` option in `execa.shell()`Sindre Sorhusbefore adoptiona80487b

line 596why, one step back
596

Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2

lines 597–598why, one step back
597if (process.platform !== 'win32') {
598 test('write to fast-exit process', async t => {

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

lines 599–600why, one step back
599 // Try-catch here is necessary, because this test is not 100% accurate
600 // Sometimes process can manage to accept input before exiting

Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2

line 601why, one step back
601 try {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 602why, one step back
602 await execa(`fast-exit-${process.platform}`, [], {input: 'data'});

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

line 603why, one step back
603 t.pass();

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 604why, one step back
604 } catch (error) {

Distinguishing between error strings and error numbers (#187)ehmickybefore adoption7d78db2

line 605why, one step back
605 t.is(error.exitCode, 32);

Attach error listener to stdio stream (#74)Vsevolod Strukchinskybefore adoptiona71bef2

lines 606–608why, one step back
606 }
607 });608}

Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117

line 609why, one step back
609

Fix extending from process.env when no env option is provided - fixes #101 (#102)Sam Verschuerenbefore adoptionafa9700

line 610why, one step back
610test('use environment variables by default', async t => {

Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4

line 611why, one step back
611 const {stdout} = await execa('environment');

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 612why, one step back
612 t.deepEqual(stdout.split('\n'), ['foo', 'undefined']);

Fix extending from process.env when no env option is provided - fixes #101 (#102)Sam Verschuerenbefore adoptionafa9700

lines 613–614why, one step back
613});
614

Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117

line 615why, one step back
615test('extend environment variables by default', async t => {

Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4

line 616why, one step back
616 const {stdout} = await execa('environment', [], {env: {BAR: 'bar'}});

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 617why, one step back
617 t.deepEqual(stdout.split('\n'), ['foo', 'bar']);

Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117

lines 618–619why, one step back
618});
619

Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44

line 620why, one step back
620test('do not extend environment with `extendEnv: false`', async t => {

Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4

line 621why, one step back
621 const {stdout} = await execa('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 622why, one step back
622 t.deepEqual(stdout.split('\n'), ['undefined', 'bar']);

Remove `execa.shell()` and `execa.shellSync()` (#219)ehmickybefore adoption06f21c6

lines 623–630why, one step back
623});
624625test('can use `options.shell: true`', async t => {626 const {stdout} = await execa('node fixtures/noop foo', {shell: true});627 t.is(stdout, 'foo');628});629630test('can use `options.shell: string`', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 631–632why, one step back
631 const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/bash';
632 const {stdout} = await execa('node fixtures/noop foo', {shell});

Remove `execa.shell()` and `execa.shellSync()` (#219)ehmickybefore adoption06f21c6

line 633why, one step back
633 t.is(stdout, 'foo');

Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44

lines 634–638why, one step back
634});
635636test('use extend environment with `extendEnv: true` and `shell: true`', async t => {637 process.env.TEST = 'test';638 const command = process.platform === 'win32' ? 'echo %TEST%' : 'echo $TEST';

Remove `execa.stdout()` and `execa.stderr()` (#234)ehmickybefore adoption3973fd4

line 639why, one step back
639 const {stdout} = await execa(command, {shell: true, env: {}, extendEnv: true});

Fix `extendEnv` option not working with `shell` option (#184)ehmickybefore adoptione897f44

lines 640–641why, one step back
640 t.is(stdout, 'test');
641 delete process.env.TEST;

Extend environment by default - fixes #87 (#88)Sam Verschuerenbefore adoptione370117

line 642why, one step back
642});

Do not buffer when streams are used - fixes #84 (#95)Sam Verschuerenbefore adoption5bab08b

lines 643–644why, one step back
643
644test('do not buffer when streaming', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 645–646why, one step back
645 const {stdout} = execa('max-buffer', ['stdout', '21'], {maxBuffer: 10});
646 const result = await getStream(stdout);

Do not buffer when streams are used - fixes #84 (#95)Sam Verschuerenbefore adoption5bab08b

lines 647–648why, one step back
647 t.is(result, '....................\n');
648});

Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab

lines 649–650why, one step back
649
650test('detach child process', async t => {

Fix `options.detached` test (#215)ehmickybefore adoption88585d2

lines 651–654why, one step back
651 const {stdout} = await execa('detach');
652 const pid = Number(stdout);653 t.true(Number.isInteger(pid));654 t.true(isRunning(pid));

Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab

line 655why, one step back
655

Fix `options.detached` test (#215)ehmickybefore adoption88585d2

line 656why, one step back
656 process.kill(pid, 'SIGKILL');

Detached child process should not kill child - fixes #115 (#117)Sam Verschuerenbefore adoption5f890ab

line 657why, one step back
657});

Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4

lines 658–663why, one step back
658
659// See #128660test('removes exit handler on exit', async t => {661 // FIXME: This relies on `signal-exit` internals662 const ee = process.__signal_exit_emitter__;663

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 664why, one step back
664 const child = execa('noop');

Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4

lines 665–671why, one step back
665 const listener = ee.listeners('exit').pop();
666667 await new Promise((resolve, reject) => {668 child.on('error', reject);669 child.on('exit', resolve);670 });671

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 672why, one step back
672 const included = ee.listeners('exit').includes(listener);

Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4

line 673why, one step back
673 t.false(included);

Fix shape of exceptions rejected by `execa()` (#276)ehmickybefore adoption49c74ac

lines 674–684why, one step back
674});
675676test('promise methods are not enumerable', t => {677 const descriptors = Object.getOwnPropertyDescriptors(execa('noop'));678 // eslint-disable-next-line promise/prefer-await-to-then679 t.false(descriptors.then.enumerable);680 t.false(descriptors.catch.enumerable);681 // TOOD: Remove the `if`-guard when targeting Node.js 10682 if (Promise.prototype.finally) {683 t.false(descriptors.finally.enumerable);684 }

Remove exit handler on exit (#129)Ryan Berdeenbefore adoption0defad4

line 685why, one step back
685});

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

line 686why, one step back
686

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 687why, one step back
687// TOOD: Remove the `if`-guard when targeting Node.js 10

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 688–689why, one step back
688if (Promise.prototype.finally) {
689 test('finally function is executed on success', async t => {

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

line 690why, one step back
690 let isCalled = false;

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 691why, one step back
691 const {stdout} = await execa('noop', ['foo']).finally(() => {

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

line 692why, one step back
692 isCalled = true;

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

line 693why, one step back
693 });

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

line 694why, one step back
694 t.is(isCalled, true);

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 695–698why, one step back
695 t.is(stdout, 'foo');
696 });697698 test('finally function is executed on failure', async t => {

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

line 699why, one step back
699 let isError = false;

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 700why, one step back
700 const {stdout, stderr} = await t.throwsAsync(execa('exit', ['2']).finally(() => {

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

line 701why, one step back
701 isError = true;

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

line 702why, one step back
702 }));

Minor test code style tweaksSindre Sorhusbefore adoptionf6db264

line 703why, one step back
703 t.is(isError, true);

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 704–705why, one step back
704 t.is(typeof stdout, 'string');
705 t.is(typeof stderr, 'string');

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 706–708why, one step back
706 });
707708 test('throw in finally function bubbles up on success', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 709why, one step back
709 const {message} = await t.throwsAsync(execa('noop', ['foo']).finally(() => {

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 710–711why, one step back
710 throw new Error('called');
711 }));

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 712why, one step back
712 t.is(message, 'called');

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 713–715why, one step back
713 });
714715 test('throw in finally bubbles up on error', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 716why, one step back
716 const {message} = await t.throwsAsync(execa('exit', ['2']).finally(() => {

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 717–718why, one step back
717 throw new Error('called');
718 }));

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 719why, one step back
719 t.is(message, 'called');

Make the Promise interface complete by adding a `.finally()` method (#174)Bradford Lemleybefore adoptionf309669

lines 720–721why, one step back
720 });
721}

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

line 722why, one step back
722

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 723–726why, one step back
723test('cancel method kills the subprocess', t => {
724 const subprocess = execa('node');725 subprocess.cancel();726 t.true(subprocess.killed);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 727–728why, one step back
727});
728

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

line 729why, one step back
729test('result.isCanceled is false when spawned.cancel() isn\'t called (success)', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 730–731why, one step back
730 const {isCanceled} = await execa('noop');
731 t.false(isCanceled);

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

lines 732–734why, one step back
732});
733734test('result.isCanceled is false when spawned.cancel() isn\'t called (failure)', async t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 735–736why, one step back
735 const {isCanceled} = await t.throwsAsync(execa('fail'));
736 t.false(isCanceled);

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

lines 737–739why, one step back
737});
738739test('result.isCanceled is false when spawned.cancel() isn\'t called in sync mode (success)', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 740–741why, one step back
740 const {isCanceled} = execa.sync('noop');
741 t.false(isCanceled);

Make `error.killed` and `error.isCanceled` always boolean (not `undefined`) (#229)ehmickybefore adoptionbb36e6d

lines 742–744why, one step back
742});
743744test('result.isCanceled is false when spawned.cancel() isn\'t called in sync mode (failure)', t => {

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 745why, one step back
745 const {isCanceled} = t.throws(() => {

Make `error.killed` more consistent (#248)ehmickybefore adoptionfd064a7

lines 746–747why, one step back
746 execa.sync('fail');
747 });

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 748why, one step back
748 t.false(isCanceled);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 749–751why, one step back
749});
750751test('calling cancel method throws an error with message "Command was canceled"', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 752–754why, one step back
752 const subprocess = execa('noop');
753 subprocess.cancel();754 await t.throwsAsync(subprocess, {message: /Command was canceled/});

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 755–757why, one step back
755});
756757test('error.isCanceled is true when cancel method is used', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 758–759why, one step back
758 const subprocess = execa('noop');
759 subprocess.cancel();

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 760–761why, one step back
760 const {isCanceled} = await t.throwsAsync(subprocess);
761 t.true(isCanceled);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 762–764why, one step back
762});
763764test('error.isCanceled is false when kill method is used', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 765–766why, one step back
765 const subprocess = execa('noop');
766 subprocess.kill();

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 767–768why, one step back
767 const {isCanceled} = await t.throwsAsync(subprocess);
768 t.false(isCanceled);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 769–771why, one step back
769});
770771test('calling cancel method twice should show the same behaviour as calling it once', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 772–774why, one step back
772 const subprocess = execa('noop');
773 subprocess.cancel();774 subprocess.cancel();

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 775–776why, one step back
775 const {isCanceled} = await t.throwsAsync(subprocess);
776 t.true(isCanceled);

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

line 777why, one step back
777 t.true(subprocess.killed);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 778–779why, one step back
778});
779

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 780–781why, one step back
780test('calling cancel method on a successfuly completed process does not make result.isCanceled true', async t => {
781 const subprocess = execa('noop');

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 782why, one step back
782 const {isCanceled} = await subprocess;

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

line 783why, one step back
783 subprocess.cancel();

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

line 784why, one step back
784 t.false(isCanceled);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 785–787why, one step back
785});
786787test('calling cancel method on a process which has been killed does not make error.isCanceled true', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 788–789why, one step back
788 const subprocess = execa('noop');
789 subprocess.kill();

Make tests more consistent (code refactoring) (#247)ehmickybefore adoptionf5172cd

lines 790–791why, one step back
790 const {isCanceled} = await t.throwsAsync(subprocess);
791 t.false(isCanceled);

Add `execa.command()` (#261)ehmickybefore adoption6853316

lines 792–836why, one step back
792});
793794test('allow commands with spaces and no array arguments', async t => {795 const {stdout} = await execa('./fixtures/command with space');796 t.is(stdout, '');797});798799test('allow commands with spaces and array arguments', async t => {800 const {stdout} = await execa('./fixtures/command with space', ['foo', 'bar']);801 t.is(stdout, 'foo\nbar');802});803804test('execa.command()', async t => {805 const {stdout} = await execa.command('node fixtures/echo foo bar');806 t.is(stdout, 'foo\nbar');807});808809test('execa.command() ignores consecutive spaces', async t => {810 const {stdout} = await execa.command('node fixtures/echo foo bar');811 t.is(stdout, 'foo\nbar');812});813814test('execa.command() allows escaping spaces in commands', async t => {815 const {stdout} = await execa.command('./fixtures/command\\ with\\ space foo bar');816 t.is(stdout, 'foo\nbar');817});818819test('execa.command() allows escaping spaces in arguments', async t => {820 const {stdout} = await execa.command('node fixtures/echo foo\\ bar');821 t.is(stdout, 'foo bar');822});823824test('execa.command() escapes other whitespaces', async t => {825 const {stdout} = await execa.command('node fixtures/echo foo\tbar');826 t.is(stdout, 'foo\tbar');827});828829test('execa.command() trims', async t => {830 const {stdout} = await execa.command(' node fixtures/echo foo bar ');831 t.is(stdout, 'foo\nbar');832});833834test('execa.command.sync()', t => {835 const {stdout} = execa.commandSync('node fixtures/echo foo bar');836 t.is(stdout, 'foo\nbar');

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

line 837why, one step back
837});