Skip to content
Myr

Update dependencies, refactor TypeScript definition to CommonJS compatible export (#197)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Dimitri Benin · committed by Sindre Sorhus · parent 95c8a14 · Browse files · 4 files+282 added−268 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+282 added−268 removed

  • other:+282 added−268 removed

4 files+282 added−268 removed

modified:index.d.ts+272 added-258 removed
1/// <reference types="node"/>2import {ChildProcess} from 'child_process';3import {Stream, Readable as ReadableStream} from 'stream';45declare namespace execa {5export type StdioOption =6 | 'pipe'7 | 'ipc'8 | 'ignore'9 | 'inherit'10 | Stream11 | number12 | null13 | undefined;6 type StdioOption =7 | 'pipe'8 | 'ipc'9 | 'ignore'10 | 'inherit'11 | Stream12 | number13 | null14 | undefined;1515export interface CommonOptions<EncodingType> {16 /**17 Current working directory of the child process.16 interface CommonOptions<EncodingType> {17 /**18 Current working directory of the child process.1919 @default process.cwd()20 */21 readonly cwd?: string;20 @default process.cwd()21 */22 readonly cwd?: string;2323 /**24 Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.24 /**25 Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.2626 @default process.env27 */28 readonly env?: NodeJS.ProcessEnv;27 @default process.env28 */29 readonly env?: NodeJS.ProcessEnv;3030 /**31 Set to `false` if you don't want to extend the environment variables when providing the `env` property.31 /**32 Set to `false` if you don't want to extend the environment variables when providing the `env` property.3333 @default true34 */35 readonly extendEnv?: boolean;34 @default true35 */36 readonly extendEnv?: boolean;3737 /**38 Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.39 */40 readonly argv0?: string;38 /**39 Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.40 */41 readonly argv0?: string;4242 /**43 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.43 /**44 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.4545 @default 'pipe'46 */47 readonly stdio?: 'pipe' | 'ignore' | 'inherit' | ReadonlyArray<StdioOption>;46 @default 'pipe'47 */48 readonly stdio?: 'pipe' | 'ignore' | 'inherit' | ReadonlyArray<StdioOption>;4949 /**50 Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).50 /**51 Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).5252 @default false53 */54 readonly detached?: boolean;53 @default false54 */55 readonly detached?: boolean;5656 /**57 Sets the user identity of the process.58 */59 readonly uid?: number;57 /**58 Sets the user identity of the process.59 */60 readonly uid?: number;6161 /**62 Sets the group identity of the process.63 */64 readonly gid?: number;62 /**63 Sets the group identity of the process.64 */65 readonly gid?: number;6666 /**67 If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.67 /**68 If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.6969 @default false70 */71 readonly shell?: boolean | string;70 @default false71 */72 readonly shell?: boolean | string;7373 /**74 Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.74 /**75 Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.7676 @default true77 */78 readonly stripFinalNewline?: boolean;77 @default true78 */79 readonly stripFinalNewline?: boolean;8080 /**81 Prefer locally installed binaries when looking for a binary to execute.81 /**82 Prefer locally installed binaries when looking for a binary to execute.8383 If you `$ npm install foo`, you can then `execa('foo')`.84 If you `$ npm install foo`, you can then `execa('foo')`.8585 @default true86 */87 readonly preferLocal?: boolean;86 @default true87 */88 readonly preferLocal?: boolean;8989 /**90 Preferred path to find locally installed binaries in (use with `preferLocal`).90 /**91 Preferred path to find locally installed binaries in (use with `preferLocal`).9292 @default process.cwd()93 */94 readonly localDir?: string;93 @default process.cwd()94 */95 readonly localDir?: string;9696 /**97 Setting this to `false` resolves the promise with the error instead of rejecting it.97 /**98 Setting this to `false` resolves the promise with the error instead of rejecting it.9999 @default true100 */101 readonly reject?: boolean;100 @default true101 */102 readonly reject?: boolean;103103 /**104 Keep track of the spawned process and `kill` it when the parent process exits.104 /**105 Keep track of the spawned process and `kill` it when the parent process exits.106106 @default true107 */108 readonly cleanup?: boolean;107 @default true108 */109 readonly cleanup?: boolean;110110 /**111 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.111 /**112 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.113113 @default 'utf8'114 */115 readonly encoding?: EncodingType;114 @default 'utf8'115 */116 readonly encoding?: EncodingType;117117 /**118 If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.118 /**119 If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.120120 @default 0121 */122 readonly timeout?: number;121 @default 0122 */123 readonly timeout?: number;124124 /**125 Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.125 /**126 Buffer the output from the spawned process. When buffering is disabled you must consume the output of the `stdout` and `stderr` streams because the promise will not be resolved/rejected until they have completed.127127 @default true128 */129 readonly buffer?: boolean;128 @default true129 */130 readonly buffer?: boolean;131131 /**132 Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 10MB.132 /**133 Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 10MB.134134 @default 10000000135 */136 readonly maxBuffer?: number;135 @default 10000000136 */137 readonly maxBuffer?: number;138138 /**139 Signal value to be used when the spawned process will be killed.139 /**140 Signal value to be used when the spawned process will be killed.141141 @default 'SIGTERM'142 */143 readonly killSignal?: string | number;142 @default 'SIGTERM'143 */144 readonly killSignal?: string | number;145145 /**146 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).146 /**147 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).148148 @default 'pipe'149 */150 readonly stdin?: StdioOption;149 @default 'pipe'150 */151 readonly stdin?: StdioOption;152152 /**153 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).153 /**154 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).155155 @default 'pipe'156 */157 readonly stdout?: StdioOption;156 @default 'pipe'157 */158 readonly stdout?: StdioOption;159159 /**160 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).160 /**161 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).162162 @default 'pipe'163 */164 readonly stderr?: StdioOption;163 @default 'pipe'164 */165 readonly stderr?: StdioOption;166166 /**167 If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.167 /**168 If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.169169 @default false170 */171 readonly windowsVerbatimArguments?: boolean;172}170 @default false171 */172 readonly windowsVerbatimArguments?: boolean;173 }174174export interface Options<EncodingType = string>175 extends CommonOptions<EncodingType> {176 /**177 Write some input to the `stdin` of your binary.178 */179 readonly input?: string | Buffer | ReadableStream;180}175 interface Options<EncodingType = string> extends CommonOptions<EncodingType> {176 /**177 Write some input to the `stdin` of your binary.178 */179 readonly input?: string | Buffer | ReadableStream;180 }181182export interface SyncOptions<EncodingType = string>183 extends CommonOptions<EncodingType> {184 /**185 Write some input to the `stdin` of your binary.186 */187 readonly input?: string | Buffer;188}182 interface SyncOptions<EncodingType = string>183 extends CommonOptions<EncodingType> {184 /**185 Write some input to the `stdin` of your binary.186 */187 readonly input?: string | Buffer;188 }189190export interface ExecaReturnBase<StdoutStderrType> {191 /**192 The numeric exit code of the process that was run.193 */194 exitCode: number;190 interface ExecaReturnBase<StdoutStderrType> {191 /**192 The numeric exit code of the process that was run.193 */194 exitCode: number;195196 /**197 The textual exit code of the process that was run.198 */199 exitCodeName: string;196 /**197 The textual exit code of the process that was run.198 */199 exitCodeName: string;200201 /**202 The output of the process on stdout.203 */204 stdout: StdoutStderrType;201 /**202 The output of the process on stdout.203 */204 stdout: StdoutStderrType;205206 /**207 The output of the process on stderr.208 */209 stderr: StdoutStderrType;206 /**207 The output of the process on stderr.208 */209 stderr: StdoutStderrType;210211 /**212 Whether the process failed to run.213 */214 failed: boolean;211 /**212 Whether the process failed to run.213 */214 failed: boolean;215216 /**217 The signal that was used to terminate the process.218 */219 signal?: string;216 /**217 The signal that was used to terminate the process.218 */219 signal?: string;220221 /**222 The command that was run.223 */224 command: string;221 /**222 The command that was run.223 */224 command: string;225226 /**227 Whether the process timed out.228 */229 timedOut: boolean;226 /**227 Whether the process timed out.228 */229 timedOut: boolean;230231 /**232 Whether the process was killed.233 */234 killed: boolean;235}231 /**232 Whether the process was killed.233 */234 killed: boolean;235 }236237export interface ExecaSyncReturnValue<StdoutErrorType = string>238 extends ExecaReturnBase<StdoutErrorType> {239 /**240 The exit code of the process that was run.241 */242 code: number;243}237 interface ExecaSyncReturnValue<StdoutErrorType = string>238 extends ExecaReturnBase<StdoutErrorType> {239 /**240 The exit code of the process that was run.241 */242 code: number;243 }244245export interface ExecaReturnValue<StdoutErrorType = string>246 extends ExecaSyncReturnValue<StdoutErrorType> {247 /**248 The output of the process with `stdout` and `stderr` interleaved.249 */250 all: StdoutErrorType;245 interface ExecaReturnValue<StdoutErrorType = string>246 extends ExecaSyncReturnValue<StdoutErrorType> {247 /**248 The output of the process with `stdout` and `stderr` interleaved.249 */250 all: StdoutErrorType;251252 /**253 Whether the process was canceled.254 */255 isCanceled: boolean;256}252 /**253 Whether the process was canceled.254 */255 isCanceled: boolean;256 }257258export interface ExecaSyncError<StdoutErrorType = string>259 extends Error,260 ExecaReturnBase<StdoutErrorType> {261 /**262 The error message.263 */264 message: string;258 interface ExecaSyncError<StdoutErrorType = string>259 extends Error,260 ExecaReturnBase<StdoutErrorType> {261 /**262 The error message.263 */264 message: string;265266 /**267 The exit code (either numeric or textual) of the process that was run.268 */269 code: number | string;270}266 /**267 The exit code (either numeric or textual) of the process that was run.268 */269 code: number | string;270 }271272export interface ExecaError<StdoutErrorType = string>273 extends ExecaSyncError<StdoutErrorType> {274 /**275 The output of the process with `stdout` and `stderr` interleaved.276 */277 all: StdoutErrorType;272 interface ExecaError<StdoutErrorType = string>273 extends ExecaSyncError<StdoutErrorType> {274 /**275 The output of the process with `stdout` and `stderr` interleaved.276 */277 all: StdoutErrorType;278279 /**280 Whether the process was canceled.281 */282 isCanceled: boolean;283}279 /**280 Whether the process was canceled.281 */282 isCanceled: boolean;283 }284285export interface ExecaChildPromise<StdoutErrorType> {286 catch<ResultType = never>(287 onRejected?:288 | ((reason: ExecaError<StdoutErrorType>) => ResultType | PromiseLike<ResultType>)289 | null290 ): Promise<ExecaReturnValue<StdoutErrorType> | ResultType>;285 interface ExecaChildPromise<StdoutErrorType> {286 catch<ResultType = never>(287 onRejected?:288 | ((289 reason: ExecaError<StdoutErrorType>290 ) => ResultType | PromiseLike<ResultType>)291 | null292 ): Promise<ExecaReturnValue<StdoutErrorType> | ResultType>;293292 /**293 Cancel the subprocess.294 /**295 Cancel the subprocess.296295 Causes the promise to reject an error with a `.isCanceled = true` property, provided the process gets canceled. The process will not be canceled if it has already exited.296 */297 cancel(): void;297 Causes the promise to reject an error with a `.isCanceled = true` property, provided the process gets canceled. The process will not be canceled if it has already exited.298 */299 cancel(): void;300 }301302 type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &303 ExecaChildPromise<StdoutErrorType> &304 Promise<ExecaReturnValue<StdoutErrorType>>;305}306300export type ExecaChildProcess<StdoutErrorType = string> = ChildProcess &301 ExecaChildPromise<StdoutErrorType> &302 Promise<ExecaReturnValue<StdoutErrorType>>;303307declare const execa: {308 /**309 Execute a file.310
29 unmodified lines
340 */341 (342 file: string,343 arguments?: ReadonlyArray<string>,341 options?: Options342 ): ExecaChildProcess;344 options?: execa.Options345 ): execa.ExecaChildProcess;346 (347 file: string,348 arguments?: ReadonlyArray<string>,346 options?: Options<null>347 ): ExecaChildProcess<Buffer>;348 (file: string, options?: Options): ExecaChildProcess;349 (file: string, options?: Options<null>): ExecaChildProcess<Buffer>;349 options?: execa.Options<null>350 ): execa.ExecaChildProcess<Buffer>;351 (file: string, options?: execa.Options): execa.ExecaChildProcess;352 (file: string, options?: execa.Options<null>): execa.ExecaChildProcess<353 Buffer354 >;355356 /**357 Same as `execa()`, but returns only `stdout`.358
3 unmodified lines
362 */363 stdout(364 file: string,365 arguments?: ReadonlyArray<string>,361 options?: Options366 options?: execa.Options367 ): Promise<string>;368 stdout(369 file: string,370 arguments?: ReadonlyArray<string>,366 options?: Options<null>371 options?: execa.Options<null>372 ): Promise<Buffer>;368 stdout(file: string, options?: Options): Promise<string>;369 stdout(file: string, options?: Options<null>): Promise<Buffer>;373 stdout(file: string, options?: execa.Options): Promise<string>;374 stdout(file: string, options?: execa.Options<null>): Promise<Buffer>;375376 /**377 Same as `execa()`, but returns only `stderr`.378
3 unmodified lines
382 */383 stderr(384 file: string,385 arguments?: ReadonlyArray<string>,381 options?: Options386 options?: execa.Options387 ): Promise<string>;388 stderr(389 file: string,390 arguments?: ReadonlyArray<string>,386 options?: Options<null>391 options?: execa.Options<null>392 ): Promise<Buffer>;388 stderr(file: string, options?: Options): Promise<string>;389 stderr(file: string, options?: Options<null>): Promise<Buffer>;393 stderr(file: string, options?: execa.Options): Promise<string>;394 stderr(file: string, options?: execa.Options<null>): Promise<Buffer>;395396 /**397 Execute a command through the system shell.398
32 unmodified lines
431 }432 })();433 ```434 */430 shell(command: string, options?: Options): ExecaChildProcess;431 shell(command: string, options?: Options<null>): ExecaChildProcess<Buffer>;435 shell(command: string, options?: execa.Options): execa.ExecaChildProcess;436 shell(437 command: string,438 options?: execa.Options<null>439 ): execa.ExecaChildProcess<Buffer>;440441 /**442 Execute a file synchronously.443
5 unmodified lines
449 */450 sync(451 file: string,452 arguments?: ReadonlyArray<string>,445 options?: SyncOptions446 ): ExecaSyncReturnValue;453 options?: execa.SyncOptions454 ): execa.ExecaSyncReturnValue;455 sync(456 file: string,457 arguments?: ReadonlyArray<string>,450 options?: SyncOptions<null>451 ): ExecaSyncReturnValue<Buffer>;452 sync(file: string, options?: SyncOptions): ExecaSyncReturnValue;453 sync(file: string, options?: SyncOptions<null>): ExecaSyncReturnValue<Buffer>;458 options?: execa.SyncOptions<null>459 ): execa.ExecaSyncReturnValue<Buffer>;460 sync(file: string, options?: execa.SyncOptions): execa.ExecaSyncReturnValue;461 sync(462 file: string,463 options?: execa.SyncOptions<null>464 ): execa.ExecaSyncReturnValue<Buffer>;465466 /**467 Execute a command synchronously through the system shell.468
23 unmodified lines
492 //}493 }494 ```495 */485 shellSync(command: string, options?: Options): ExecaSyncReturnValue;496 shellSync(497 command: string,498 options?: execa.Options499 ): execa.ExecaSyncReturnValue;500 shellSync(501 command: string,488 options?: Options<null>489 ): ExecaSyncReturnValue<Buffer>;502 options?: execa.Options<null>503 ): execa.ExecaSyncReturnValue<Buffer>;504};505492export default execa;506export = execa;
modified:index.js-1 removed
373 unmodified lines
374 return spawned;375};376377module.exports = execa;378module.exports.default = execa;378379// TODO: set `stderr: 'ignore'` when that option is implemented380module.exports.stdout = async (...args) => {381 const {stdout} = await execa(...args);
48 unmodified lines
modified:index.test-d.ts+2 added-1 removed
modified:package.json+8 added-8 removed
36 unmodified lines
37 "path",38 "local"39 ],40 "dependencies": {41 "cross-spawn": "^6.0.0",42 "get-stream": "^4.0.0",41 "cross-spawn": "^6.0.5",42 "get-stream": "^5.0.0",43 "is-stream": "^1.1.0",44 "merge-stream": "^1.0.1",45 "npm-run-path": "^2.0.0",45 "npm-run-path": "^3.0.0",46 "p-finally": "^1.0.0",47 "signal-exit": "^3.0.0",47 "signal-exit": "^3.0.2",48 "strip-final-newline": "^2.0.0"49 },50 "devDependencies": {51 "@types/node": "^11.11.4",52 "ava": "^1.3.1",51 "@types/node": "^11.12.2",52 "ava": "^1.4.1",53 "cat-names": "^2.0.0",54 "coveralls": "^3.0.3",55 "delay": "^4.1.0",56 "is-running": "^2.0.0",56 "is-running": "^2.1.0",57 "nyc": "^13.3.0",58 "tempfile": "^2.0.0",59 "tsd": "^0.7.0",59 "tsd": "^0.7.1",60 "xo": "^0.24.0"61 },62 "nyc": {63 "exclude": [
6 unmodified lines