Require Node.js 8
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by Sindre Sorhus · parent e897f44 · Browse files · 6 files·+123 added−112 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+123 added−112 removed
- tests:+2 added−2 removed
- other:+121 added−110 removed
Provenance
- Commit
dce2267- Tree
84bbde2- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
e897f44
6 files changed+123 added−112 removed
modified:lib/errname.js+1 added-1 removed
7 unmodified lines89101112121314151623 unmodified lines7 unmodified linesif (typeof util.getSystemErrorName === 'function') { module.exports = util.getSystemErrorName;} else { try { uv = process.binding('uv'); uv = process.binding('uv'); // eslint-disable-line node/no-deprecated-api
if (typeof uv.errname !== 'function') { throw new TypeError('uv.errname is not a function'); }23 unmodified linesmodified:test/errname.js+2 added-2 removed
12344567812 unmodified lines21222324252526import test from 'ava';import errname from '../lib/errname';
const isWin = process.platform === 'win32';const isWindows = process.platform === 'win32';
// Simulates failure to capture `process.binding('uv');`const fallback = code => errname.__test__(null, code);
12 unmodified lines}
const unknown = 'Unknown system error -2';
makeTests('native', errname, isWin ? unknown : 'ENOENT');makeTests('native', errname, isWindows ? unknown : 'ENOENT');makeTests('fallback', fallback, unknown);modified:.travis.yml-1 removed
3 unmodified lines45678893 unmodified lineslanguage: node_jsnode_js: - '10' - '8' - '6'after_success: - './node_modules/.bin/nyc report --reporter=text-lcov | ./node_modules/.bin/coveralls'modified:index.js+32 added-17 removed
18 unmodified lines19 command = parsed.command;20 args = parsed.args;21 options = parsed.options;22 23- options = Object.assign({23+ options = {24 maxBuffer: TEN_MEGABYTES,25 buffer: true,26 stripFinalNewline: true,27 preferLocal: true,28 localDir: options.cwd || process.cwd(),29 encoding: 'utf8',30 reject: true,31- cleanup: true32- }, options, {31+ cleanup: true,32+ ...options,33 windowsHide: true34- });34+ };35 36 if (options.extendEnv !== false) {37- options.env = Object.assign({}, process.env, options.env);37+ options.env = {38+ ...process.env,39+ ...options.env40+ };41 }42 43 if (options.preferLocal) {41- options.env = npmRunPath.env(Object.assign({}, options, {cwd: options.localDir}));44+ options.env = npmRunPath.env({45+ ...options,46+ cwd: options.localDir47+ });48 }49 50 // TODO: Remove in the next major release51 if (options.stripEof === false) {35 unmodified lines87 return value;88 }89 90 function handleShell(fn, command, options) {85- return fn(command, Object.assign({}, options, {shell: true}));91+ return fn(command, {...options, shell: true});92 }93 94 function getStream(process, stream, {encoding, buffer, maxBuffer}) {95 if (!process[stream]) {166 unmodified lines262 spawned.stderr.destroy();263 }264 }265 266+ // TODO: Use native "finally" syntax when targeting Node.js 10267 const handlePromise = () => pFinally(Promise.all([268 processDone,269 getStream(spawned, 'stdout', {encoding, buffer, maxBuffer}),270 getStream(spawned, 'stderr', {encoding, buffer, maxBuffer})264- ]).then(arr => {265- const result = arr[0];266- result.stdout = arr[1];267- result.stderr = arr[2];271+ ]).then(results => { // eslint-disable-line promise/prefer-await-to-then272+ const result = results[0];273+ result.stdout = results[1];274+ result.stderr = results[2];275 276 if (result.error || result.code !== 0 || result.signal !== null) {277 const error = makeError(result, {278 joinedCommand,28 unmodified lines307 crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);308 309 handleInput(spawned, parsed.options.input);310 304- spawned.then = (onfulfilled, onrejected) => handlePromise().then(onfulfilled, onrejected);305- spawned.catch = onrejected => handlePromise().catch(onrejected);306- // eslint-disable-next-line no-use-extend-native/no-use-extend-native311+ // eslint-disable-next-line promise/prefer-await-to-then312+ spawned.then = (onFulfilled, onRejected) => handlePromise().then(onFulfilled, onRejected);313+ spawned.catch = onRejected => handlePromise().catch(onRejected);314+315+ // TOOD: Remove the `if`-guard when targeting Node.js 10316 if (Promise.prototype.finally) {308- spawned.finally = onfinally => handlePromise().finally(onfinally);317+ spawned.finally = onFinally => handlePromise().finally(onFinally);318 }319 320 return spawned;321 };322 323 // TODO: set `stderr: 'ignore'` when that option is implemented315-module.exports.stdout = (...args) => module.exports(...args).then(x => x.stdout);324+module.exports.stdout = async (...args) => {325+ const {stdout} = await module.exports(...args);326+ return stdout;327+};328 329 // TODO: set `stdout: 'ignore'` when that option is implemented318-module.exports.stderr = (...args) => module.exports(...args).then(x => x.stderr);330+module.exports.stderr = async (...args) => {331+ const {stderr} = await module.exports(...args);332+ return stderr;333+};334 335 module.exports.shell = (command, options) => handleShell(module.exports, command, options);336 337 module.exports.sync = (command, args, options) => {35 unmodified linesmodified:package.json+7 added-7 removed
8 unmodified lines910111213131415161727 unmodified lines454647484950515249505152535454555656575859605 unmodified lines8 unmodified lines "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=6" "node": ">=8" }, "scripts": { "test": "xo && nyc ava" },27 unmodified lines "signal-exit": "^3.0.0", "strip-final-newline": "^2.0.0" }, "devDependencies": { "ava": "^1.2.1", "cat-names": "^1.0.2", "coveralls": "^3.0.1", "delay": "^3.0.0", "ava": "^1.3.1", "cat-names": "^2.0.0", "coveralls": "^3.0.3", "delay": "^4.1.0", "is-running": "^2.0.0", "nyc": "^13.0.1", "nyc": "^13.3.0", "tempfile": "^2.0.0", "xo": "^0.23.0" "xo": "^0.24.0" }, "nyc": { "exclude": [ "**/fixtures/**",5 unmodified linesmodified:test.js+81 added-84 removed
5 unmodified lines6 import getStream from 'get-stream';7 import isRunning from 'is-running';8 import delay from 'delay';9 import tempfile from 'tempfile';10-import m from '.';10+import execa from '.';11 12 process.env.PATH = path.join(__dirname, 'fixtures') + path.delimiter + process.env.PATH;13 process.env.FOO = 'foo';14 15 const NO_NEWLINES_REGEXP = /^[^\n]*$/;16 const STDERR_STDOUT_REGEXP = /stderr[^]*stdout/;17 const TIMEOUT_REGEXP = /timed out after/;18 19-function getExitRegExp(exitMessage) {20- return new RegExp(`failed with exit code ${exitMessage}`);19+const getExitRegExp = exitMessage => new RegExp(`failed with exit code ${exitMessage}`);21-}20 21 test('execa()', async t => {24- const {stdout} = await m('noop', ['foo']);22+ const {stdout} = await execa('noop', ['foo']);23 t.is(stdout, 'foo');24 });25 26 if (process.platform === 'win32') {27 test('execa() - cmd file', async t => {30- const {stdout} = await m('hello.cmd');31-28+ const {stdout} = await execa('hello.cmd');29 t.is(stdout, 'Hello World');30 });31 }32 33 test('buffer', async t => {37- const {stdout} = await m('noop', ['foo'], {encoding: null});34+ const {stdout} = await execa('noop', ['foo'], {encoding: null});35 t.true(Buffer.isBuffer(stdout));36 t.is(stdout.toString(), 'foo');37 });38 39 test('execa.stdout()', async t => {43- const stdout = await m.stdout('noop', ['foo']);40+ const stdout = await execa.stdout('noop', ['foo']);41 t.is(stdout, 'foo');42 });43 44 test('execa.stderr()', async t => {48- const stderr = await m.stderr('noop-err', ['foo']);45+ const stderr = await execa.stderr('noop-err', ['foo']);46 t.is(stderr, 'foo');47 });48 49 test('stdout/stderr available on errors', async t => {53- const err = await t.throwsAsync(m('exit', ['2']), {message: getExitRegExp('2')});50+ const err = await t.throwsAsync(execa('exit', ['2']), {message: getExitRegExp('2')});51 t.is(typeof err.stdout, 'string');52 t.is(typeof err.stderr, 'string');53 });54 55 test('include stdout and stderr in errors for improved debugging', async t => {59- await t.throwsAsync(m('fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});56+ await t.throwsAsync(execa('fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});57 });58 59 test('do not include in errors when `stdio` is set to `inherit`', async t => {63- await t.throwsAsync(m('fixtures/error-message.js', {stdio: 'inherit'}), {message: NO_NEWLINES_REGEXP});60+ await t.throwsAsync(execa('fixtures/error-message.js', {stdio: 'inherit'}), {message: NO_NEWLINES_REGEXP});61 });62 63 test('do not include `stderr` and `stdout` in errors when set to `inherit`', async t => {67- await t.throwsAsync(m('fixtures/error-message.js', {stdout: 'inherit', stderr: 'inherit'}), {message: NO_NEWLINES_REGEXP});64+ await t.throwsAsync(execa('fixtures/error-message.js', {stdout: 'inherit', stderr: 'inherit'}), {message: NO_NEWLINES_REGEXP});65 });66 67 test('do not include `stderr` and `stdout` in errors when `stdio` is set to `inherit`', async t => {71- await t.throwsAsync(m('fixtures/error-message.js', {stdio: [null, 'inherit', 'inherit']}), {message: NO_NEWLINES_REGEXP});68+ await t.throwsAsync(execa('fixtures/error-message.js', {stdio: [null, 'inherit', 'inherit']}), {message: NO_NEWLINES_REGEXP});69 });70 71 test('do not include `stdout` in errors when set to `inherit`', async t => {75- const err = await t.throwsAsync(m('fixtures/error-message.js', {stdout: 'inherit'}), {message: /stderr/});72+ const err = await t.throwsAsync(execa('fixtures/error-message.js', {stdout: 'inherit'}), {message: /stderr/});73 t.notRegex(err.message, /stdout/);74 });75 76 test('do not include `stderr` in errors when set to `inherit`', async t => {80- const err = await t.throwsAsync(m('fixtures/error-message.js', {stderr: 'inherit'}), {message: /stdout/});77+ const err = await t.throwsAsync(execa('fixtures/error-message.js', {stderr: 'inherit'}), {message: /stdout/});78 t.notRegex(err.message, /stderr/);79 });80 81 test('pass `stdout` to a file descriptor', async t => {82 const file = tempfile('.txt');86- await m('fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});83+ await execa('fixtures/noop', ['foo bar'], {stdout: fs.openSync(file, 'w')});84 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');85 });86 87 test('pass `stderr` to a file descriptor', async t => {88 const file = tempfile('.txt');92- await m('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});89+ await execa('fixtures/noop-err', ['foo bar'], {stderr: fs.openSync(file, 'w')});90 t.is(fs.readFileSync(file, 'utf8'), 'foo bar\n');91 });92 93 test('execa.shell()', async t => {97- const {stdout} = await m.shell('node fixtures/noop foo');94+ const {stdout} = await execa.shell('node fixtures/noop foo');95 t.is(stdout, 'foo');96 });97 98 test('execa.sync()', t => {102- const {stdout} = m.sync('noop', ['foo']);99+ const {stdout} = execa.sync('noop', ['foo']);100 t.is(stdout, 'foo');101 });102 103 test('execa.sync() throws error if written to stderr', t => {107- t.throws(() => m.sync('foo'), process.platform === 'win32' ? /'foo' is not recognized as an internal or external command/ : /spawnSync foo ENOENT/);104+ t.throws(() => execa.sync('foo'), process.platform === 'win32' ? /'foo' is not recognized as an internal or external command/ : /spawnSync foo ENOENT/);105 });106 107 test('execa.sync() includes stdout and stderr in errors for improved debugging', t => {111- t.throws(() => m.sync('node', ['fixtures/error-message.js']), {message: STDERR_STDOUT_REGEXP, code: 1});108+ t.throws(() => execa.sync('node', ['fixtures/error-message.js']), {message: STDERR_STDOUT_REGEXP, code: 1});109 });110 111 test('skip throwing when using reject option in execa.sync()', t => {115- const err = m.sync('node', ['fixtures/error-message.js'], {reject: false});112+ const err = execa.sync('node', ['fixtures/error-message.js'], {reject: false});113 t.is(typeof err.stdout, 'string');114 t.is(typeof err.stderr, 'string');115 });116 117 test('execa.shellSync()', t => {121- const {stdout} = m.shellSync('node fixtures/noop foo');118+ const {stdout} = execa.shellSync('node fixtures/noop foo');119 t.is(stdout, 'foo');120 });121 122 test('execa.shellSync() includes stdout and stderr in errors for improved debugging', t => {126- t.throws(() => m.shellSync('node fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});123+ t.throws(() => execa.shellSync('node fixtures/error-message.js'), {message: STDERR_STDOUT_REGEXP, code: 1});124 });125 126 test('skip throwing when using reject option in execa.shellSync()', t => {130- const err = m.shellSync('node fixtures/error-message.js', {reject: false});127+ const err = execa.shellSync('node fixtures/error-message.js', {reject: false});128 t.is(typeof err.stdout, 'string');129 t.is(typeof err.stderr, 'string');130 });131 132 test('stripEof option (legacy)', async t => {136- const {stdout} = await m('noop', ['foo'], {stripEof: false});133+ const {stdout} = await execa('noop', ['foo'], {stripEof: false});134 t.is(stdout, 'foo\n');135 });136 137 test('stripFinalNewline option', async t => {141- const {stdout} = await m('noop', ['foo'], {stripFinalNewline: false});138+ const {stdout} = await execa('noop', ['foo'], {stripFinalNewline: false});139 t.is(stdout, 'foo\n');140 });141 142 test.serial('preferLocal option', async t => {146- t.true((await m('cat-names')).stdout.length > 2);143+ t.true((await execa('cat-names')).stdout.length > 2);144 145 if (process.platform === 'win32') {146 // TODO: figure out how to make the below not hang on Windows147 return;1 unmodified line149 150 // Account for npm adding local binaries to the PATH151 const _path = process.env.PATH;152 process.env.PATH = '';156- await t.throwsAsync(m('cat-names', {preferLocal: false}), /spawn .* ENOENT/);153+ await t.throwsAsync(execa('cat-names', {preferLocal: false}), /spawn .* ENOENT/);154 process.env.PATH = _path;155 });156 157 test.serial('localDir option', async t => {158 const cwd = 'fixtures/local-dir';159 const bin = path.resolve(cwd, 'node_modules/.bin/self-path');160 164- await m('npm', ['install', '--no-package-lock'], {cwd});161+ await execa('npm', ['install', '--no-package-lock'], {cwd});162 166- const {stdout} = await m(bin, {localDir: cwd});163+ const {stdout} = await execa(bin, {localDir: cwd});164 165 t.is(path.relative(cwd, stdout), path.normalize('node_modules/self-path'));166 });167 168 test('input option can be a String', async t => {172- const {stdout} = await m('stdin', {input: 'foobar'});169+ const {stdout} = await execa('stdin', {input: 'foobar'});170 t.is(stdout, 'foobar');171 });172 173 test('input option can be a Buffer', async t => {177- const {stdout} = await m('stdin', {input: 'testing12'});174+ const {stdout} = await execa('stdin', {input: 'testing12'});175 t.is(stdout, 'testing12');176 });177 178 test('input can be a Stream', async t => {179 const s = new stream.PassThrough();180 s.write('howdy');181 s.end();185- const {stdout} = await m('stdin', {input: s});182+ const {stdout} = await execa('stdin', {input: s});183 t.is(stdout, 'howdy');184 });185 186 test('you can write to child.stdin', async t => {190- const child = m('stdin');187+ const child = execa('stdin');188 child.stdin.end('unicorns');189 t.is((await child).stdout, 'unicorns');190 });191 192 test('input option can be a String - sync', t => {196- const {stdout} = m.sync('stdin', {input: 'foobar'});193+ const {stdout} = execa.sync('stdin', {input: 'foobar'});194 t.is(stdout, 'foobar');195 });196 197 test('input option can be a Buffer - sync', t => {201- const {stdout} = m.sync('stdin', {input: Buffer.from('testing12', 'utf8')});198+ const {stdout} = execa.sync('stdin', {input: Buffer.from('testing12', 'utf8')});199 t.is(stdout, 'testing12');200 });201 202 test('opts.stdout:ignore - stdout will not collect data', async t => {206- const {stdout} = await m('stdin', {203+ const {stdout} = await execa('stdin', {204 input: 'hello',205 stdio: [null, 'ignore', null]206 });207 t.is(stdout, null);208 });209 210 test('helpful error trying to provide an input stream in sync mode', t => {211 t.throws(215- () => m.sync('stdin', {input: new stream.PassThrough()}),212+ () => execa.sync('stdin', {input: new stream.PassThrough()}),213 /The `input` option cannot be a stream in sync mode/214 );215 });216 217 test('execa() returns a promise with kill() and pid', t => {221- const promise = m('noop', ['foo']);218+ const promise = execa('noop', ['foo']);219 t.is(typeof promise.kill, 'function');220 t.is(typeof promise.pid, 'number');221 });222 223 test('maxBuffer affects stdout', async t => {227- await t.throwsAsync(m('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);228- await t.notThrowsAsync(m('max-buffer', ['stdout', '10'], {maxBuffer: 10}));224+ await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);225+ await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));226 });227 228 test('maxBuffer affects stderr', async t => {232- await t.throwsAsync(m('max-buffer', ['stderr', '13'], {maxBuffer: 12}), /stderr maxBuffer exceeded/);233- await t.notThrowsAsync(m('max-buffer', ['stderr', '12'], {maxBuffer: 12}));229+ await t.throwsAsync(execa('max-buffer', ['stderr', '13'], {maxBuffer: 12}), /stderr maxBuffer exceeded/);230+ await t.notThrowsAsync(execa('max-buffer', ['stderr', '12'], {maxBuffer: 12}));231 });232 233 test('do not buffer stdout when `buffer` set to `false`', async t => {237- const promise = m('max-buffer', ['stdout', '10'], {buffer: false});234+ const promise = execa('max-buffer', ['stdout', '10'], {buffer: false});235 const [result, stdout] = await Promise.all([236 promise,237 getStream(promise.stdout)238 ]);2 unmodified lines241 t.is(stdout, '.........\n');242 });243 244 test('do not buffer stderr when `buffer` set to `false`', async t => {248- const promise = m('max-buffer', ['stderr', '10'], {buffer: false});245+ const promise = execa('max-buffer', ['stderr', '10'], {buffer: false});246 const [result, stderr] = await Promise.all([247 promise,248 getStream(promise.stderr)249 ]);2 unmodified lines252 t.is(stderr, '.........\n');253 });254 255 test('skip throwing when using reject option', async t => {259- const error = await m('exit', ['2'], {reject: false});256+ const error = await execa('exit', ['2'], {reject: false});257 t.is(typeof error.stdout, 'string');258 t.is(typeof error.stderr, 'string');259 });260 261 test('allow unknown exit code', async t => {265- await t.throwsAsync(m('exit', ['255']), {message: /exit code 255 \(Unknown system error -255\)/});262+ await t.throwsAsync(execa('exit', ['255']), {message: /exit code 255 \(Unknown system error -255\)/});263 });264 265 test('execa() returns code and failed properties', async t => {269- const {code, failed} = await m('noop', ['foo']);270- const error = await t.throwsAsync(m('exit', ['2']), {code: 2, message: getExitRegExp('2')});266+ const {code, failed} = await execa('noop', ['foo']);267+ const error = await t.throwsAsync(execa('exit', ['2']), {code: 2, message: getExitRegExp('2')});268 t.is(code, 0);269 t.false(failed);270 t.true(error.failed);271 });272 273 test('use relative path with \'..\' chars', async t => {274 const pathViaParentDir = path.join('..', path.basename(__dirname), 'fixtures', 'noop');278- const {stdout} = await m(pathViaParentDir, ['foo']);275+ const {stdout} = await execa(pathViaParentDir, ['foo']);276 t.is(stdout, 'foo');277 });278 279 if (process.platform !== 'win32') {280 test('execa() rejects if running non-executable', async t => {284- const cp = m('non-executable');281+ const cp = execa('non-executable');282 await t.throwsAsync(cp);283 });284 }285 286 test('error.killed is true if process was killed directly', async t => {290- const cp = m('forever');287+ const cp = execa('forever');288 289 setTimeout(() => {290 cp.kill();291 }, 100);3 unmodified lines295 });296 297 // TODO: Should this really be the case, or should we improve on child_process?298 test('error.killed is false if process was killed indirectly', async t => {302- const cp = m('forever');299+ const cp = execa('forever');300 301 setTimeout(() => {302 process.kill(cp.pid, 'SIGINT');303 }, 100);19 unmodified lines323 }324 325 if (process.platform !== 'win32') {326 test('error.signal is SIGINT', async t => {330- const cp = m('forever');327+ const cp = execa('forever');328 329 setTimeout(() => {330 process.kill(cp.pid, 'SIGINT');331 }, 100);2 unmodified lines334 t.is(error.signal, 'SIGINT');335 });336 337 test('error.signal is SIGTERM', async t => {341- const cp = m('forever');338+ const cp = execa('forever');339 340 setTimeout(() => {341 process.kill(cp.pid, 'SIGTERM');342 }, 100);2 unmodified lines345 t.is(error.signal, 'SIGTERM');346 });347 348 test('custom error.signal', async t => {352- const error = await t.throwsAsync(m('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500, message: TIMEOUT_REGEXP}));349+ const error = await t.throwsAsync(execa('delay', ['3000', '0'], {killSignal: 'SIGHUP', timeout: 1500, message: TIMEOUT_REGEXP}));350 t.is(error.signal, 'SIGHUP');351 });352 }353 354 test('result.signal is null for successful execution', async t => {358- t.is((await m('noop')).signal, null);355+ t.is((await execa('noop')).signal, null);356 });357 358 test('result.signal is null if process failed, but was not killed', async t => {362- const error = await t.throwsAsync(m('exit', [2]), {message: getExitRegExp('2')});359+ const error = await t.throwsAsync(execa('exit', [2]), {message: getExitRegExp('2')});360 t.is(error.signal, null);361 });362 363 async function code(t, num) {367- await t.throwsAsync(m('exit', [`${num}`]), {code: num, message: getExitRegExp(num)});364+ await t.throwsAsync(execa('exit', [`${num}`]), {code: num, message: getExitRegExp(num)});365 }366 367 test('error.code is 2', code, 2);368 test('error.code is 3', code, 3);369 test('error.code is 4', code, 4);370 371 test('timeout will kill the process early', async t => {375- const error = await t.throwsAsync(m('delay', ['60000', '0'], {timeout: 1500, message: TIMEOUT_REGEXP}));372+ const error = await t.throwsAsync(execa('delay', ['60000', '0'], {timeout: 1500, message: TIMEOUT_REGEXP}));373 374 t.true(error.timedOut);375 t.not(error.code, 22);376 });377 378 test('timeout will not kill the process early', async t => {382- const error = await t.throwsAsync(m('delay', ['3000', '22'], {timeout: 30000}), {code: 22, message: getExitRegExp('22')});379+ const error = await t.throwsAsync(execa('delay', ['3000', '22'], {timeout: 30000}), {code: 22, message: getExitRegExp('22')});380 t.false(error.timedOut);381 });382 383 test('timedOut will be false if no timeout was set and zero exit code', async t => {387- const result = await m('delay', ['1000', '0']);384+ const result = await execa('delay', ['1000', '0']);385 t.false(result.timedOut);386 });387 388 test('timedOut will be false if no timeout was set and non-zero exit code', async t => {392- const error = await t.throwsAsync(m('delay', ['1000', '3']), {message: getExitRegExp('3')});389+ const error = await t.throwsAsync(execa('delay', ['1000', '3']), {message: getExitRegExp('3')});390 t.false(error.timedOut);391 });392 393 async function errorMessage(t, expected, ...args) {397- await t.throwsAsync(m('exit', args), {message: expected});394+ await t.throwsAsync(execa('exit', args), {message: expected});395 }396 397 errorMessage.title = (message, expected) => `error.message matches: ${expected}`;398 399 test(errorMessage, /Command failed with exit code 2.*: exit 2 foo bar/, 2, 'foo', 'bar');400 test(errorMessage, /Command failed with exit code 3.*: exit 3 baz quz/, 3, 'baz', 'quz');401 402 async function cmd(t, expected, ...args) {406- const error = await t.throwsAsync(m('fail', args));403+ const error = await t.throwsAsync(execa('fail', args));404 t.is(error.cmd, `fail${expected}`);405 409- const result = await m('noop', args);406+ const result = await execa('noop', args);407 t.is(result.cmd, `noop${expected}`);408 }409 410 cmd.title = (message, expected) => `cmd is: ${JSON.stringify(expected)}`;3 unmodified lines414 test(cmd, '');415 416 async function spawnAndKill(t, signal, cleanup) {417 const name = cleanup ? 'sub-process' : 'sub-process-false';421- const cp = m(name);418+ const cp = execa(name);419 let pid;420 421 cp.stdout.setEncoding('utf8');422 cp.stdout.on('data', chunk => {23 unmodified lines446 test('cleanup false - SIGKILL', spawnAndKill, 'SIGKILL', false);447 }448 449 test('execa.shell() supports the `shell` option', async t => {453- const {stdout} = await m.shell('node fixtures/noop foo', {450+ const {stdout} = await execa.shell('node fixtures/noop foo', {451 shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash'452 });453 t.is(stdout, 'foo');454 });2 unmodified lines457 test('write to fast-exit process', async t => {458 // Try-catch here is necessary, because this test is not 100% accurate459 // Sometimes process can manage to accept input before exiting460 try {464- await m(`fast-exit-${process.platform}`, [], {input: 'data'});461+ await execa(`fast-exit-${process.platform}`, [], {input: 'data'});462 t.pass();463 } catch (error) {464 t.is(error.code, 32);465 }466 });467 }468 469 test('use environment variables by default', async t => {473- const result = await m.stdout('environment');470+ const result = await execa.stdout('environment');471 472 t.deepEqual(result.split('\n'), [473 'foo',474 'undefined'475 ]);476 });477 478 test('extend environment variables by default', async t => {482- const result = await m.stdout('environment', [], {env: {BAR: 'bar'}});479+ const result = await execa.stdout('environment', [], {env: {BAR: 'bar'}});480 481 t.deepEqual(result.split('\n'), [482 'foo',483 'bar'484 ]);485 });486 487 test('do not extend environment with `extendEnv: false`', async t => {491- const result = await m.stdout('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});488+ const result = await execa.stdout('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});489 490 t.deepEqual(result.split('\n'), [491 'undefined',492 'bar'2 unmodified lines495 496 test('use extend environment with `extendEnv: true` and `shell: true`', async t => {497 process.env.TEST = 'test';498 const command = process.platform === 'win32' ? 'echo %TEST%' : 'echo $TEST';502- const stdout = await m.stdout(command, {shell: true, env: {}, extendEnv: true});499+ const stdout = await execa.stdout(command, {shell: true, env: {}, extendEnv: true});500 t.is(stdout, 'test');501 delete process.env.TEST;502 });503 504 test('do not buffer when streaming', async t => {508- const result = await getStream(m('max-buffer', ['stdout', '21'], {maxBuffer: 10}).stdout);505+ const result = await getStream(execa('max-buffer', ['stdout', '21'], {maxBuffer: 10}).stdout);506 507 t.is(result, '....................\n');508 });509 510 test('detach child process', async t => {511 const file = tempfile('.txt');512 516- await m('detach', [file]);513+ await execa('detach', [file]);514 515 await delay(5000);516 517 t.is(fs.readFileSync(file, 'utf8'), 'foo\n');3 unmodified lines521 test('removes exit handler on exit', async t => {522 // FIXME: This relies on `signal-exit` internals523 const ee = process.__signal_exit_emitter__;524 528- const child = m('noop');525+ const child = execa('noop');526 const listener = ee.listeners('exit').pop();527 528 await new Promise((resolve, reject) => {529 child.on('error', reject);3 unmodified lines533 const included = ee.listeners('exit').includes(listener);534 t.false(included);535 });536 540-// eslint-disable-next-line no-use-extend-native/no-use-extend-native537+// TOOD: Remove the `if`-guard when targeting Node.js 10538 if (Promise.prototype.finally) {539 test('finally function is executed on success', async t => {540 let called = false;544- const {stdout} = await m('noop', ['foo']).finally(() => {541+ const {stdout} = await execa('noop', ['foo']).finally(() => {542 called = true;543 });544 t.is(called, true);545 t.is(stdout, 'foo');546 });547 548 test('finally function is executed on failure', async t => {549 let called = false;553- const err = await t.throwsAsync(m('exit', ['2']).finally(() => {550+ const err = await t.throwsAsync(execa('exit', ['2']).finally(() => {551 called = true;552 }));553 t.is(called, true);554 t.is(typeof err.stdout, 'string');555 t.is(typeof err.stderr, 'string');556 });557 558 test('throw in finally function bubbles up on success', async t => {562- const result = await t.throwsAsync(m('noop', ['foo']).finally(() => {559+ const result = await t.throwsAsync(execa('noop', ['foo']).finally(() => {560 throw new Error('called');561 }));562 t.is(result.message, 'called');563 });564 565 test('throw in finally bubbles up on error', async t => {569- const result = await t.throwsAsync(m('exit', ['2']).finally(() => {566+ const result = await t.throwsAsync(execa('exit', ['2']).finally(() => {567 throw new Error('called');568 }));569 t.is(result.message, 'called');570 });1 unmodified line