Skip to content
Myr

pipe.d.ts

This file

Path

types/pipe.d.ts

72 lines · 3.7 KiB · TypeScript

Last changed by

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

Add `.js` to imports in types (#1033)ehmickybefore adoption3bdab60

lines 1–3why, one step back
1import type {Options} from './arguments/options.js';
2import type {Result} from './return/result.js';3import type {FromOption, ToOption} from './arguments/fd-options.js';

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

lines 4–5why, one step back
4import type {ResultPromise, SubprocessResultMethods} from './subprocess/subprocess.js';
5import type {IpcMethods, HasIpc} from './ipc.js';

Add `.js` to imports in types (#1033)ehmickybefore adoption3bdab60

line 6why, one step back
6import type {TemplateExpression} from './methods/template.js';

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 7–27why, one step back
7
8// `subprocess.pipe()` options9type PipeOptions = {10 /**11 Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.1213 `"all"` pipes both `stdout` and `stderr`. This requires the `all` option to be `true`.14 */15 readonly from?: FromOption;1617 /**18 Which stream to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.19 */20 readonly to?: ToOption;2122 /**23 Unpipe the subprocess when the signal aborts.24 */25 readonly unpipeSignal?: AbortSignal;26};27

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

lines 28–36why, one step back
28// Methods forwarded from the destination subprocess to the return value of `subprocess.pipe()`, so its output can be iterated, converted to a stream, or used for IPC.
29type PipeResultMethods<OptionsType extends Options> =30 & SubprocessResultMethods<OptionsType>31 & IpcMethods<HasIpc<OptionsType>, OptionsType['serialization']>;3233// Same as `PipeResultMethods`, but when the destination is another `execa()` call, so its own option types are kept.34// The base `Options` is only used to compute the property names, which do not depend on the specific options.35type PipeResultMethodsFrom<Destination extends ResultPromise> = Pick<Destination, keyof PipeResultMethods<Options>>;36

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 37–42why, one step back
37// `subprocess.pipe()`
38export type PipableSubprocess = {39 /**40 [Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' `stdout` to a second Execa subprocess' `stdin`. This resolves with that second subprocess' result. If either subprocess is rejected, this is rejected with that subprocess' error instead.4142 This follows the same syntax as `execa(file, arguments?, options?)` except both regular options and pipe-specific options can be specified.

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

lines 43–44why, one step back
43
44 Like a subprocess, the return value can be [iterated](https://github.com/sindresorhus/execa/blob/main/docs/lines.md#progressive-splitting), [converted to a stream](https://github.com/sindresorhus/execa/blob/main/docs/streams.md#converting-a-subprocess-to-a-stream), or used for [IPC](https://github.com/sindresorhus/execa/blob/main/docs/ipc.md) with the destination subprocess.

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 45–49why, one step back
45 */
46 pipe<OptionsType extends Options & PipeOptions = {}>(47 file: string | URL,48 arguments?: readonly string[],49 options?: OptionsType,

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

line 50why, one step back
50 ): Promise<Result<OptionsType>> & PipableSubprocess & PipeResultMethods<OptionsType>;

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 51–53why, one step back
51 pipe<OptionsType extends Options & PipeOptions = {}>(
52 file: string | URL,53 options?: OptionsType,

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

line 54why, one step back
54 ): Promise<Result<OptionsType>> & PipableSubprocess & PipeResultMethods<OptionsType>;

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 55–59why, one step back
55
56 /**57 Like `subprocess.pipe(file, arguments?, options?)` but using a `command` template string instead. This follows the same syntax as `$`.58 */59 pipe(templates: TemplateStringsArray, ...expressions: readonly TemplateExpression[]):

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

line 60why, one step back
60 Promise<Result<{}>> & PipableSubprocess & PipeResultMethods<{}>;

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 61–62why, one step back
61 pipe<OptionsType extends Options & PipeOptions = {}>(options: OptionsType):
62 (templates: TemplateStringsArray, ...expressions: readonly TemplateExpression[])

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

line 63why, one step back
63 => Promise<Result<OptionsType>> & PipableSubprocess & PipeResultMethods<OptionsType>;

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 64–68why, one step back
64
65 /**66 Like `subprocess.pipe(file, arguments?, options?)` but using the return value of another `execa()` call instead.67 */68 pipe<Destination extends ResultPromise>(destination: Destination, options?: PipeOptions):

Expose the destination subprocess methods on `.pipe()` (#1252)Sindre Sorhusbefore adoptionc31c94c

line 69why, one step back
69 Promise<Awaited<Destination>> & PipableSubprocess & PipeResultMethodsFrom<Destination>;

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 70why, one step back
70};

Ensure all `d.ts` files are considered as ESM (#1216)Sindre Sorhusbefore adoption964f650

lines 71–72why, one step back
71
72export {};