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
Provenance
- Commit
1afeb81- Tree
940be9b- Author
Young <younggglcy@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
248349c
8 files changed+89 added−104 removed
modified:lib/command.js+2 added-3 removed
1123458 unmodified lines63646566686967686970717246 unmodified linesimport {Buffer} from 'node:buffer';import {ChildProcess} from 'node:child_process';
const normalizeArgs = (file, args = []) => { if (!Array.isArray(args)) {58 unmodified lines if (typeOfStdout === 'string') { return expression.stdout; }
if (Buffer.isBuffer(expression.stdout)) { return expression.stdout.toString(); if (ArrayBuffer.isView(expression.stdout)) { return new TextDecoder().decode(expression.stdout); }
throw new TypeError(`Unexpected "${typeOfStdout}" stdout in template expression`); }46 unmodified linesmodified:lib/stream.js+3 added-3 removed
1 import {once} from 'node:events';2 import {setTimeout} from 'node:timers/promises';3 import {finished} from 'node:stream/promises';4-import getStream, {getStreamAsBuffer} from 'get-stream';4+import getStream, {getStreamAsBuffer, getStreamAsArrayBuffer} from 'get-stream';5 import mergeStreams from '@sindresorhus/merge-streams';6 7 // `all` interleaves `stdout` and `stderr`8 export const makeAllStream = (spawned, {all}) => {32 unmodified lines41 if (encoding === 'utf8' || encoding === 'utf-8') {42 return getStream(stream, {maxBuffer});43 }44 45- 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 }48 49 return applyEncoding(stream, maxBuffer, encoding);50 };54 unmodified linesmodified:test/command.js+4 added-4 removed
129 unmodified lines130 t.is(stdout, 'foo\nbar');131 });132 133 test('$ 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 });138 139 test('$ 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 lines263 t.is(stdout, 'foo\nbar');264 });265 266 test('$.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 });271 272 test('$.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 linesmodified:test/stream.js+19 added-13 removed
20 unmodified lines21 setFixtureDir();22 23 const nonFileUrl = new URL('https://example.com');24 25-test('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');25+test('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 });30 31+test('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+});36+37 const 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 lines67 t.true(BUFFER_TO_ENCODE.equals(nativeStdout));68 };69 70 test('can pass encoding "buffer"', checkBufferEncoding, 'buffer');65-test('can pass encoding null', checkBufferEncoding, null);71 72 test('validate unknown encodings', async t => {73 await t.throwsAsync(execa('noop.js', {encoding: 'unknownEncoding'}), {code: 'ERR_UNKNOWN_ENCODING'});74 });39 unmodified lines114 t.is(stdout, 'foobar');115 });116 117 const textEncoder = new TextEncoder();118+const textDecoder = new TextDecoder();119 const binaryFoo = textEncoder.encode('foo');120 const binaryBar = textEncoder.encode('bar');121 122 test('stdin option can be a sync iterable of Uint8Arrays', async t => {105 unmodified lines228 const {stdout} = await execa('stdin.js', {input: 'foobar'});229 t.is(stdout, 'foobar');230 });231 232+test('input option can be a Uint8Array', async t => {233+ const {stdout} = await execa('stdin.js', {input: binaryFoo});234+ t.is(stdout, 'foo');235+});236+237 test('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 lines245 execa('stdin.js', {input: 'foobar', stdio: 'ignore'});246 }, {message: /`input` and `stdin` options/});247 });248 238-test('input option can be a Buffer', async t => {239- const {stdout} = await execa('stdin.js', {input: 'testing12'});240- t.is(stdout, 'testing12');241-});242-249 const createNoFileReadable = value => {250 const stream = new Stream.PassThrough();251 stream.write(value);252 stream.end();263 unmodified lines516 const {stdout} = $({input: 'foobar'}).sync`stdin.js`;517 t.is(stdout, 'foobar');518 });519 514-test('input option can be a Buffer - sync', t => {515- const {stdout} = execaSync('stdin.js', {input: Buffer.from('testing12', 'utf8')});516- t.is(stdout, 'testing12');520+test('input option can be a Uint8Array - sync', t => {521+ const {stdout} = execaSync('stdin.js', {input: binaryFoo});522+ t.is(stdout, 'foo');523 });524 525 test('opts.stdout:ignore - stdout will not collect data', async t => {526 const {stdout} = await execa('stdin.js', {234 unmodified linesmodified:index.d.ts+8 added-10 removed
1-import {type Buffer} from 'node:buffer';1 import {type ChildProcess} from 'node:child_process';2 import {type Stream, type Readable, type Writable} from 'node:stream';3 4 export type StdioOption =34 unmodified lines39 | 'hex'40 | 'base64'41 | 'base64url'42 | 'buffer'44- | null43 | undefined;44 type DefaultEncodingOption = 'utf8';47-type BufferEncodingOption = 'buffer' | null;45+type BufferEncodingOption = 'buffer';46 47 type GetStdoutStderrType<EncodingType extends EncodingOption> =50- EncodingType extends DefaultEncodingOption ? string : Buffer;48+ EncodingType extends DefaultEncodingOption ? string : Uint8Array;49 50 export type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {51 /**52 Kill the spawned process when the parent process exits unless either:163 unmodified lines216 */217 readonly shell?: boolean | string;218 219 /**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.221 222 @default 'utf8'223 */224 readonly encoding?: EncodingType;116 unmodified lines341 */342 readonly nodeOptions?: string[];343 } & Options<EncodingType>;344 347-type StdoutStderrAll = string | Buffer | undefined;345+type StdoutStderrAll = string | Uint8Array | undefined;346 347 export type ExecaReturnBase<StdoutStderrType extends StdoutStderrAll> = {348 /**349 The file and arguments that were run, for logging purposes.438 unmodified lines788 789 type 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>>;795 796 type 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 lines818 ```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 linesmodified:index.js+11 added-3 removed
60 unmodified lines61 62 return {file, args, options};63 };64 65+const handleOutputSync = (options, value, error) => {66+ if (Buffer.isBuffer(value)) {67+ value = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);68+ }69+70+ return handleOutput(options, value, error);71+};72+73 const 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 lines200 });201 }202 203 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);206 207 if (result.error || result.status !== 0 || result.signal !== null) {208 const error = makeError({209 stdout,108 unmodified linesmodified:index.test-d.ts+37 added-63 removed
1-import {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`.4 import * as process from 'node:process';23 unmodified lines28 const writeStream = createWriteStream('output.txt');29 30 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));39 40 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));49 50 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));59 60 const unicornsResult = await execaPromise;61 expectType<string>(unicornsResult.command);62 expectType<string>(unicornsResult.escapedCommand);84 unmodified lines147 expectError(execa('unicorns', {encoding: 'unknownEncoding'}));148 execa('unicorns', {execPath: '/path'});149 execa('unicorns', {buffer: false});150 execa('unicorns', {input: ''});152-execa('unicorns', {input: Buffer.from('')});151+execa('unicorns', {input: new Uint8Array()});152 execa('unicorns', {input: process.stdin});153 execa('unicorns', {inputFile: ''});154 execa('unicorns', {stdin: 'pipe'});155 execa('unicorns', {stdin: 'overlapped'});77 unmodified lines233 expectType<ExecaReturnValue>(await execa('unicorns'));234 expectType<ExecaReturnValue>(235 await execa('unicorns', {encoding: 'utf8'}),236 );238-expectType<ExecaReturnValue<Buffer>>(await execa('unicorns', {encoding: 'buffer'}));239-expectType<ExecaReturnValue<Buffer>>(await execa('unicorns', {encoding: null}));237+expectType<ExecaReturnValue<Uint8Array>>(await execa('unicorns', {encoding: 'buffer'}));238 expectType<ExecaReturnValue>(239 await execa('unicorns', ['foo'], {encoding: 'utf8'}),240 );243-expectType<ExecaReturnValue<Buffer>>(241+expectType<ExecaReturnValue<Uint8Array>>(242 await execa('unicorns', ['foo'], {encoding: 'buffer'}),243 );246-expectType<ExecaReturnValue<Buffer>>(247- await execa('unicorns', ['foo'], {encoding: null}),248-);244 245 expectType<ExecaSyncReturnValue>(execaSync('unicorns'));246 expectType<ExecaSyncReturnValue>(247 execaSync('unicorns', {encoding: 'utf8'}),248 );254-expectType<ExecaSyncReturnValue<Buffer>>(249+expectType<ExecaSyncReturnValue<Uint8Array>>(250 execaSync('unicorns', {encoding: 'buffer'}),251 );257-expectType<ExecaSyncReturnValue<Buffer>>(258- execaSync('unicorns', {encoding: null}),259-);252 expectType<ExecaSyncReturnValue>(253 execaSync('unicorns', ['foo'], {encoding: 'utf8'}),254 );263-expectType<ExecaSyncReturnValue<Buffer>>(255+expectType<ExecaSyncReturnValue<Uint8Array>>(256 execaSync('unicorns', ['foo'], {encoding: 'buffer'}),257 );266-expectType<ExecaSyncReturnValue<Buffer>>(267- execaSync('unicorns', ['foo'], {encoding: null}),268-);258 259 expectType<ExecaChildProcess>(execaCommand('unicorns'));260 expectType<ExecaReturnValue>(await execaCommand('unicorns'));261 expectType<ExecaReturnValue>(await execaCommand('unicorns', {encoding: 'utf8'}));273-expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns', {encoding: 'buffer'}));274-expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns', {encoding: null}));262+expectType<ExecaReturnValue<Uint8Array>>(await execaCommand('unicorns', {encoding: 'buffer'}));263 expectType<ExecaReturnValue>(await execaCommand('unicorns foo', {encoding: 'utf8'}));276-expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns foo', {encoding: 'buffer'}));277-expectType<ExecaReturnValue<Buffer>>(await execaCommand('unicorns foo', {encoding: null}));264+expectType<ExecaReturnValue<Uint8Array>>(await execaCommand('unicorns foo', {encoding: 'buffer'}));265 266 expectType<ExecaSyncReturnValue>(execaCommandSync('unicorns'));267 expectType<ExecaSyncReturnValue>(execaCommandSync('unicorns', {encoding: 'utf8'}));281-expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns', {encoding: 'buffer'}));282-expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns', {encoding: null}));268+expectType<ExecaSyncReturnValue<Uint8Array>>(execaCommandSync('unicorns', {encoding: 'buffer'}));269 expectType<ExecaSyncReturnValue>(execaCommandSync('unicorns foo', {encoding: 'utf8'}));284-expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns foo', {encoding: 'buffer'}));285-expectType<ExecaSyncReturnValue<Buffer>>(execaCommandSync('unicorns foo', {encoding: null}));270+expectType<ExecaSyncReturnValue<Uint8Array>>(execaCommandSync('unicorns foo', {encoding: 'buffer'}));271 272 expectType<ExecaChildProcess>(execaNode('unicorns'));273 expectType<ExecaReturnValue>(await execaNode('unicorns'));274 expectType<ExecaReturnValue>(275 await execaNode('unicorns', {encoding: 'utf8'}),276 );292-expectType<ExecaReturnValue<Buffer>>(await execaNode('unicorns', {encoding: 'buffer'}));293-expectType<ExecaReturnValue<Buffer>>(await execaNode('unicorns', {encoding: null}));277+expectType<ExecaReturnValue<Uint8Array>>(await execaNode('unicorns', {encoding: 'buffer'}));278 expectType<ExecaReturnValue>(279 await execaNode('unicorns', ['foo'], {encoding: 'utf8'}),280 );297-expectType<ExecaReturnValue<Buffer>>(281+expectType<ExecaReturnValue<Uint8Array>>(282 await execaNode('unicorns', ['foo'], {encoding: 'buffer'}),283 );300-expectType<ExecaReturnValue<Buffer>>(301- await execaNode('unicorns', ['foo'], {encoding: null}),302-);284 285 expectType<ExecaChildProcess>(execaNode('unicorns', {nodeOptions: ['--async-stack-traces']}));286 expectType<ExecaChildProcess>(execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces']}));306-expectType<ExecaChildProcess<Buffer>>(287+expectType<ExecaChildProcess<Uint8Array>>(288 execaNode('unicorns', {nodeOptions: ['--async-stack-traces'], encoding: 'buffer'}),289 );309-expectType<ExecaChildProcess<Buffer>>(310- execaNode('unicorns', {nodeOptions: ['--async-stack-traces'], encoding: null}),311-);312-expectType<ExecaChildProcess<Buffer>>(290+expectType<ExecaChildProcess<Uint8Array>>(291 execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces'], encoding: 'buffer'}),292 );315-expectType<ExecaChildProcess<Buffer>>(316- execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces'], encoding: null}),317-);293 294 expectType<ExecaChildProcess>($`unicorns`);295 expectType<ExecaReturnValue>(await $`unicorns`);296 expectType<ExecaSyncReturnValue>($.sync`unicorns`);6 unmodified lines303 expectType<ExecaChildProcess>($({encoding: 'utf8'})`unicorns foo`);304 expectType<ExecaReturnValue>(await $({encoding: 'utf8'})`unicorns foo`);305 expectType<ExecaSyncReturnValue>($({encoding: 'utf8'}).sync`unicorns foo`);306 332-expectType<ExecaChildProcess<Buffer>>($({encoding: null})`unicorns`);333-expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})`unicorns`);334-expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})`unicorns`);335-expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'}).sync`unicorns`);307+expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})`unicorns`);308+expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})`unicorns`);309+expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'}).sync`unicorns`);310 337-expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})`unicorns foo`);338-expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})`unicorns foo`);339-expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'}).sync`unicorns foo`);311+expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})`unicorns foo`);312+expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})`unicorns foo`);313+expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'}).sync`unicorns foo`);314 315 expectType<ExecaChildProcess>($({encoding: 'buffer'})({encoding: 'utf8'})`unicorns`);316 expectType<ExecaReturnValue>(await $({encoding: 'buffer'})({encoding: 'utf8'})`unicorns`);317 expectType<ExecaSyncReturnValue>($({encoding: 'buffer'})({encoding: 'utf8'}).sync`unicorns`);1 unmodified line319 expectType<ExecaChildProcess>($({encoding: 'buffer'})({encoding: 'utf8'})`unicorns foo`);320 expectType<ExecaReturnValue>(await $({encoding: 'buffer'})({encoding: 'utf8'})`unicorns foo`);321 expectType<ExecaSyncReturnValue>($({encoding: 'buffer'})({encoding: 'utf8'}).sync`unicorns foo`);322 349-expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})({})`unicorns`);350-expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})({})`unicorns`);351-expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'})({}).sync`unicorns`);323+expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})({})`unicorns`);324+expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})({})`unicorns`);325+expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'})({}).sync`unicorns`);326 353-expectType<ExecaChildProcess<Buffer>>($({encoding: 'buffer'})({})`unicorns foo`);354-expectType<ExecaReturnValue<Buffer>>(await $({encoding: 'buffer'})({})`unicorns foo`);355-expectType<ExecaSyncReturnValue<Buffer>>($({encoding: 'buffer'})({}).sync`unicorns foo`);327+expectType<ExecaChildProcess<Uint8Array>>($({encoding: 'buffer'})({})`unicorns foo`);328+expectType<ExecaReturnValue<Uint8Array>>(await $({encoding: 'buffer'})({})`unicorns foo`);329+expectType<ExecaSyncReturnValue<Uint8Array>>($({encoding: 'buffer'})({}).sync`unicorns foo`);330 331 expectType<ExecaReturnValue>(await $`unicorns ${'foo'}`);332 expectType<ExecaSyncReturnValue>($.sync`unicorns ${'foo'}`);333 expectType<ExecaReturnValue>(await $`unicorns ${1}`);15 unmodified linesmodified:readme.md+5 added-5 removed
398 unmodified lines399 The numeric exit code of the process that was run.400 401 #### stdout402 403-Type: `string | Buffer`403+Type: `string | Uint8Array`404 405 The output of the process on stdout.406 407 #### stderr408 409-Type: `string | Buffer`409+Type: `string | Uint8Array`410 411 The output of the process on stderr.412 413 #### all414 415-Type: `string | Buffer | undefined`415+Type: `string | Uint8Array | undefined`416 417 The output of the process with `stdout` and `stderr` interleaved.418 419 This is `undefined` if either:269 unmodified lines689 - unsafe, potentially allowing command injection.690 691 #### encoding692 693-Type: `string | null`\693+Type: `string`\694 Default: `utf8`695 696-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.696+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.697 698 #### timeout699 700 Type: `number`\121 unmodified lines