Skip to content
Myr

Make `buffer` encoding option return `Uint8Array` instead of `Buffer` (#586)

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

authored by Young · committed by GitHub · parent 248349c · Browse files · 8 files+89 added−104 removed
This commit

State

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

Trailers

  • Co-authored-by: ehmicky <ehmicky@users.noreply.github.com>

Diff stats

8 files+89 added−104 removed

  • tests:+23 added−17 removed
  • other:+66 added−87 removed

8 files+89 added−104 removed

modified:lib/command.js+2 added-3 removed
modified:lib/stream.js+3 added-3 removed
1import {once} from 'node:events';2import {setTimeout} from 'node:timers/promises';3import {finished} from 'node:stream/promises';4import getStream, {getStreamAsBuffer} from 'get-stream';4import getStream, {getStreamAsBuffer, getStreamAsArrayBuffer} from 'get-stream';5import mergeStreams from '@sindresorhus/merge-streams';67// `all` interleaves `stdout` and `stderr`8export const makeAllStream = (spawned, {all}) => {
32 unmodified lines
41 if (encoding === 'utf8' || encoding === 'utf-8') {42 return getStream(stream, {maxBuffer});43 }4445 if (encoding === null || encoding === 'buffer') {46 return getStreamAsBuffer(stream, {maxBuffer});45 if (encoding === 'buffer') {46 return getStreamAsArrayBuffer(stream, {maxBuffer}).then(arrayBuffer => new Uint8Array(arrayBuffer));47 }4849 return applyEncoding(stream, maxBuffer, encoding);50};
54 unmodified lines
modified:test/command.js+4 added-4 removed
129 unmodified lines
130 t.is(stdout, 'foo\nbar');131});132133test('$ allows execa return value buffer interpolation', async t => {134 const foo = await $({encoding: null})`echo.js foo`;134 const foo = await $({encoding: 'buffer'})`echo.js foo`;135 const {stdout} = await $`echo.js ${foo} bar`;136 t.is(stdout, 'foo\nbar');137});138139test('$ allows execa return value buffer array interpolation', async t => {140 const foo = await $({encoding: null})`echo.js foo`;140 const foo = await $({encoding: 'buffer'})`echo.js foo`;141 const {stdout} = await $`echo.js ${[foo, 'bar']}`;142 t.is(stdout, 'foo\nbar');143});144
118 unmodified lines
263 t.is(stdout, 'foo\nbar');264});265266test('$.sync allows execa return value buffer interpolation', t => {267 const foo = $({encoding: null}).sync`echo.js foo`;267 const foo = $({encoding: 'buffer'}).sync`echo.js foo`;268 const {stdout} = $.sync`echo.js ${foo} bar`;269 t.is(stdout, 'foo\nbar');270});271272test('$.sync allows execa return value buffer array interpolation', t => {273 const foo = $({encoding: null}).sync`echo.js foo`;273 const foo = $({encoding: 'buffer'}).sync`echo.js foo`;274 const {stdout} = $.sync`echo.js ${[foo, 'bar']}`;275 t.is(stdout, 'foo\nbar');276});277
63 unmodified lines
modified:test/stream.js+19 added-13 removed
20 unmodified lines
21setFixtureDir();2223const nonFileUrl = new URL('https://example.com');2425test('buffer', async t => {26 const {stdout} = await execa('noop.js', ['foo'], {encoding: null});27 t.true(Buffer.isBuffer(stdout));28 t.is(stdout.toString(), 'foo');25test('encoding option can be buffer', async t => {26 const {stdout} = await execa('noop.js', ['foo'], {encoding: 'buffer'});27 t.true(ArrayBuffer.isView(stdout));28 t.is(textDecoder.decode(stdout), 'foo');29});3031test('encoding option can be buffer - Sync', t => {32 const {stdout} = execaSync('noop.js', ['foo'], {encoding: 'buffer'});33 t.true(ArrayBuffer.isView(stdout));34 t.is(textDecoder.decode(stdout), 'foo');35});3637const checkEncoding = async (t, encoding) => {38 const {stdout} = await execa('noop-no-newline.js', [STRING_TO_ENCODE], {encoding});39 t.is(stdout, BUFFER_TO_ENCODE.toString(encoding));40
26 unmodified lines
67 t.true(BUFFER_TO_ENCODE.equals(nativeStdout));68};6970test('can pass encoding "buffer"', checkBufferEncoding, 'buffer');65test('can pass encoding null', checkBufferEncoding, null);7172test('validate unknown encodings', async t => {73 await t.throwsAsync(execa('noop.js', {encoding: 'unknownEncoding'}), {code: 'ERR_UNKNOWN_ENCODING'});74});
39 unmodified lines
114 t.is(stdout, 'foobar');115});116117const textEncoder = new TextEncoder();118const textDecoder = new TextDecoder();119const binaryFoo = textEncoder.encode('foo');120const binaryBar = textEncoder.encode('bar');121122test('stdin option can be a sync iterable of Uint8Arrays', async t => {
105 unmodified lines
228 const {stdout} = await execa('stdin.js', {input: 'foobar'});229 t.is(stdout, 'foobar');230});231232test('input option can be a Uint8Array', async t => {233 const {stdout} = await execa('stdin.js', {input: binaryFoo});234 t.is(stdout, 'foo');235});236237test('input option cannot be a String when stdin is set', t => {238 t.throws(() => {239 execa('stdin.js', {input: 'foobar', stdin: 'ignore'});240 }, {message: /`input` and `stdin` options/});
4 unmodified lines
245 execa('stdin.js', {input: 'foobar', stdio: 'ignore'});246 }, {message: /`input` and `stdin` options/});247});248238test('input option can be a Buffer', async t => {239 const {stdout} = await execa('stdin.js', {input: 'testing12'});240 t.is(stdout, 'testing12');241});242249const createNoFileReadable = value => {250 const stream = new Stream.PassThrough();251 stream.write(value);252 stream.end();
263 unmodified lines
516 const {stdout} = $({input: 'foobar'}).sync`stdin.js`;517 t.is(stdout, 'foobar');518});519514test('input option can be a Buffer - sync', t => {515 const {stdout} = execaSync('stdin.js', {input: Buffer.from('testing12', 'utf8')});516 t.is(stdout, 'testing12');520test('input option can be a Uint8Array - sync', t => {521 const {stdout} = execaSync('stdin.js', {input: binaryFoo});522 t.is(stdout, 'foo');523});524525test('opts.stdout:ignore - stdout will not collect data', async t => {526 const {stdout} = await execa('stdin.js', {
234 unmodified lines
modified:index.d.ts+8 added-10 removed
1import {type Buffer} from 'node:buffer';1import {type ChildProcess} from 'node:child_process';2import {type Stream, type Readable, type Writable} from 'node:stream';34export type StdioOption =
34 unmodified lines
39 | 'hex'40 | 'base64'41 | 'base64url'42 | 'buffer'44 | null43 | undefined;44type DefaultEncodingOption = 'utf8';47type BufferEncodingOption = 'buffer' | null;45type BufferEncodingOption = 'buffer';4647type GetStdoutStderrType<EncodingType extends EncodingOption> =50 EncodingType extends DefaultEncodingOption ? string : Buffer;48 EncodingType extends DefaultEncodingOption ? string : Uint8Array;4950export type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {51 /**52 Kill the spawned process when the parent process exits unless either:
163 unmodified lines
216 */217 readonly shell?: boolean | string;218219 /**222 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.220 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'`, then `stdout` and `stderr` will be a `Uint8Array` instead of a string.221222 @default 'utf8'223 */224 readonly encoding?: EncodingType;
116 unmodified lines
341 */342 readonly nodeOptions?: string[];343} & Options<EncodingType>;344347type StdoutStderrAll = string | Buffer | undefined;345type StdoutStderrAll = string | Uint8Array | undefined;346347export type ExecaReturnBase<StdoutStderrType extends StdoutStderrAll> = {348 /**349 The file and arguments that were run, for logging purposes.
438 unmodified lines
788789type TemplateExpression =790 | string791 | number794 | ExecaReturnValue<string | Buffer>795 | ExecaSyncReturnValue<string | Buffer>796 | Array<string | number | ExecaReturnValue<string | Buffer> | ExecaSyncReturnValue<string | Buffer>>;792 | ExecaReturnValue<string | Uint8Array>793 | ExecaSyncReturnValue<string | Uint8Array>794 | Array<string | number | ExecaReturnValue<string | Uint8Array> | ExecaSyncReturnValue<string | Uint8Array>>;795796type Execa$<StdoutStderrType extends StdoutStderrAll = string> = {797 /**798 Returns a new instance of `$` but with different default `options`. Consecutive calls are merged to previous ones.
19 unmodified lines
818 ```819 */820 (options: Options<undefined>): Execa$<StdoutStderrType>;821 (options: Options): Execa$;824 (options: Options<BufferEncodingOption>): Execa$<Buffer>;822 (options: Options<BufferEncodingOption>): Execa$<Uint8Array>;823 (824 templates: TemplateStringsArray,825 ...expressions: TemplateExpression[]826 ): ExecaChildProcess<StdoutStderrType>;
191 unmodified lines
modified:index.js+11 added-3 removed
60 unmodified lines
6162 return {file, args, options};63};6465const handleOutputSync = (options, value, error) => {66 if (Buffer.isBuffer(value)) {67 value = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);68 }6970 return handleOutput(options, value, error);71};7273const handleOutput = (options, value, error) => {66 if (typeof value !== 'string' && !Buffer.isBuffer(value)) {74 if (typeof value !== 'string' && !ArrayBuffer.isView(value)) {75 // When `execaSync()` errors, we normalize it to '' to mimic `execa()`76 return error === undefined ? undefined : '';77 }78
121 unmodified lines
200 });201 }202203 pipeOutputSync(stdioStreams, result);196 const stdout = handleOutput(parsed.options, result.stdout, result.error);197 const stderr = handleOutput(parsed.options, result.stderr, result.error);204 const stdout = handleOutputSync(parsed.options, result.stdout, result.error);205 const stderr = handleOutputSync(parsed.options, result.stderr, result.error);206207 if (result.error || result.status !== 0 || result.signal !== null) {208 const error = makeError({209 stdout,
108 unmodified lines
modified:index.test-d.ts+37 added-63 removed
1import {Buffer} from 'node:buffer';1// For some reason a default import of `process` causes2// `process.stdin`, `process.stderr`, and `process.stdout`3// to get treated as `any` by `@typescript-eslint/no-unsafe-assignment`.4import * as process from 'node:process';
23 unmodified lines
28 const writeStream = createWriteStream('output.txt');2930 expectAssignable<Function | undefined>(execaPromise.pipeStdout);31 expectType<ExecaChildProcess>(execaPromise.pipeStdout!('file.txt'));33 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeStdout!('file.txt'));32 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeStdout!('file.txt'));33 expectType<ExecaChildProcess>(execaPromise.pipeStdout!(writeStream));35 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeStdout!(writeStream));34 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeStdout!(writeStream));35 expectType<ExecaChildProcess>(execaPromise.pipeStdout!(execaPromise));37 expectType<ExecaChildProcess<Buffer>>(execaPromise.pipeStdout!(execaBufferPromise));36 expectType<ExecaChildProcess<Uint8Array>>(execaPromise.pipeStdout!(execaBufferPromise));37 expectType<ExecaChildProcess>(execaBufferPromise.pipeStdout!(execaPromise));39 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeStdout!(execaBufferPromise));38 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeStdout!(execaBufferPromise));3940 expectAssignable<Function | undefined>(execaPromise.pipeStderr);41 expectType<ExecaChildProcess>(execaPromise.pipeStderr!('file.txt'));43 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeStderr!('file.txt'));42 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeStderr!('file.txt'));43 expectType<ExecaChildProcess>(execaPromise.pipeStderr!(writeStream));45 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeStderr!(writeStream));44 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeStderr!(writeStream));45 expectType<ExecaChildProcess>(execaPromise.pipeStderr!(execaPromise));47 expectType<ExecaChildProcess<Buffer>>(execaPromise.pipeStderr!(execaBufferPromise));46 expectType<ExecaChildProcess<Uint8Array>>(execaPromise.pipeStderr!(execaBufferPromise));47 expectType<ExecaChildProcess>(execaBufferPromise.pipeStderr!(execaPromise));49 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeStderr!(execaBufferPromise));48 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeStderr!(execaBufferPromise));4950 expectAssignable<Function | undefined>(execaPromise.pipeAll);51 expectType<ExecaChildProcess>(execaPromise.pipeAll!('file.txt'));53 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeAll!('file.txt'));52 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeAll!('file.txt'));53 expectType<ExecaChildProcess>(execaPromise.pipeAll!(writeStream));55 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeAll!(writeStream));54 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeAll!(writeStream));55 expectType<ExecaChildProcess>(execaPromise.pipeAll!(execaPromise));57 expectType<ExecaChildProcess<Buffer>>(execaPromise.pipeAll!(execaBufferPromise));56 expectType<ExecaChildProcess<Uint8Array>>(execaPromise.pipeAll!(execaBufferPromise));57 expectType<ExecaChildProcess>(execaBufferPromise.pipeAll!(execaPromise));59 expectType<ExecaChildProcess<Buffer>>(execaBufferPromise.pipeAll!(execaBufferPromise));58 expectType<ExecaChildProcess<Uint8Array>>(execaBufferPromise.pipeAll!(execaBufferPromise));5960 const unicornsResult = await execaPromise;61 expectType<string>(unicornsResult.command);62 expectType<string>(unicornsResult.escapedCommand);
84 unmodified lines
147expectError(execa('unicorns', {encoding: 'unknownEncoding'}));148execa('unicorns', {execPath: '/path'});149execa('unicorns', {buffer: false});150execa('unicorns', {input: ''});152execa('unicorns', {input: Buffer.from('')});151execa('unicorns', {input: new Uint8Array()});152execa('unicorns', {input: process.stdin});153execa('unicorns', {inputFile: ''});154execa('unicorns', {stdin: 'pipe'});155execa('unicorns', {stdin: 'overlapped'});
77 unmodified lines
233expectType<ExecaReturnValue>(await execa('unicorns'));234expectType<ExecaReturnValue>(235 await execa('unicorns', {encoding: 'utf8'}),236);238expectType<ExecaReturnValue<Buffer>>(await execa('unicorns', {encoding: 'buffer'}));239expectType<ExecaReturnValue<Buffer>>(await execa('unicorns', {encoding: null}));237expectType<ExecaReturnValue<Uint8Array>>(await execa('unicorns', {encoding: 'buffer'}));238expectType<ExecaReturnValue>(239 await execa('unicorns', ['foo'], {encoding: 'utf8'}),240);243expectType<ExecaReturnValue<Buffer>>(241expectType<ExecaReturnValue<Uint8Array>>(242 await execa('unicorns', ['foo'], {encoding: 'buffer'}),243);246expectType<ExecaReturnValue<Buffer>>(247 await execa('unicorns', ['foo'], {encoding: null}),248);244245expectType<ExecaSyncReturnValue>(execaSync('unicorns'));246expectType<ExecaSyncReturnValue>(247 execaSync('unicorns', {encoding: 'utf8'}),248);254expectType<ExecaSyncReturnValue<Buffer>>(249expectType<ExecaSyncReturnValue<Uint8Array>>(250 execaSync('unicorns', {encoding: 'buffer'}),251);257expectType<ExecaSyncReturnValue<Buffer>>(258 execaSync('unicorns', {encoding: null}),259);252expectType<ExecaSyncReturnValue>(253 execaSync('unicorns', ['foo'], {encoding: 'utf8'}),254);263expectType<ExecaSyncReturnValue<Buffer>>(255expectType<ExecaSyncReturnValue<Uint8Array>>(256 execaSync('unicorns', ['foo'], {encoding: 'buffer'}),257);266expectType<ExecaSyncReturnValue<Buffer>>(267 execaSync('unicorns', ['foo'], {encoding: null}),268);258259expectType<ExecaChildProcess>(execaCommand('unicorns'));260expectType<ExecaReturnValue>(await execaCommand('unicorns'));261expectType<ExecaReturnValue>(await execaCommand('unicorns', {encoding: 'utf8'}));273expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns', {encoding: 'buffer'}));274expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns', {encoding: null}));262expectType<ExecaReturnValue<Uint8Array>>(await execaCommand('unicorns', {encoding: 'buffer'}));263expectType<ExecaReturnValue>(await execaCommand('unicorns foo', {encoding: 'utf8'}));276expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns foo', {encoding: 'buffer'}));277expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns foo', {encoding: null}));264expectType<ExecaReturnValue<Uint8Array>>(await execaCommand('unicorns foo', {encoding: 'buffer'}));265266expectType<ExecaSyncReturnValue>(execaCommandSync('unicorns'));267expectType<ExecaSyncReturnValue>(execaCommandSync('unicorns', {encoding: 'utf8'}));281expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns', {encoding: 'buffer'}));282expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns', {encoding: null}));268expectType<ExecaSyncReturnValue<Uint8Array>>(execaCommandSync('unicorns', {encoding: 'buffer'}));269expectType<ExecaSyncReturnValue>(execaCommandSync('unicorns foo', {encoding: 'utf8'}));284expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns foo', {encoding: 'buffer'}));285expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns foo', {encoding: null}));270expectType<ExecaSyncReturnValue<Uint8Array>>(execaCommandSync('unicorns foo', {encoding: 'buffer'}));271272expectType<ExecaChildProcess>(execaNode('unicorns'));273expectType<ExecaReturnValue>(await execaNode('unicorns'));274expectType<ExecaReturnValue>(275 await execaNode('unicorns', {encoding: 'utf8'}),276);292expectType<ExecaReturnValue<Buffer>>(await execaNode('unicorns', {encoding: 'buffer'}));293expectType<ExecaReturnValue<Buffer>>(await execaNode('unicorns', {encoding: null}));277expectType<ExecaReturnValue<Uint8Array>>(await execaNode('unicorns', {encoding: 'buffer'}));278expectType<ExecaReturnValue>(279 await execaNode('unicorns', ['foo'], {encoding: 'utf8'}),280);297expectType<ExecaReturnValue<Buffer>>(281expectType<ExecaReturnValue<Uint8Array>>(282 await execaNode('unicorns', ['foo'], {encoding: 'buffer'}),283);300expectType<ExecaReturnValue<Buffer>>(301 await execaNode('unicorns', ['foo'], {encoding: null}),302);284285expectType<ExecaChildProcess>(execaNode('unicorns', {nodeOptions: ['--async-stack-traces']}));286expectType<ExecaChildProcess>(execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces']}));306expectType<ExecaChildProcess<Buffer>>(287expectType<ExecaChildProcess<Uint8Array>>(288 execaNode('unicorns', {nodeOptions: ['--async-stack-traces'], encoding: 'buffer'}),289);309expectType<ExecaChildProcess<Buffer>>(310 execaNode('unicorns', {nodeOptions: ['--async-stack-traces'], encoding: null}),311);312expectType<ExecaChildProcess<Buffer>>(290expectType<ExecaChildProcess<Uint8Array>>(291 execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces'], encoding: 'buffer'}),292);315expectType<ExecaChildProcess<Buffer>>(316 execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces'], encoding: null}),317);293294expectType<ExecaChildProcess>($`unicorns`);295expectType<ExecaReturnValue>(await $`unicorns`);296expectType<ExecaSyncReturnValue>($.sync`unicorns`);
6 unmodified lines
303expectType<ExecaChildProcess>($({encoding: 'utf8'})`unicorns foo`);304expectType<ExecaReturnValue>(await $({encoding: 'utf8'})`unicorns foo`);305expectType<ExecaSyncReturnValue>($({encoding: 'utf8'}).sync`unicorns foo`);306332expectType<ExecaChildProcess<Buffer>>($({encoding: null})`unicorns`);333expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})`unicorns`);334expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})`unicorns`);335expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'}).sync`unicorns`);307expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})`unicorns`);308expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})`unicorns`);309expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'}).sync`unicorns`);310337expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})`unicorns foo`);338expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})`unicorns foo`);339expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'}).sync`unicorns foo`);311expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})`unicorns foo`);312expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})`unicorns foo`);313expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'}).sync`unicorns foo`);314315expectType<ExecaChildProcess>($({encoding: 'buffer'})({encoding: 'utf8'})`unicorns`);316expectType<ExecaReturnValue>(await $({encoding: 'buffer'})({encoding: 'utf8'})`unicorns`);317expectType<ExecaSyncReturnValue>($({encoding: 'buffer'})({encoding: 'utf8'}).sync`unicorns`);
1 unmodified line
319expectType<ExecaChildProcess>($({encoding: 'buffer'})({encoding: 'utf8'})`unicorns foo`);320expectType<ExecaReturnValue>(await $({encoding: 'buffer'})({encoding: 'utf8'})`unicorns foo`);321expectType<ExecaSyncReturnValue>($({encoding: 'buffer'})({encoding: 'utf8'}).sync`unicorns foo`);322349expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})({})`unicorns`);350expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})({})`unicorns`);351expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'})({}).sync`unicorns`);323expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})({})`unicorns`);324expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})({})`unicorns`);325expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'})({}).sync`unicorns`);326353expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})({})`unicorns foo`);354expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})({})`unicorns foo`);355expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'})({}).sync`unicorns foo`);327expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})({})`unicorns foo`);328expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})({})`unicorns foo`);329expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'})({}).sync`unicorns foo`);330331expectType<ExecaReturnValue>(await $`unicorns ${'foo'}`);332expectType<ExecaSyncReturnValue>($.sync`unicorns ${'foo'}`);333expectType<ExecaReturnValue>(await $`unicorns ${1}`);
15 unmodified lines
modified:readme.md+5 added-5 removed
398 unmodified lines
399The numeric exit code of the process that was run.400401#### stdout402403Type: `string | Buffer`403Type: `string | Uint8Array`404405The output of the process on stdout.406407#### stderr408409Type: `string | Buffer`409Type: `string | Uint8Array`410411The output of the process on stderr.412413#### all414415Type: `string | Buffer | undefined`415Type: `string | Uint8Array | undefined`416417The output of the process with `stdout` and `stderr` interleaved.418419This is `undefined` if either:
269 unmodified lines
689- unsafe, potentially allowing command injection.690691#### encoding692693Type: `string | null`\693Type: `string`\694Default: `utf8`695696Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.696Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'`, then `stdout` and `stderr` will be a `Uint8Array` instead of a string.697698#### timeout699700Type: `number`\
121 unmodified lines