Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 3, 2020
1 parent bdbd975 commit 5d64878
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 47 deletions.
29 changes: 14 additions & 15 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ declare namespace execa {

interface ExecaSyncError<StdoutErrorType = string>
extends Error,
ExecaReturnBase<StdoutErrorType> {
ExecaReturnBase<StdoutErrorType> {
/**
Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.
Expand Down Expand Up @@ -384,33 +384,33 @@ declare namespace execa {
}

interface ExecaChildPromise<StdoutErrorType> {
/**
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
This is `undefined` if either:
- the `all` option is `false` (the default value)
- both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
*/
all?: ReadableStream;

catch<ResultType = never>(
onRejected?: (reason: ExecaError<StdoutErrorType>) => ResultType | PromiseLike<ResultType>
): Promise<ExecaReturnValue<StdoutErrorType> | ResultType>;

/**
Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal), except if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`.
*/
kill(signal?: string, options?: execa.KillOptions): void;
kill(signal?: string, options?: KillOptions): void;

/**
Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This is preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`.
*/
cancel(): void;

/**
Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).
This is `undefined` if either:
- the `all` option is `false` (the default value)
- both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)
*/
all?: ReadableStream;
}

type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &
ExecaChildPromise<StdoutErrorType> &
Promise<ExecaReturnValue<StdoutErrorType>>;
ExecaChildPromise<StdoutErrorType> &
Promise<ExecaReturnValue<StdoutErrorType>>;
}

declare const execa: {
Expand All @@ -432,7 +432,6 @@ declare const execa: {
console.log(stdout);
//=> 'unicorns'
// Cancelling a spawned process
const subprocess = execa('node');
Expand Down Expand Up @@ -465,7 +464,7 @@ declare const execa: {
): execa.ExecaChildProcess<Buffer>;
(file: string, options?: execa.Options): execa.ExecaChildProcess;
(file: string, options?: execa.Options<null>): execa.ExecaChildProcess<
Buffer
Buffer
>;

/**
Expand Down
8 changes: 4 additions & 4 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expectType, expectError} from 'tsd';
import {Readable as ReadableStream} from 'stream'
import {Readable as ReadableStream} from 'stream';
import execa = require('.');
import {
ExecaReturnValue,
Expand All @@ -12,7 +12,7 @@ import {
try {
const execaPromise = execa('unicorns');
execaPromise.cancel();
expectType<ReadableStream | undefined>(execaPromise.all)
expectType<ReadableStream | undefined>(execaPromise.all);

const unicornsResult = await execaPromise;
expectType<string>(unicornsResult.command);
Expand All @@ -26,7 +26,7 @@ try {
expectType<boolean>(unicornsResult.killed);
expectType<string | undefined>(unicornsResult.signal);
expectType<string | undefined>(unicornsResult.signalDescription);
} catch (error) {
} catch (error) { // eslint-disable-line @typescript-eslint/no-implicit-any-catch
const execaError: ExecaError = error;

expectType<string>(execaError.message);
Expand Down Expand Up @@ -57,7 +57,7 @@ try {
expectType<boolean>(unicornsResult.killed);
expectType<string | undefined>(unicornsResult.signal);
expectType<string | undefined>(unicornsResult.signalDescription);
} catch (error) {
} catch (error) { // eslint-disable-line @typescript-eslint/no-implicit-any-catch
const execaError: ExecaSyncError = error;

expectType<string>(execaError.message);
Expand Down
16 changes: 8 additions & 8 deletions lib/stdio.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
'use strict';
const aliases = ['stdin', 'stdout', 'stderr'];

const hasAlias = opts => aliases.some(alias => opts[alias] !== undefined);
const hasAlias = options => aliases.some(alias => options[alias] !== undefined);

const normalizeStdio = opts => {
if (!opts) {
const normalizeStdio = options => {
if (!options) {
return;
}

const {stdio} = opts;
const {stdio} = options;

if (stdio === undefined) {
return aliases.map(alias => opts[alias]);
return aliases.map(alias => options[alias]);
}

if (hasAlias(opts)) {
if (hasAlias(options)) {
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map(alias => `\`${alias}\``).join(', ')}`);
}

Expand All @@ -33,8 +33,8 @@ const normalizeStdio = opts => {
module.exports = normalizeStdio;

// `ipc` is pushed unless it is already present
module.exports.node = opts => {
const stdio = normalizeStdio(opts);
module.exports.node = options => {
const stdio = normalizeStdio(options);

if (stdio === 'ipc') {
return 'ipc';
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@
"local"
],
"dependencies": {
"cross-spawn": "^7.0.0",
"get-stream": "^5.0.0",
"human-signals": "^1.1.1",
"cross-spawn": "^7.0.3",
"get-stream": "^6.0.0",
"human-signals": "^2.1.0",
"is-stream": "^2.0.0",
"merge-stream": "^2.0.0",
"npm-run-path": "^4.0.0",
"onetime": "^5.1.0",
"signal-exit": "^3.0.2",
"npm-run-path": "^4.0.1",
"onetime": "^5.1.2",
"signal-exit": "^3.0.3",
"strip-final-newline": "^2.0.0"
},
"devDependencies": {
"@types/node": "^12.12.18",
"ava": "^2.1.0",
"coveralls": "^3.0.9",
"get-node": "^6.6.0",
"@types/node": "^14.14.10",
"ava": "^2.4.0",
"coveralls": "^3.1.0",
"get-node": "^11.0.1",
"is-running": "^2.1.0",
"nyc": "^14.1.1",
"p-event": "^4.1.0",
"nyc": "^15.1.0",
"p-event": "^4.2.0",
"tempfile": "^3.0.0",
"tsd": "^0.11.0",
"xo": "^0.25.3"
"tsd": "^0.13.1",
"xo": "^0.35.0"
},
"nyc": {
"exclude": [
Expand Down
6 changes: 3 additions & 3 deletions test/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ test('exitCode is 0 on success', async t => {
t.is(exitCode, 0);
});

const testExitCode = async (t, num) => {
const {exitCode} = await t.throwsAsync(execa('exit', [`${num}`]), {message: getExitRegExp(num)});
t.is(exitCode, num);
const testExitCode = async (t, number) => {
const {exitCode} = await t.throwsAsync(execa('exit', [`${number}`]), {message: getExitRegExp(number)});
t.is(exitCode, number);
};

test('exitCode is 2', testExitCode, 2);
Expand Down
2 changes: 1 addition & 1 deletion test/kill.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if (process.platform !== 'win32') {

test('`forceKillAfterTimeout` should not be NaN', t => {
t.throws(() => {
execa('noop').kill('SIGTERM', {forceKillAfterTimeout: NaN});
execa('noop').kill('SIGTERM', {forceKillAfterTimeout: Number.NaN});
}, {instanceOf: TypeError, message: /non-negative integer/});
});

Expand Down
4 changes: 2 additions & 2 deletions test/stdio.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util from 'util';
import {inspect} from 'util';
import test from 'ava';
import normalizeStdio from '../lib/stdio';

Expand All @@ -13,7 +13,7 @@ const macro = (t, input, expected, func) => {
t.deepEqual(func(input), expected);
};

const macroTitle = name => (title, input) => `${name} ${(util.inspect(input))}`;
const macroTitle = name => (title, input) => `${name} ${(inspect(input))}`;

const stdioMacro = (...args) => macro(...args, normalizeStdio);
stdioMacro.title = macroTitle('execa()');
Expand Down

0 comments on commit 5d64878

Please sign in to comment.