Remove `execa.stdout()` and `execa.stderr()` (#234)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by ehmicky · committed by Sindre Sorhus · parent b5dfb0b · Browse files · 5 files·+7 added−93 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+7 added−93 removed
- other:+7 added−93 removed
Provenance
- Commit
3973fd4- Tree
771eab4- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
Sindre Sorhus <sindresorhus@gmail.com>- Parent
b5dfb0b
5 files changed+7 added−93 removed
modified:index.d.ts-40 removed
354 unmodified lines355 Buffer356 >;357 358 /**359- Same as `execa()`, but returns only `stdout`.360-361- @param file - The program/script to execute.362- @param arguments - Arguments to pass to `file` on execution.363- @returns The contents of the executed process' `stdout`.364- */365- stdout(366- file: string,367- arguments?: readonly string[],368- options?: execa.Options369- ): Promise<string>;370- stdout(371- file: string,372- arguments?: readonly string[],373- options?: execa.Options<null>374- ): Promise<Buffer>;375- stdout(file: string, options?: execa.Options): Promise<string>;376- stdout(file: string, options?: execa.Options<null>): Promise<Buffer>;377-378- /**379- Same as `execa()`, but returns only `stderr`.380-381- @param file - The program/script to execute.382- @param arguments - Arguments to pass to `file` on execution.383- @returns The contents of the executed process' `stderr`.384- */385- stderr(386- file: string,387- arguments?: readonly string[],388- options?: execa.Options389- ): Promise<string>;390- stderr(391- file: string,392- arguments?: readonly string[],393- options?: execa.Options<null>394- ): Promise<Buffer>;395- stderr(file: string, options?: execa.Options): Promise<string>;396- stderr(file: string, options?: execa.Options<null>): Promise<Buffer>;397-398- /**359 Execute a file synchronously.360 361 This method throws an `Error` if the command fails.362 22 unmodified linesmodified:index.js-12 removed
418 unmodified lines419 };420 421 module.exports = execa;422 423-// TODO: set `stderr: 'ignore'` when that option is implemented424-module.exports.stdout = async (...args) => {425- const {stdout} = await execa(...args);426- return stdout;427-};428-429-// TODO: set `stdout: 'ignore'` when that option is implemented430-module.exports.stderr = async (...args) => {431- const {stderr} = await execa(...args);432- return stderr;433-};434-423 module.exports.sync = (command, args, options) => {424 const parsed = handleArgs(command, args, options);425 const joinedCommand = joinCommand(command, args);426 35 unmodified linesmodified:index.test-d.ts-14 removed
112 unmodified linesExpand all1131141151161171181191201211221231241251261271281291301171181191209 unmodified lines112 unmodified linesExpand allexpectType<ExecaReturnValue<Buffer>>( await execa('unicorns', ['foo'], {encoding: null}));
expectType<Promise<string>>(execa.stdout('unicorns'));expectType<string>(await execa.stdout('unicorns'));expectType<string>(await execa.stdout('unicorns', {encoding: 'utf8'}));expectType<Buffer>(await execa.stdout('unicorns', {encoding: null}));expectType<string>(await execa.stdout('unicorns', ['foo'], {encoding: 'utf8'}));expectType<Buffer>(await execa.stdout('unicorns', ['foo'], {encoding: null}));
expectType<Promise<string>>(execa.stderr('unicorns'));expectType<string>(await execa.stderr('unicorns'));expectType<string>(await execa.stderr('unicorns', {encoding: 'utf8'}));expectType<Buffer>(await execa.stderr('unicorns', {encoding: null}));expectType<string>(await execa.stderr('unicorns', ['foo'], {encoding: 'utf8'}));expectType<Buffer>(await execa.stderr('unicorns', ['foo'], {encoding: null}));
expectType<ExecaSyncReturnValue<string>>(execa.sync('unicorns'));expectType<ExecaSyncReturnValue<string>>( execa.sync('unicorns', {encoding: 'utf8'}));9 unmodified linesmodified:readme.md-10 removed
129 unmodified lines130 The spawned process can be canceled with the `.cancel()` method on the promise, which 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.131 132 The promise result is an `Object` with `stdout`, `stderr` and `all` properties.133 134-### execa.stdout(file, [arguments], [options])135-### execa.stdout(command, [options])136-137-Same as `execa()`, but returns only `stdout`.138-139-### execa.stderr(file, [arguments], [options])140-### execa.stderr(command, [options])141-142-Same as `execa()`, but returns only `stderr`.143-134 ### execa.sync(file, [arguments], [options])135 ### execa.sync(command, [options])136 137 Execute a file synchronously.208 unmodified linesmodified:test.js+7 added-17 removed
37 unmodified lines38 t.true(Buffer.isBuffer(stdout));39 t.is(stdout.toString(), 'foo');40 });41 42-test('execa.stdout()', async t => {43- const stdout = await execa.stdout('noop', ['foo']);44- t.is(stdout, 'foo');45-});46-47-test('execa.stderr()', async t => {48- const stderr = await execa.stderr('noop-err', ['foo']);49- t.is(stderr, 'foo');50-});51-42 test.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {43 const result = await execa('noop-132');44 t.is(result.all, '132');45 });416 unmodified lines462 });463 }464 465 test('use environment variables by default', async t => {476- const result = await execa.stdout('environment');466+ const {stdout} = await execa('environment');467 478- t.deepEqual(result.split('\n'), [468+ t.deepEqual(stdout.split('\n'), [469 'foo',470 'undefined'471 ]);472 });473 474 test('extend environment variables by default', async t => {485- const result = await execa.stdout('environment', [], {env: {BAR: 'bar'}});475+ const {stdout} = await execa('environment', [], {env: {BAR: 'bar'}});476 487- t.deepEqual(result.split('\n'), [477+ t.deepEqual(stdout.split('\n'), [478 'foo',479 'bar'480 ]);481 });482 483 test('do not extend environment with `extendEnv: false`', async t => {494- const result = await execa.stdout('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});484+ const {stdout} = await execa('environment', [], {env: {BAR: 'bar', PATH: process.env.PATH}, extendEnv: false});485 496- t.deepEqual(result.split('\n'), [486+ t.deepEqual(stdout.split('\n'), [487 'undefined',488 'bar'489 ]);490 });12 unmodified lines503 504 test('use extend environment with `extendEnv: true` and `shell: true`', async t => {505 process.env.TEST = 'test';506 const command = process.platform === 'win32' ? 'echo %TEST%' : 'echo $TEST';517- const stdout = await execa.stdout(command, {shell: true, env: {}, extendEnv: true});507+ const {stdout} = await execa(command, {shell: true, env: {}, extendEnv: true});508 t.is(stdout, 'test');509 delete process.env.TEST;510 });511 136 unmodified lines