Skip to content
Myr

Improve `.pipe()` method (#859)

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

authored by ehmicky · committed by GitHub · parent aeb8194 · Browse files · 11 files+159 added−113 removed
This commit

State

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

Diff stats

11 files+159 added−113 removed

  • tests:+78 added−10 removed
  • other:+81 added−103 removed

11 files+159 added−113 removed

modified:lib/pipe/sequence.js+2 added-2 removed
modified:lib/pipe/setup.js+16 added-4 removed
modified:lib/pipe/throw.js+2 added-14 removed
modified:lib/pipe/validate.js+16 added-6 removed
1import {create$} from '../script.js';2import {STANDARD_STREAMS_ALIASES} from '../utils.js';33export const normalizePipeArguments = ({source, sourcePromise, stdioStreamsGroups}, ...args) => {4export const normalizePipeArguments = ({source, sourcePromise, stdioStreamsGroups, destinationOptions}, ...args) => {5 const sourceOptions = PROCESS_OPTIONS.get(source);6 const {7 destination,8 destinationStream,9 destinationError,10 pipeOptions: {from, unpipeSignal} = {},10 } = getDestinationStream(...args);11 } = getDestinationStream(destinationOptions, ...args);12 const {sourceStream, sourceError} = getSourceStream(source, stdioStreamsGroups, from, sourceOptions);13 return {14 sourcePromise,15 sourceStream,
6 unmodified lines
22 stdioStreamsGroups,23 };24};2525const getDestinationStream = (...args) => {26const getDestinationStream = (destinationOptions, ...args) => {27 try {27 const {destination, pipeOptions} = getDestination(...args);28 const {destination, pipeOptions} = getDestination(destinationOptions, ...args);29 const destinationStream = destination.stdin;30 if (destinationStream === null) {31 throw new TypeError('The destination child process\'s stdin must be available. Please set its "stdin" option to "pipe".');32 }
3 unmodified lines
36 return {destinationError: error};37 }38};3939const getDestination = (firstArgument, ...args) => {40const getDestination = (destinationOptions, firstArgument, ...args) => {41 if (Array.isArray(firstArgument)) {42 const destination = create$({...destinationOptions, stdin: 'pipe'})(firstArgument, ...args);43 return {destination, pipeOptions: destinationOptions};44 }4546 if (!PROCESS_OPTIONS.has(firstArgument)) {41 throw new TypeError(`The first argument must be an Execa child process: ${firstArgument}`);47 throw new TypeError(`The first argument must be a template string, an options object, or an Execa child process: ${firstArgument}`);48 }4950 if (Object.keys(destinationOptions).length > 0) {51 throw new TypeError('Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).');52 }5354 return {destination: firstArgument, pipeOptions: args[0]};55};5657export const PROCESS_OPTIONS = new WeakMap();
80 unmodified lines
modified:lib/async.js+1 added-1 removed
13 unmodified lines
14import {mergePromise} from './promise.js';1516export const execa = (rawFile, rawArgs, rawOptions) => {17 const {spawned, promise, options, stdioStreamsGroups} = runExeca(rawFile, rawArgs, rawOptions);18 spawned.pipe = pipeToProcess.bind(undefined, {source: spawned, sourcePromise: promise, stdioStreamsGroups});18 spawned.pipe = pipeToProcess.bind(undefined, {source: spawned, sourcePromise: promise, stdioStreamsGroups, destinationOptions: {}});19 mergePromise(spawned, promise);20 PROCESS_OPTIONS.set(spawned, options);21 return spawned;22};
74 unmodified lines
modified:lib/script.js+2 added-32 removed
1import isPlainObject from 'is-plain-obj';2import {isBinary, binaryToString, isChildProcess} from './utils.js';3import {execa} from './async.js';4import {execaSync} from './sync.js';5import {PROCESS_OPTIONS} from './pipe/validate.js';57const create$ = options => {6export const create$ = options => {7 function $(templatesOrOptions, ...expressions) {8 if (isPlainObject(templatesOrOptions)) {9 return create$({...options, ...templatesOrOptions});10 }
2 unmodified lines
13 throw new TypeError('Please use either $(option) or $`command`.');14 }1516 const [file, ...args] = parseTemplates(templatesOrOptions, expressions);18 const childProcess = execa(file, args, normalizeScriptOptions(options));19 return scriptWithPipe(childProcess);17 return execa(file, args, normalizeScriptOptions(options));18 }1920 $.sync = (templates, ...expressions) => {21 if (isPlainObject(templates)) {
14 unmodified lines
36};3738export const $ = create$();3942const scriptWithPipe = returnValue => {43 const originalPipe = returnValue.pipe.bind(returnValue);44 const pipeMethod = (...args) => scriptWithPipe(originalPipe(...args));45 returnValue.pipe = scriptPipe.bind(undefined, pipeMethod, {});46 return returnValue;47};4849const scriptPipe = (pipeMethod, options, firstArgument, ...args) => {50 if (PROCESS_OPTIONS.has(firstArgument)) {51 if (Object.keys(options).length > 0) {52 throw new TypeError('Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).');53 }5455 return pipeMethod(firstArgument, ...args);56 }5758 if (isPlainObject(firstArgument)) {59 return scriptPipe.bind(undefined, pipeMethod, {...options, ...firstArgument});60 }6162 if (!Array.isArray(firstArgument)) {63 throw new TypeError('The first argument must be a template string, an options object, or an Execa child process.');64 }6566 const childProcess = create$({...options, stdin: 'pipe'})(firstArgument, ...args);67 return pipeMethod(childProcess, options);68};6940const parseTemplates = (templates, expressions) => {41 let tokens = [];4243 for (const [index, template] of templates.entries()) {
133 unmodified lines
modified:test/pipe/template.js+53 added-9 removed
1import {spawn} from 'node:child_process';2import test from 'ava';3import {$} from '../../index.js';3import {$, execa} from '../../index.js';4import {setFixtureDir} from '../helpers/fixtures-dir.js';5import {foobarString} from '../helpers/input.js';67setFixtureDir();
2 unmodified lines
10 const {stdout} = await $`noop.js ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`);11 t.is(stdout, foobarString);12});1314test('execa.$.pipe(childProcess)', async t => {15 const {stdout} = await execa('noop.js', [foobarString]).pipe($({stdin: 'pipe'})`stdin.js`);16 t.is(stdout, foobarString);17});1819test('$.pipe.pipe(childProcess)', async t => {20 const {stdout} = await $`noop.js ${foobarString}`21 .pipe($({stdin: 'pipe'})`stdin.js`)22 .pipe($({stdin: 'pipe'})`stdin.js`);
4 unmodified lines
27 const {stdout} = await $`noop.js ${foobarString}`.pipe`stdin.js`;28 t.is(stdout, foobarString);29});3031test('execa.$.pipe`command`', async t => {32 const {stdout} = await execa('noop.js', [foobarString]).pipe`stdin.js`;33 t.is(stdout, foobarString);34});3536test('$.pipe.pipe`command`', async t => {37 const {stdout} = await $`noop.js ${foobarString}`38 .pipe`stdin.js`39 .pipe`stdin.js`;
4 unmodified lines
44 const {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});45 t.is(stdout, foobarString);46});4748test('execa.$.pipe(childProcess, pipeOptions)', async t => {49 const {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});50 t.is(stdout, foobarString);51});5253test('$.pipe.pipe(childProcess, pipeOptions)', async t => {54 const {stdout} = await $`noop-fd.js 2 ${foobarString}`55 .pipe($({stdin: 'pipe'})`noop-stdin-fd.js 2`, {from: 'stderr'})56 .pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});
4 unmodified lines
61 const {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe({from: 'stderr'})`stdin.js`;62 t.is(stdout, foobarString);63});6465test('execa.$.pipe(pipeOptions)`command`', async t => {66 const {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe({from: 'stderr'})`stdin.js`;67 t.is(stdout, foobarString);68});6970test('$.pipe.pipe(pipeOptions)`command`', async t => {71 const {stdout} = await $`noop-fd.js 2 ${foobarString}`72 .pipe({from: 'stderr'})`noop-stdin-fd.js 2`73 .pipe({from: 'stderr'})`stdin.js`;
4 unmodified lines
78 const {stdout} = await $`noop.js ${foobarString}`.pipe({stripFinalNewline: false})`stdin.js`;79 t.is(stdout, `${foobarString}\n`);80});8182test('execa.$.pipe(options)`command`', async t => {83 const {stdout} = await execa('noop.js', [foobarString]).pipe({stripFinalNewline: false})`stdin.js`;84 t.is(stdout, `${foobarString}\n`);85});8687test('$.pipe.pipe(options)`command`', async t => {88 const {stdout} = await $`noop.js ${foobarString}`89 .pipe({})`stdin.js`90 .pipe({stripFinalNewline: false})`stdin.js`;
4 unmodified lines
95 const {stdout} = await $`noop-fd.js 2 ${foobarString}\n`.pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;96 t.is(stdout, `${foobarString}\n`);97});9899test('execa.$.pipe(pipeAndProcessOptions)`command`', async t => {100 const {stdout} = await execa('noop-fd.js', ['2', `${foobarString}\n`]).pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;101 t.is(stdout, `${foobarString}\n`);102});103104test('$.pipe.pipe(pipeAndProcessOptions)`command`', async t => {105 const {stdout} = await $`noop-fd.js 2 ${foobarString}\n`106 .pipe({from: 'stderr'})`noop-stdin-fd.js 2`107 .pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;
4 unmodified lines
112 const {stdout} = await $`noop.js ${foobarString}`.pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;113 t.is(stdout, foobarString);114});115116test('execa.$.pipe(options)(secondOptions)`command`', async t => {117 const {stdout} = await execa('noop.js', [foobarString]).pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;118 t.is(stdout, foobarString);119});120121test('$.pipe.pipe(options)(secondOptions)`command`', async t => {122 const {stdout} = await $`noop.js ${foobarString}`123 .pipe({})({})`stdin.js`124 .pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;125 t.is(stdout, foobarString);126});12793test('$.pipe(options)(childProcess) fails', t => {94 t.throws(() => {95 $`empty.js`.pipe({stdout: 'pipe'})($`empty.js`);96 }, {message: /Please use \.pipe/});128test('$.pipe(options)(childProcess) fails', async t => {129 await t.throwsAsync(130 $`empty.js`.pipe({stdout: 'pipe'})($`empty.js`),131 {message: /Please use \.pipe/},132 );133});13499const testInvalidPipe = (t, ...args) => {100 t.throws(() => {101 $`empty.js`.pipe(...args);102 }, {message: /must be a template string/});135test('execa.$.pipe(options)(childProcess) fails', async t => {136 await t.throwsAsync(137 execa('empty.js').pipe({stdout: 'pipe'})($`empty.js`),138 {message: /Please use \.pipe/},139 );140});141142const testInvalidPipe = async (t, ...args) => {143 await t.throwsAsync(144 $`empty.js`.pipe(...args),145 {message: /must be a template string/},146 );147};148149test('$.pipe(nonExecaChildProcess) fails', testInvalidPipe, spawn('node', ['--version']));150test('$.pipe(false) fails', testInvalidPipe, false);
modified:test/pipe/validate.js+25 added-1 removed
51 unmodified lines
52 'an Execa child process',53 );54};5556test('pipe() cannot pipe to non-processes', invalidDestination, () => ({stdin: new PassThrough()}));56test('pipe() cannot pipe to non-processes', invalidDestination, () => new PassThrough());57test('pipe() cannot pipe to non-Execa processes', invalidDestination, () => spawn('node', ['--version']));5859test('pipe() "from" option cannot be "stdin"', async t => {60 await assertPipeError(
3 unmodified lines
64 'not be "stdin"',65 );66});6768test('$.pipe() "from" option cannot be "stdin"', async t => {69 await assertPipeError(70 t,71 execa('empty.js')72 .pipe({from: 'stdin'})`empty.js`,73 'not be "stdin"',74 );75});7677const invalidFromOption = async (t, from) => {78 await assertPipeError(79 t,80 execa('empty.js')
75 unmodified lines
156 await source;157 t.like(await destination, {stdout: ''});158});159160test('Destination stream is ended when first argument is invalid - $', async t => {161 const pipePromise = execa('empty.js', {stdout: 'ignore'}).pipe`stdin.js`;162 await assertPipeError(t, pipePromise, 'option is incompatible');163});164165test('Source stream is aborted when second argument is invalid', async t => {166 const source = execa('noop.js', [foobarString]);167 const pipePromise = source.pipe('');168
8 unmodified lines
177 await assertPipeError(t, pipePromise, 'an Execa child process');178 t.like(await source, {stdout: undefined});179});180181test('Sets the right error message when the "all" option is incompatible - execa.$', async t => {182 await assertPipeError(183 t,184 execa('empty.js')185 .pipe({all: false})`stdin.js`186 .pipe(execa('empty.js'), {from: 'all'}),187 '"all" option must be true',188 );189});190191test('Sets the right error message when the "all" option is incompatible - execa.execa', async t => {192 await assertPipeError(193 t,194 execa('empty.js')
15 unmodified lines
modified:index.d.ts+7 added-33 removed
834 unmodified lines
835};836837type PipableProcess = {838 /**839 [Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process' `stdout` to a second Execa child process' `stdin`. This resolves with that second process' result. If either process is rejected, this is rejected with that process' error instead.840841 This can be called multiple times to chain a series of processes.842843 Multiple child processes can be piped to the same process. Conversely, the same child process can be piped to multiple other processes.844845 When using `$`, the following simpler syntax can be used instead.846847 ```js848 import {$} from 'execa';849850 await $`command`.pipe`secondCommand`;851852 // To pass either child process options or pipe options853 await $`command`.pipe(options)`secondCommand`;854 ```839 Like `.pipe(secondChildProcess)` but using a `command` template string instead. This follows the same syntax as `$`. `options` can be used to specify both pipe options and regular options.840 */856 pipe<Destination extends ExecaChildProcess>(destination: Destination, options?: PipeOptions): Promise<Awaited<Destination>> & PipableProcess;857};841 pipe(templates: TemplateStringsArray, ...expressions: TemplateExpression[]): Promise<ExecaReturnValue<{}>> & PipableProcess;842 pipe<OptionsType extends Options & PipeOptions = {}>(options: OptionsType):843 (templates: TemplateStringsArray, ...expressions: TemplateExpression[])844 => Promise<ExecaReturnValue<OptionsType>> & PipableProcess;845859type ScriptPipableProcess = {846 /**847 [Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process' `stdout` to a second Execa child process' `stdin`. This resolves with that second process' result. If either process is rejected, this is rejected with that process' error instead.848849 This can be called multiple times to chain a series of processes.850851 Multiple child processes can be piped to the same process. Conversely, the same child process can be piped to multiple other processes.866867 When using `$`, the following simpler syntax can be used instead.868869 ```js870 await $`command`.pipe`secondCommand`;871 // To pass either child process options or pipe options872 await $`command`.pipe(options)`secondCommand`;873 ```852 */875 pipe<Destination extends ExecaChildProcess>(destination: Destination, options?: PipeOptions): Promise<Awaited<Destination>> & ScriptPipableProcess;876 pipe(templates: TemplateStringsArray, ...expressions: TemplateExpression[]): Promise<ExecaReturnValue<{}>> & ScriptPipableProcess;877 pipe<OptionsType extends Options & PipeOptions = {}>(options: OptionsType):878 (templates: TemplateStringsArray, ...expressions: TemplateExpression[])879 => Promise<ExecaReturnValue<OptionsType>> & ScriptPipableProcess;853 pipe<Destination extends ExecaChildProcess>(destination: Destination, options?: PipeOptions): Promise<Awaited<Destination>> & PipableProcess;854};855856export type ExecaChildPromise<OptionsType extends Options = Options> = {857 stdin: StreamUnlessIgnored<'0', OptionsType>;
298 unmodified lines
1156 <NewOptionsType extends CommonOptions = {}>1157 (options: NewOptionsType): Execa$<OptionsType & NewOptionsType>;11581159 (templates: TemplateStringsArray, ...expressions: TemplateExpression[]):1186 Omit<ExecaChildProcess<StricterOptions<OptionsType, Options>>, 'pipe'> & ScriptPipableProcess;1160 ExecaChildProcess<StricterOptions<OptionsType, Options>> & PipableProcess;11611162 /**1163 Same as $\`command\` but synchronous.1164
191 unmodified lines
modified:index.test-d.ts+29 added-3 removed
88 unmodified lines
89 expectType<typeof bufferResult>(await execaPromise.pipe(execaBufferPromise));90 expectType<typeof bufferResult>(await scriptPromise.pipe(execaBufferPromise));91 expectNotType<typeof bufferResult>(await execaPromise.pipe(execaPromise));92 expectNotType<typeof bufferResult>(await scriptPromise.pipe(execaPromise));93 expectType<ExecaReturnValue<{}>>(await execaPromise.pipe`stdin`);94 expectType<ExecaReturnValue<{}>>(await scriptPromise.pipe`stdin`);95 expectType<typeof bufferResult>(await execaPromise.pipe(execaPromise).pipe(execaBufferPromise));96 expectType<typeof bufferResult>(await scriptPromise.pipe(execaPromise).pipe(execaBufferPromise));96 expectType <ExecaReturnValue<{}>>(await scriptPromise.pipe`stdin`.pipe`stdin`);97 expectType<ExecaReturnValue<{}>>(await execaPromise.pipe`stdin`.pipe`stdin`);98 expectType<ExecaReturnValue<{}>>(await scriptPromise.pipe`stdin`.pipe`stdin`);99 expectType<ExecaReturnValue<{}>>(await execaPromise.pipe(execaPromise).pipe`stdin`);100 expectType<ExecaReturnValue<{}>>(await scriptPromise.pipe(execaPromise).pipe`stdin`);101 expectType<typeof bufferResult>(await execaPromise.pipe`stdin`.pipe(execaBufferPromise));102 expectType<typeof bufferResult>(await scriptPromise.pipe`stdin`.pipe(execaBufferPromise));103 await execaPromise.pipe(execaPromise).pipe(execaBufferPromise, {from: 'stdout'});104 await scriptPromise.pipe(execaPromise).pipe(execaBufferPromise, {from: 'stdout'});105 await execaPromise.pipe`stdin`.pipe({from: 'stdout'})`stdin`;106 await scriptPromise.pipe`stdin`.pipe({from: 'stdout'})`stdin`;107 await execaPromise.pipe`stdin`.pipe(execaBufferPromise, {from: 'stdout'});108 await scriptPromise.pipe`stdin`.pipe(execaBufferPromise, {from: 'stdout'});109 await execaPromise.pipe(execaBufferPromise, {from: 'stdout'}).pipe`stdin`;110 await scriptPromise.pipe(execaBufferPromise, {from: 'stdout'}).pipe`stdin`;111 expectError(execaPromise.pipe(execaBufferPromise).stdout);112 expectError(scriptPromise.pipe(execaBufferPromise).stdout);113 expectError(execaPromise.pipe`stdin`.stdout);114 expectError(scriptPromise.pipe`stdin`.stdout);115 expectError(execaPromise.pipe(createWriteStream('output.txt')));116 expectError(scriptPromise.pipe(createWriteStream('output.txt')));117 expectError(execaPromise.pipe('output.txt'));118 expectError(scriptPromise.pipe('output.txt'));119 await execaPromise.pipe(execaBufferPromise, {});120 await scriptPromise.pipe(execaBufferPromise, {});121 await execaPromise.pipe({})`stdin`;122 await scriptPromise.pipe({})`stdin`;123 expectError(execaPromise.pipe(execaBufferPromise, 'stdout'));124 expectError(scriptPromise.pipe(execaBufferPromise, 'stdout'));125 expectError(execaPromise.pipe('stdout')`stdin`);126 expectError(scriptPromise.pipe('stdout')`stdin`);127 await execaPromise.pipe(execaBufferPromise, {from: 'stdout'});128 await scriptPromise.pipe(execaBufferPromise, {from: 'stdout'});129 await execaPromise.pipe({from: 'stdout'})`stdin`;130 await scriptPromise.pipe({from: 'stdout'})`stdin`;131 await execaPromise.pipe(execaBufferPromise, {from: 'stderr'});132 await scriptPromise.pipe(execaBufferPromise, {from: 'stderr'});133 await execaPromise.pipe({from: 'stderr'})`stdin`;134 await scriptPromise.pipe({from: 'stderr'})`stdin`;135 await execaPromise.pipe(execaBufferPromise, {from: 'all'});136 await scriptPromise.pipe(execaBufferPromise, {from: 'all'});137 await execaPromise.pipe({from: 'all'})`stdin`;138 await scriptPromise.pipe({from: 'all'})`stdin`;139 await execaPromise.pipe(execaBufferPromise, {from: 3});140 await scriptPromise.pipe(execaBufferPromise, {from: 3});141 await execaPromise.pipe({from: 3})`stdin`;142 await scriptPromise.pipe({from: 3})`stdin`;143 expectError(execaPromise.pipe(execaBufferPromise, {from: 'other'}));144 expectError(scriptPromise.pipe(execaBufferPromise, {from: 'other'}));145 expectError(execaPromise.pipe({from: 'other'})`stdin`);146 expectError(scriptPromise.pipe({from: 'other'})`stdin`);147 await execaPromise.pipe(execaBufferPromise, {unpipeSignal: new AbortController().signal});148 await scriptPromise.pipe(execaBufferPromise, {unpipeSignal: new AbortController().signal});149 await execaPromise.pipe({unpipeSignal: new AbortController().signal})`stdin`;150 await scriptPromise.pipe({unpipeSignal: new AbortController().signal})`stdin`;151 expectError(await execaPromise.pipe(execaBufferPromise, {unpipeSignal: true}));152 expectError(await scriptPromise.pipe(execaBufferPromise, {unpipeSignal: true}));153 expectError(await execaPromise.pipe({unpipeSignal: true})`stdin`);154 expectError(await scriptPromise.pipe({unpipeSignal: true})`stdin`);155 expectError(await execaPromise.pipe({})({}));156 expectError(await scriptPromise.pipe({})({}));157 expectError(await execaPromise.pipe({})(execaPromise));158 expectError(await scriptPromise.pipe({})(execaPromise));159139 const pipeResult = await scriptPromise.pipe`stdin`;160 const pipeResult = await execaPromise.pipe`stdin`;161 expectType<string>(pipeResult.stdout);141 const ignorePipeResult = await scriptPromise.pipe({stdout: 'ignore'})`stdin`;162 const ignorePipeResult = await execaPromise.pipe({stdout: 'ignore'})`stdin`;163 expectType<undefined>(ignorePipeResult.stdout);164165 const scriptPipeResult = await scriptPromise.pipe`stdin`;166 expectType<string>(scriptPipeResult.stdout);167 const ignoreScriptPipeResult = await scriptPromise.pipe({stdout: 'ignore'})`stdin`;168 expectType<undefined>(ignoreScriptPipeResult.stdout);169170 expectType<Readable>(execaPromise.all);171 const noAllPromise = execa('unicorns');172 expectType<undefined>(noAllPromise.all);173 const noAllResult = await noAllPromise;
1318 unmodified lines
modified:readme.md+6 added-8 removed
349 unmodified lines
350This can be called multiple times to chain a series of processes.351352Multiple child processes can be piped to the same process. Conversely, the same child process can be piped to multiple other processes.353354When using [`$`](#command), the following [simpler syntax](docs/scripts.md#piping-stdout-to-another-command) can be used instead.354#### pipe`command`355#### pipe(options)`command`356356```js357import {$} from 'execa';357`command`: `string`\358`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\359_Returns_: [`Promise<ChildProcessResult>`](#childprocessresult)360359await $`command`.pipe`secondCommand`;361Like [`.pipe(secondChildProcess)`](#pipesecondchildprocess-pipeoptions) but using a [`command` template string](docs/scripts.md#piping-stdout-to-another-command) instead. This follows the same syntax as [`$`](#command). `options` can be used to specify both [pipe options](#pipeoptions) and [regular options](#options-1).362361// To pass either child process options or pipe options362await $`command`.pipe(options)`secondCommand`;363```364363##### pipeOptions364365Type: `object`366
657 unmodified lines