Skip to content
Myr

test.js

This file

Path

test.js

642 lines · 19.6 KiB · JavaScript

Last changed by

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

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

lines 7–8why, one step back
7import isRunning from 'is-running';
8import delay from 'delay';

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

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

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

Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671

lines 15–16why, one step back
15const NO_NEWLINES_REGEXP = /^[^\n]*$/;
16const STDERR_STDOUT_REGEXP = /stderr[^]*stdout/;

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

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

Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671

line 18why, one step back
18

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

line 20why, one step back
20

initSindre Sorhusbefore adoptionbc16d6b

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

initSindre Sorhusbefore adoptionbc16d6b

lines 23–25
23 t.is(stdout, 'foo');
24});25

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 29–32why, one step back
29 t.is(stdout, 'Hello World');
30 });31}32

initSindre Sorhusbefore adoptionbc16d6b

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

initSindre Sorhusbefore adoptionbc16d6b

lines 35–38
35 t.true(Buffer.isBuffer(stdout));
36 t.is(stdout.toString(), 'foo');37});38

add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505

line 39why, one step back
39test('execa.stdout()', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 40why, one step back
40 const stdout = await execa.stdout('noop', ['foo']);

add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505

lines 41–44why, one step back
41 t.is(stdout, 'foo');
42});4344test('execa.stderr()', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 45why, one step back
45 const stderr = await execa.stderr('noop-err', ['foo']);

add `execa.stdout()` shortcut (#14)Sindre Sorhusbefore adoption868f505

lines 46–48why, one step back
46 t.is(stderr, 'foo');
47});48

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

lines 49–54why, one step back
49test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {
50 const result = await execa('noop-132');51 t.is(result.all, '132');52});5354test('stdout/stderr/all available on errors', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 55why, one step back
55 const err = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});

meta tweaksSindre Sorhusbefore adoption858af26

lines 56–57why, one step back
56 t.is(typeof err.stdout, 'string');
57 t.is(typeof err.stderr, 'string');

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

line 58why, one step back
58 t.is(typeof err.all, 'string');

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

lines 59–60why, one step back
59});
60

add tests (#48)James Talmagebefore adoptionb15483a

line 61why, one step back
61test('include stdout and stderr in errors for improved debugging', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 62why, one step back
62 await t.throwsAsync(execa('fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});

include stdout in errors for improved debuggingSindre Sorhusbefore adoptionaea8c9a

lines 63–64why, one step back
63});
64

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

line 65why, one step back
65test('do not include in errors when `stdio` is set to `inherit`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 66why, one step back
66 await t.throwsAsync(execa('fixtures/error-message.js', {stdio: 'inherit'}), {message: NO_NEWLINES_REGEXP});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 67–69why, one step back
67});
6869test('do not include `stderr` and `stdout` in errors when set to `inherit`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 70why, one step back
70 await t.throwsAsync(execa('fixtures/error-message.js', {stdout: 'inherit', stderr: 'inherit'}), {message: NO_NEWLINES_REGEXP});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 71–73why, one step back
71});
7273test('do not include `stderr` and `stdout` in errors when `stdio` is set to `inherit`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 74why, one step back
74 await t.throwsAsync(execa('fixtures/error-message.js', {stdio: [null, 'inherit', 'inherit']}), {message: NO_NEWLINES_REGEXP});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 75–77why, one step back
75});
7677test('do not include `stdout` in errors when set to `inherit`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 78why, one step back
78 const err = await t.throwsAsync(execa('fixtures/error-message.js', {stdout: 'inherit'}), {message: /stderr/});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 79–82why, one step back
79 t.notRegex(err.message, /stdout/);
80});8182test('do not include `stderr` in errors when set to `inherit`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 83why, one step back
83 const err = await t.throwsAsync(execa('fixtures/error-message.js', {stderr: 'inherit'}), {message: /stdout/});

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

lines 84–88why, one step back
84 t.notRegex(err.message, /stderr/);
85});8687test('pass `stdout` to a file descriptor', async t => {88 const file = tempfile('.txt');

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

Better stdio option handling - fixes #24Sam Verschuerenbefore adoption9cd5e2a

line 96why, one step back
96 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 97–98why, one step back
97});
98

Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c

line 99why, one step back
99test('execa.shell()', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 100why, one step back
100 const {stdout} = await execa.shell('node fixtures/noop foo');

Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c

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

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 106–108why, one step back
106 t.is(stdout, 'foo');
107});108

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 110why, one step back
110 t.throws(() => execa.sync('foo'), process.platform === 'win32' ? /'foo' is not recognized as an internal or external command/ : /spawnSync foo ENOENT/);

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

lines 111–112why, one step back
111});
112

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

line 113why, one step back
113test('execa.sync() includes stdout and stderr in errors for improved debugging', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 114why, one step back
114 t.throws(() => execa.sync('node', ['fixtures/error-message.js']), {message: STDERR_STDOUT_REGEXP, code: 1});

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

lines 115–117why, one step back
115});
116117test('skip throwing when using reject option in execa.sync()', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 118why, one step back
118 const err = execa.sync('node', ['fixtures/error-message.js'], {reject: false});

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

lines 119–122why, one step back
119 t.is(typeof err.stdout, 'string');
120 t.is(typeof err.stderr, 'string');121});122

add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 124why, one step back
124 const {stdout} = execa.shellSync('node fixtures/noop foo');

add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee

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

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

lines 126–128why, one step back
126});
127128test('execa.shellSync() includes stdout and stderr in errors for improved debugging', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 129why, one step back
129 t.throws(() => execa.shellSync('node fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});

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

lines 130–132why, one step back
130});
131132test('skip throwing when using reject option in execa.shellSync()', t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 133why, one step back
133 const err = execa.shellSync('node fixtures/error-message.js', {reject: false});

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

lines 134–135why, one step back
134 t.is(typeof err.stdout, 'string');
135 t.is(typeof err.stderr, 'string');

add `execa.shellSync()`Sindre Sorhusbefore adoption71a58ee

lines 136–137why, one step back
136});
137

Rename `stripEof` option to `stripFinalNewline`Sindre Sorhusbefore adoptionf8397ba

line 138why, one step back
138test('stripEof option (legacy)', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

Rename `stripEof` option to `stripFinalNewline`Sindre Sorhusbefore adoptionf8397ba

lines 140–143why, one step back
140 t.is(stdout, 'foo\n');
141});142143test('stripFinalNewline option', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

initSindre Sorhusbefore adoptionbc16d6b

lines 145–147
145 t.is(stdout, 'foo\n');
146});147

Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c

line 148why, one step back
148test.serial('preferLocal option', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 149why, one step back
149 t.true((await execa('cat-names')).stdout.length > 2);

Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c

line 150why, one step back
150

fix tests on Windows 💩Sindre Sorhusbefore adoption14f16df

lines 151–155why, one step back
151 if (process.platform === 'win32') {
152 // TODO: figure out how to make the below not hang on Windows153 return;154 }155

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

line 156why, one step back
156 // Account for npm adding local binaries to the PATH

Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c

lines 157–158why, one step back
157 const _path = process.env.PATH;
158 process.env.PATH = '';

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 159why, one step back
159 await t.throwsAsync(execa('cat-names', {preferLocal: false}), /spawn .* ENOENT/);

Merge pull request #3 from sindresorhus/local-binsSindre Sorhusbefore adoptiona0c035c

line 160why, one step back
160 process.env.PATH = _path;

add `input` optionJames Talmagebefore adoption605a674

lines 161–162why, one step back
161});
162

Fix test flakiness on WindowsSindre Sorhusbefore adoptionf071546

line 163why, one step back
163test.serial('localDir option', async t => {

Add test for #73Sindre Sorhusbefore adoptionc7481f4

lines 164–166why, one step back
164 const cwd = 'fixtures/local-dir';
165 const bin = path.resolve(cwd, 'node_modules/.bin/self-path');166

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 167why, one step back
167 await execa('npm', ['install', '--no-package-lock'], {cwd});

Add test for #73Sindre Sorhusbefore adoptionc7481f4

line 168why, one step back
168

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 169why, one step back
169 const {stdout} = await execa(bin, {localDir: cwd});

Add test for #73Sindre Sorhusbefore adoptionc7481f4

line 170why, one step back
170

Meta tweaksSindre Sorhusbefore adoptionc0fc20c

line 171why, one step back
171 t.is(path.relative(cwd, stdout), path.normalize('node_modules/self-path'));

Add test for #73Sindre Sorhusbefore adoptionc7481f4

lines 172–173why, one step back
172});
173

add `input` optionJames Talmagebefore adoption605a674

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add `input` optionJames Talmagebefore adoption605a674

lines 176–179why, one step back
176 t.is(stdout, 'foobar');
177});178179test('input option can be a Buffer', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add `input` optionJames Talmagebefore adoption605a674

lines 181–184why, one step back
181 t.is(stdout, 'testing12');
182});183184test('input can be a Stream', async t => {

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

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

add `input` optionJames Talmagebefore adoption605a674

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add `input` optionJames Talmagebefore adoption605a674

lines 189–191why, one step back
189 t.is(stdout, 'howdy');
190});191

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 194–197why, one step back
194 child.stdin.end('unicorns');
195 t.is((await child).stdout, 'unicorns');196});197

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add `input` optionJames Talmagebefore adoption605a674

lines 200–202why, one step back
200 t.is(stdout, 'foobar');
201});202

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add `input` optionJames Talmagebefore adoption605a674

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

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

lines 206–208why, one step back
206});
207208test('opts.stdout:ignore - stdout will not collect data', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

fix XO lint issuesSindre Sorhusbefore adoption342096c

lines 210–212why, one step back
210 input: 'hello',
211 stdio: [null, 'ignore', null]212 });

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

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

add `input` optionJames Talmagebefore adoption605a674

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 218why, one step back
218 () => execa.sync('stdin', {input: new stream.PassThrough()}),

add `input` optionJames Talmagebefore adoption605a674

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

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 224why, one step back
224 const promise = execa('noop', ['foo']);

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

lines 225–226why, one step back
225 t.is(typeof promise.kill, 'function');
226 t.is(typeof promise.pid, 'number');

initSindre Sorhusbefore adoptionbc16d6b

line 227
227});

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

line 228why, one step back
228

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

lines 230–231why, one step back
230 await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);
231 await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));

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

lines 232–233why, one step back
232});
233

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

lines 235–236why, one step back
235 await t.throwsAsync(execa('max-buffer', ['stderr', '13'], {maxBuffer: 12}), /stderr maxBuffer exceeded/);
236 await t.notThrowsAsync(execa('max-buffer', ['stderr', '12'], {maxBuffer: 12}));

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

line 237why, one step back
237});

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

line 238why, one step back
238

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

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

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

lines 243–244why, one step back
243 getStream(promise.stdout),
244 getStream(promise.all)

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

lines 245–251why, one step back
245 ]);
246247 t.is(result.stdout, undefined);248 t.is(stdout, '.........\n');249});250251test('do not buffer stderr when `buffer` set to `false`', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

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

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

lines 255–256why, one step back
255 getStream(promise.stderr),
256 getStream(promise.all)

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

lines 257–262why, one step back
257 ]);
258259 t.is(result.stderr, undefined);260 t.is(stderr, '.........\n');261});262

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 264why, one step back
264 const error = await execa('exit', ['2'], {reject: false});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

lines 265–266why, one step back
265 t.is(typeof error.stdout, 'string');
266 t.is(typeof error.stderr, 'string');

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

lines 267–268why, one step back
267});
268

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

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

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

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

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

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

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

line 275why, one step back
275test('execa() returns code and failed properties', async t => {

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

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

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

line 277why, one step back
277 t.is(code, 0);

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

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

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

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

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

lines 281–285why, one step back
281
282 const error = await t.throwsAsync(execa('exit', ['2']), {code: 2, message: getExitRegExp('2')});283 t.is(error.exitCode, 2);284 const expectedName = process.platform === 'win32' ? 'Unknown system error -2' : 'ENOENT';285 t.is(error.exitCodeName, expectedName);

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

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

line 287why, one step back
287});

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

line 288why, one step back
288

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

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

add tests (#48)James Talmagebefore adoptionb15483a

line 294why, one step back
294

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

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

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671

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

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

lines 299–301why, one step back
299 });
300}301

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add tests (#48)James Talmagebefore adoptionb15483a

line 304why, one step back
304

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

line 305why, one step back
305 setTimeout(() => {

add tests (#48)James Talmagebefore adoptionb15483a

lines 306–308why, one step back
306 cp.kill();
307 }, 100);308

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

line 309why, one step back
309 const error = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 310why, one step back
310 t.true(error.killed);

add tests (#48)James Talmagebefore adoptionb15483a

lines 311–313why, one step back
311});
312313// TODO: Should this really be the case, or should we improve on child_process?

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add tests (#48)James Talmagebefore adoptionb15483a

line 316why, one step back
316

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

line 317why, one step back
317 setTimeout(() => {

add tests (#48)James Talmagebefore adoptionb15483a

lines 318–320why, one step back
318 process.kill(cp.pid, 'SIGINT');
319 }, 100);320

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

lines 321–323why, one step back
321 // `process.kill()` is emulated by Node.js on Windows
322 const message = process.platform === 'win32' ? /failed with exit code 1/ : /was killed with SIGINT/;323 const error = await t.throwsAsync(cp, {message});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 324why, one step back
324 t.false(error.killed);

add tests (#48)James Talmagebefore adoptionb15483a

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

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

lines 329–331why, one step back
329 const cp = childProcess.exec('forever', error => {
330 t.truthy(error);331 t.false(error.killed);

add tests (#48)James Talmagebefore adoptionb15483a

lines 332–334why, one step back
332 t.end();
333 });334

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

line 335why, one step back
335 setTimeout(() => {

add tests (#48)James Talmagebefore adoptionb15483a

lines 336–341why, one step back
336 process.kill(cp.pid, 'SIGINT');
337 }, 100);338 });339}340341if (process.platform !== 'win32') {

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add tests (#48)James Talmagebefore adoptionb15483a

line 344why, one step back
344

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

line 345why, one step back
345 setTimeout(() => {

add tests (#48)James Talmagebefore adoptionb15483a

lines 346–348why, one step back
346 process.kill(cp.pid, 'SIGINT');
347 }, 100);348

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

line 349why, one step back
349 const error = await t.throwsAsync(cp, {message: /was killed with SIGINT/});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 350why, one step back
350 t.is(error.signal, 'SIGINT');

add tests (#48)James Talmagebefore adoptionb15483a

lines 351–352why, one step back
351 });
352

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add tests (#48)James Talmagebefore adoptionb15483a

line 355why, one step back
355

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

line 356why, one step back
356 setTimeout(() => {

add tests (#48)James Talmagebefore adoptionb15483a

lines 357–359why, one step back
357 process.kill(cp.pid, 'SIGTERM');
358 }, 100);359

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

line 360why, one step back
360 const error = await t.throwsAsync(cp, {message: /was killed with SIGTERM/});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 361why, one step back
361 t.is(error.signal, 'SIGTERM');

add tests (#48)James Talmagebefore adoptionb15483a

line 362why, one step back
362 });

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

line 363why, one step back
363

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 365why, one step back
365 const error = await t.throwsAsync(execa('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500, message: TIMEOUT_REGEXP}));

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 366why, one step back
366 t.is(error.signal, 'SIGHUP');

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

line 367why, one step back
367 });

add tests (#48)James Talmagebefore adoptionb15483a

lines 368–369why, one step back
368}
369

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

lines 370–371why, one step back
370test('result.signal is undefined for successful execution', async t => {
371 t.is((await execa('noop')).signal, undefined);

add tests (#48)James Talmagebefore adoptionb15483a

lines 372–373why, one step back
372});
373

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 375why, one step back
375 const error = await t.throwsAsync(execa('exit', [2]), {message: getExitRegExp('2')});

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

line 376why, one step back
376 t.is(error.signal, undefined);

add tests (#48)James Talmagebefore adoptionb15483a

lines 377–379why, one step back
377});
378379async function code(t, num) {

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

lines 380–381why, one step back
380 const error = await t.throwsAsync(execa('exit', [`${num}`]), {code: num, message: getExitRegExp(num)});
381 t.is(error.exitCode, num);

add tests (#48)James Talmagebefore adoptionb15483a

lines 382–383why, one step back
382}
383

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

lines 384–386why, one step back
384test('error.code is 2', code, 2);
385test('error.code is 3', code, 3);386test('error.code is 4', code, 4);

add tests (#48)James Talmagebefore adoptionb15483a

line 387why, one step back
387

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

line 388why, one step back
388test('timeout will kill the process early', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 389why, one step back
389 const error = await t.throwsAsync(execa('delay', ['60000', '0'], {timeout: 1500, message: TIMEOUT_REGEXP}));

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

line 390why, one step back
390

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 391why, one step back
391 t.true(error.timedOut);

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

line 392why, one step back
392 t.not(error.exitCode, 22);

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

lines 393–395why, one step back
393});
394395test('timeout will not kill the process early', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 396why, one step back
396 const error = await t.throwsAsync(execa('delay', ['3000', '22'], {timeout: 30000}), {code: 22, message: getExitRegExp('22')});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 397why, one step back
397 t.false(error.timedOut);

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

lines 398–400why, one step back
398});
399400test('timedOut will be false if no timeout was set and zero exit code', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 401why, one step back
401 const result = await execa('delay', ['1000', '0']);

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

lines 402–405why, one step back
402 t.false(result.timedOut);
403});404405test('timedOut will be false if no timeout was set and non-zero exit code', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 406why, one step back
406 const error = await t.throwsAsync(execa('delay', ['1000', '3']), {message: getExitRegExp('3')});

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 407why, one step back
407 t.false(error.timedOut);

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

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

add tests (#48)James Talmagebefore adoptionb15483a

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

add tests (#48)James Talmagebefore adoptionb15483a

lines 412–413why, one step back
412}
413

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

add tests (#48)James Talmagebefore adoptionb15483a

line 415why, one step back
415

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

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

add tests (#48)James Talmagebefore adoptionb15483a

lines 418–419why, one step back
418
419async function cmd(t, expected, ...args) {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 420why, one step back
420 const error = await t.throwsAsync(execa('fail', args));

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

line 421why, one step back
421 t.is(error.cmd, `fail${expected}`);

add tests (#48)James Talmagebefore adoptionb15483a

line 422why, one step back
422

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 423why, one step back
423 const result = await execa('noop', args);

add tests (#48)James Talmagebefore adoptionb15483a

lines 424–431why, one step back
424 t.is(result.cmd, `noop${expected}`);
425}426427cmd.title = (message, expected) => `cmd is: ${JSON.stringify(expected)}`;428429test(cmd, ' foo bar', 'foo', 'bar');430test(cmd, ' baz quz', 'baz', 'quz');431test(cmd, '');

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

lines 432–434why, one step back
432
433async function spawnAndKill(t, signal, cleanup) {434 const name = cleanup ? 'sub-process' : 'sub-process-false';

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 435why, one step back
435 const cp = execa(name);

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

lines 436–447why, one step back
436 let pid;
437438 cp.stdout.setEncoding('utf8');439 cp.stdout.on('data', chunk => {440 pid = parseInt(chunk, 10);441 t.is(typeof pid, 'number');442443 setTimeout(() => {444 process.kill(cp.pid, signal);445 }, 100);446 });447

Upgrade ava to 1.2.1 (#178)ehmickybefore adoption0f48671

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

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

lines 449–464why, one step back
449
450 // Give everybody some time to breath and kill things451 await delay(200);452453 t.false(isRunning(cp.pid));454 t.is(isRunning(pid), !cleanup);455}456457test('cleanup - SIGINT', spawnAndKill, 'SIGINT', true);458test('cleanup - SIGKILL', spawnAndKill, 'SIGTERM', true);459460if (process.platform !== 'win32') {461 // On Windows the subprocesses are actually always killed462 test('cleanup false - SIGINT', spawnAndKill, 'SIGTERM', false);463 test('cleanup false - SIGKILL', spawnAndKill, 'SIGKILL', false);464}

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

line 465why, one step back
465

Fix Windows test related to `shell` option (#185)ehmickybefore adoptioneac23b0

line 466why, one step back
466test('execa.shell() supports the `shell` option', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 467why, one step back
467 const {stdout} = await execa.shell('node fixtures/noop foo', {

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

lines 468–471why, one step back
468 shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash'
469 });470 t.is(stdout, 'foo');471});

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

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

Fix linting (#77)Sam Verschuerenbefore adoption80a059d

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

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

line 477why, one step back
477 try {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

Fix tests (#89)Sam Verschuerenbefore adoption1861b5e

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

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

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

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

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

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

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

line 485why, one step back
485

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 487why, one step back
487 const result = await execa.stdout('environment');

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

lines 488–494why, one step back
488
489 t.deepEqual(result.split('\n'), [490 'foo',491 'undefined'492 ]);493});494

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 497–503why, one step back
497
498 t.deepEqual(result.split('\n'), [499 'foo',500 'bar'501 ]);502});503

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 506–510why, one step back
506
507 t.deepEqual(result.split('\n'), [508 'undefined',509 'bar'510 ]);

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

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

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

line 519why, one step back
519});

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

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

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 522why, one step back
522 const result = await getStream(execa('max-buffer', ['stdout', '21'], {maxBuffer: 10}).stdout);

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

lines 523–525why, one step back
523
524 t.is(result, '....................\n');525});

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

lines 526–529why, one step back
526
527test('detach child process', async t => {528 const file = tempfile('.txt');529

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 530why, one step back
530 await execa('detach', [file]);

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

line 531why, one step back
531

Increase delay of detached child process (#120)Sam Verschuerenbefore adoption8fb8b6d

line 532why, one step back
532 await delay(5000);

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

lines 533–535why, one step back
533
534 t.is(fs.readFileSync(file, 'utf8'), 'foo\n');535});

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

lines 536–541why, one step back
536
537// See #128538test('removes exit handler on exit', async t => {539 // FIXME: This relies on `signal-exit` internals540 const ee = process.__signal_exit_emitter__;541

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 543–549why, one step back
543 const listener = ee.listeners('exit').pop();
544545 await new Promise((resolve, reject) => {546 child.on('error', reject);547 child.on('exit', resolve);548 });549

Fix lint issuesSindre Sorhusbefore adoptionb7752fb

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

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

lines 551–552why, one step back
551 t.false(included);
552});

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

line 553why, one step back
553

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

line 554why, one step back
554// 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 555–557why, one step back
555if (Promise.prototype.finally) {
556 test('finally function is executed on success', async t => {557 let called = false;

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 559–566why, one step back
559 called = true;
560 });561 t.is(called, true);562 t.is(stdout, 'foo');563 });564565 test('finally function is executed on failure', async t => {566 let called = false;

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 568–575why, one step back
568 called = true;
569 }));570 t.is(called, true);571 t.is(typeof err.stdout, 'string');572 t.is(typeof err.stderr, 'string');573 });574575 test('throw in finally function bubbles up on success', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 577–582why, one step back
577 throw new Error('called');
578 }));579 t.is(result.message, 'called');580 });581582 test('throw in finally bubbles up on error', async t => {

Require Node.js 8Sindre Sorhusbefore adoptiondce2267

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

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

lines 584–588why, one step back
584 throw new Error('called');
585 }));586 t.is(result.message, 'called');587 });588}

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

line 589why, one step back
589

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 590–593why, one step back
590test('cancel method kills the subprocess', t => {
591 const subprocess = execa('node');592 subprocess.cancel();593 t.true(subprocess.killed);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 594–601why, one step back
594});
595596test('result.isCanceled is false when spawned.cancel isn\'t called', async t => {597 const result = await execa('noop');598 t.false(result.isCanceled);599});600601test('calling cancel method throws an error with message "Command was canceled"', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

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

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

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

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 608–610why, one step back
608 const subprocess = execa('noop');
609 subprocess.cancel();610 const error = await t.throwsAsync(subprocess);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 611–614why, one step back
611 t.true(error.isCanceled);
612});613614test('error.isCanceled is false when kill method is used', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 615–617why, one step back
615 const subprocess = execa('noop');
616 subprocess.kill();617 const error = await t.throwsAsync(subprocess);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 618–621why, one step back
618 t.false(error.isCanceled);
619});620621test('calling cancel method twice should show the same behaviour as calling it once', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 622–625why, one step back
622 const subprocess = execa('noop');
623 subprocess.cancel();624 subprocess.cancel();625 const error = await t.throwsAsync(subprocess);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

line 626why, one step back
626 t.true(error.isCanceled);

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

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

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 628–629why, one step back
628});
629

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

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

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 634–637why, one step back
634 t.false(result.isCanceled);
635});636637test('calling cancel method on a process which has been killed does not make error.isCanceled true', async t => {

Clean up #189Sindre Sorhusbefore adoptionf24e7c7

lines 638–640why, one step back
638 const subprocess = execa('noop');
639 subprocess.kill();640 const error = await t.throwsAsync(subprocess);

Make the spawned process cancelable (#189)Ammarbefore adoption79356cc

lines 641–642why, one step back
641 t.false(error.isCanceled);
642});