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
Provenance
- Commit
09df476- Tree
f7e680a- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
30c7a7a
6 files changed+51 added−55 removed
modified:lib/promise.js+2 added
123456731 unmodified lines// eslint-disable-next-line unicorn/prefer-top-level-awaitconst nativePromisePrototype = (async () => {})().constructor.prototype;
const descriptors = ['then', 'catch', 'finally'].map(property => [ property, Reflect.getOwnPropertyDescriptor(nativePromisePrototype, property),]);31 unmodified linesmodified:test/fixtures/sub-process-exit.js+6 added-10 removed
3 unmodified lines456789101112131489101112131516173 unmodified lines
const cleanup = process.argv[2] === 'true';const detached = process.argv[3] === 'true';
const runChild = async () => { try { await execa('node', ['./test/fixtures/noop.js'], {cleanup, detached}); } catch (error) { console.error(error); process.exit(1); }try { await execa('node', ['./test/fixtures/noop.js'], {cleanup, detached});} catch (error) { console.error(error); process.exit(1);}};
runChild();modified:test/test.js+2 added-2 removed
102 unmodified lines103 t.true(envPaths.some(envPath => envPath.endsWith('.bin')));104 });105 106 test('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 });111 112 test('stdin errors are handled', async t => {113 const subprocess = execa('noop.js');142 unmodified linesmodified:index.d.ts+25 added-30 removed
1-import {Buffer} from 'node:buffer';2-import {ChildProcess} from 'node:child_process';3-import {Stream, Readable as ReadableStream} from 'node:stream';1+import {type Buffer} from 'node:buffer';2+import {type ChildProcess} from 'node:child_process';3+import {type Stream, type Readable as ReadableStream} from 'node:stream';4 5 export type StdioOption =6 | 'pipe'7 | 'overlapped'3 unmodified lines11 | Stream12 | number13 | undefined;14 15-export interface CommonOptions<EncodingType> {15+export 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 exit223 unmodified lines243 244 @default true245 */246 readonly windowsHide?: boolean;247-}247+};248 249-export interface Options<EncodingType = string> extends CommonOptions<EncodingType> {249+export 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>;255 256-export interface SyncOptions<EncodingType = string> extends CommonOptions<EncodingType> {256+export 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>;262 263-export interface NodeOptions<EncodingType = string> extends Options<EncodingType> {263+export type NodeOptions<EncodingType = string> = {264 /**265 The Node.js executable to use.266 267 @default process.execPath5 unmodified lines273 274 @default process.execArgv275 */276 readonly nodeOptions?: string[];277-}277+} & Options<EncodingType>;278 279-export interface ExecaReturnBase<StdoutStderrType> {279+export type ExecaReturnBase<StdoutStderrType> = {280 /**281 The file and arguments that were run, for logging purposes.282 283 This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.50 unmodified lines334 335 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+};339 340-export interface ExecaSyncReturnValue<StdoutErrorType = string>341- extends ExecaReturnBase<StdoutErrorType> {342-}340+export type ExecaSyncReturnValue<StdoutErrorType = string> = {341+} & ExecaReturnBase<StdoutErrorType>;342 343 /**344 Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.345 3 unmodified lines349 - timing out350 - being canceled351 - there's not enough memory or there are already too many child processes352 */354-export interface ExecaReturnValue<StdoutErrorType = string>355- extends ExecaSyncReturnValue<StdoutErrorType> {353+export type ExecaReturnValue<StdoutErrorType = string> = {354 /**355 The output of the process with `stdout` and `stderr` interleaved.356 357 This is `undefined` if either:7 unmodified lines365 366 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>;370 373-export interface ExecaSyncError<StdoutErrorType = string>374- extends Error,375- ExecaReturnBase<StdoutErrorType> {371+export 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.374 375 The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.10 unmodified lines386 387 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>;391 396-export interface ExecaError<StdoutErrorType = string>397- extends ExecaSyncError<StdoutErrorType> {392+export type ExecaError<StdoutErrorType = string> = {393 /**394 The output of the process with `stdout` and `stderr` interleaved.395 396 This is `undefined` if either:5 unmodified lines402 /**403 Whether the process was canceled.404 */405 isCanceled: boolean;411-}406+} & ExecaSyncError<StdoutErrorType>;407 413-export interface KillOptions {408+export type KillOptions = {409 /**410 Milliseconds to wait for the child process to terminate before sending `SIGKILL`.411 412 Can be disabled with `false`.413 414 @default 5000415 */416 forceKillAfterTimeout?: number | false;422-}417+};418 424-export interface ExecaChildPromise<StdoutErrorType> {419+export 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).422 423 This is `undefined` if either:14 unmodified lines438 /**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+};443 444 export type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &445 ExecaChildPromise<StdoutErrorType> &446 Promise<ExecaReturnValue<StdoutErrorType>>;130 unmodified linesmodified:index.test-d.ts+6 added-6 removed
1 unmodified line2 // 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`.5 import * as process from 'node:process';6-import {Readable as ReadableStream} from 'node:stream';6+import {type Readable as ReadableStream} from 'node:stream';7 import {expectType, expectError} from 'tsd';8 import {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';20 21 try {22 const execaPromise = execa('unicorns');199 unmodified linesmodified:package.json+10 added-7 removed
41 unmodified lines424344454646474849505152535455565758555657585960616263646364656667684 unmodified lines73747576777879808182833 unmodified lines41 unmodified lines ], "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.1", "human-signals": "^4.1.0", "human-signals": "^4.3.0", "is-stream": "^3.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^5.1.0", "onetime": "^6.0.0", "signal-exit": "^3.0.7", "strip-final-newline": "^3.0.0" }, "devDependencies": { "@types/node": "^17.0.17", "ava": "^4.0.1", "c8": "^7.11.0", "get-node": "^12.0.0", "@types/node": "^18.13.0", "ava": "^5.2.0", "c8": "^7.12.0", "get-node": "^13.5.0", "is-running": "^2.1.0", "p-event": "^5.0.1", "path-key": "^4.0.0", "tempfile": "^4.0.0", "tsd": "^0.19.1", "xo": "^0.48.0" "tsd": "^0.25.0", "xo": "^0.53.1" }, "c8": { "reporter": [ "text",4 unmodified lines "**/test.js", "**/test/**" ] }, "ava": { "workerThreads": false }, "xo": { "rules": { "unicorn/no-empty-file": "off", "@typescript-eslint/ban-types": "off"3 unmodified lines