Skip to content
Myr

Meta tweaks

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 30c7a7a · Browse files · 6 files+51 added−55 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+51 added−55 removed

  • tests:+8 added−12 removed
  • other:+43 added−43 removed

6 files+51 added−55 removed

modified:lib/promise.js+2 added
modified:test/fixtures/sub-process-exit.js+6 added-10 removed
modified:test/test.js+2 added-2 removed
102 unmodified lines
103 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));104});105106test('execPath option', async t => {107 const {path: execPath} = await getNode('6.0.0');107 const {path: execPath} = await getNode('16.0.0');108 const {stdout} = await execa('node', ['-p', 'process.env.Path || process.env.PATH'], {preferLocal: true, execPath});109 t.true(stdout.includes('6.0.0'));109 t.true(stdout.includes('16.0.0'));110});111112test('stdin errors are handled', async t => {113 const subprocess = execa('noop.js');
142 unmodified lines
modified:index.d.ts+25 added-30 removed
1import {Buffer} from 'node:buffer';2import {ChildProcess} from 'node:child_process';3import {Stream, Readable as ReadableStream} from 'node:stream';1import {type Buffer} from 'node:buffer';2import {type ChildProcess} from 'node:child_process';3import {type Stream, type Readable as ReadableStream} from 'node:stream';45export type StdioOption =6 | 'pipe'7 | 'overlapped'
3 unmodified lines
11 | Stream12 | number13 | undefined;1415export interface CommonOptions<EncodingType> {15export type CommonOptions<EncodingType> = {16 /**17 Kill the spawned process when the parent process exits unless either:18 - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)19 - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit
223 unmodified lines
243244 @default true245 */246 readonly windowsHide?: boolean;247}247};248249export interface Options<EncodingType = string> extends CommonOptions<EncodingType> {249export type Options<EncodingType = string> = {250 /**251 Write some input to the `stdin` of your binary.252 */253 readonly input?: string | Buffer | ReadableStream;254}254} & CommonOptions<EncodingType>;255256export interface SyncOptions<EncodingType = string> extends CommonOptions<EncodingType> {256export type SyncOptions<EncodingType = string> = {257 /**258 Write some input to the `stdin` of your binary.259 */260 readonly input?: string | Buffer;261}261} & CommonOptions<EncodingType>;262263export interface NodeOptions<EncodingType = string> extends Options<EncodingType> {263export type NodeOptions<EncodingType = string> = {264 /**265 The Node.js executable to use.266267 @default process.execPath
5 unmodified lines
273274 @default process.execArgv275 */276 readonly nodeOptions?: string[];277}277} & Options<EncodingType>;278279export interface ExecaReturnBase<StdoutStderrType> {279export type ExecaReturnBase<StdoutStderrType> = {280 /**281 The file and arguments that were run, for logging purposes.282283 This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.
50 unmodified lines
334335 If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.336 */337 signalDescription?: string;338}338};339340export interface ExecaSyncReturnValue<StdoutErrorType = string>341 extends ExecaReturnBase<StdoutErrorType> {342}340export type ExecaSyncReturnValue<StdoutErrorType = string> = {341} & ExecaReturnBase<StdoutErrorType>;342343/**344Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.345
3 unmodified lines
349- timing out350- being canceled351- there's not enough memory or there are already too many child processes352*/354export interface ExecaReturnValue<StdoutErrorType = string>355 extends ExecaSyncReturnValue<StdoutErrorType> {353export type ExecaReturnValue<StdoutErrorType = string> = {354 /**355 The output of the process with `stdout` and `stderr` interleaved.356357 This is `undefined` if either:
7 unmodified lines
365366 You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.367 */368 isCanceled: boolean;371}369} & ExecaSyncReturnValue<StdoutErrorType>;370373export interface ExecaSyncError<StdoutErrorType = string>374 extends Error,375 ExecaReturnBase<StdoutErrorType> {371export type ExecaSyncError<StdoutErrorType = string> = {372 /**373 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.374375 The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.
10 unmodified lines
386387 This is `undefined` unless the child process exited due to an `error` event or a timeout.388 */389 originalMessage?: string;394}390} & Error & ExecaReturnBase<StdoutErrorType>;391396export interface ExecaError<StdoutErrorType = string>397 extends ExecaSyncError<StdoutErrorType> {392export type ExecaError<StdoutErrorType = string> = {393 /**394 The output of the process with `stdout` and `stderr` interleaved.395396 This is `undefined` if either:
5 unmodified lines
402 /**403 Whether the process was canceled.404 */405 isCanceled: boolean;411}406} & ExecaSyncError<StdoutErrorType>;407413export interface KillOptions {408export type KillOptions = {409 /**410 Milliseconds to wait for the child process to terminate before sending `SIGKILL`.411412 Can be disabled with `false`.413414 @default 5000415 */416 forceKillAfterTimeout?: number | false;422}417};418424export interface ExecaChildPromise<StdoutErrorType> {419export type ExecaChildPromise<StdoutErrorType> = {420 /**421 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).422423 This is `undefined` if either:
14 unmodified lines
438 /**439 Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This used to be preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`. But now this is deprecated and you should either use `.kill()` or the `signal` option when creating the child process.440 */441 cancel(): void;447}442};443444export type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &445ExecaChildPromise<StdoutErrorType> &446Promise<ExecaReturnValue<StdoutErrorType>>;
130 unmodified lines
modified:index.test-d.ts+6 added-6 removed
1 unmodified line
2// For some reason a default import of `process` causes3// `process.stdin`, `process.stderr`, and `process.stdout`4// to get treated as `any` by `@typescript-eslint/no-unsafe-assignment`.5import * as process from 'node:process';6import {Readable as ReadableStream} from 'node:stream';6import {type Readable as ReadableStream} from 'node:stream';7import {expectType, expectError} from 'tsd';8import {9 execa,10 execaSync,11 execaCommand,12 execaCommandSync,13 execaNode,14 ExecaReturnValue,15 ExecaChildProcess,16 ExecaError,17 ExecaSyncReturnValue,18 ExecaSyncError,14 type ExecaReturnValue,15 type ExecaChildProcess,16 type ExecaError,17 type ExecaSyncReturnValue,18 type ExecaSyncError,19} from './index.js';2021try {22 const execaPromise = execa('unicorns');
199 unmodified lines
modified:package.json+10 added-7 removed