Remove `execaCommand()` and `execaCommandSync()` (#1244)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sindre Sorhus · committed by GitHub · parent 04b4454 · Browse files · 11 files·+20 added−353 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+20 added−353 removed
- tests:+15 added−133 removed
- other:+5 added−220 removed
Provenance
- Commit
3ced394- Tree
e5399fd- Author
Sindre Sorhus <sindresorhus@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
04b4454
11 files changed+20 added−353 removed
modified:lib/methods/command.js-16 removed
12345678910111213141516123423 unmodified lines// Main logic for `execaCommand()`export const mapCommandAsync = ({file, commandArguments}) => parseCommand(file, commandArguments);
// Main logic for `execaCommandSync()`export const mapCommandSync = ({file, commandArguments}) => ({...parseCommand(file, commandArguments), isSync: true});
// Convert `execaCommand(command)` into `execa(file, ...commandArguments)`const parseCommand = (command, unusedArguments) => { if (unusedArguments.length > 0) { throw new TypeError(`The command and its arguments must be passed as a single string: ${command} ${unusedArguments}.`); }
const [file, ...commandArguments] = parseCommandString(command); return {file, commandArguments};};
// Convert `command` string into an array of file or arguments to pass to $`${...fileOrCommandArguments}`export const parseCommandString = command => { if (typeof command !== 'string') { throw new TypeError(`The command must be a string: ${String(command)}.`);23 unmodified linesmodified:lib/methods/create.js+3 added-5 removed
49 unmodified lines5051525354555455585657606158596061626349 unmodified lines : [firstArgument, ...nextArguments]; const [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments); const mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions); const { file = initialFile, commandArguments = initialArguments, options = mergedOptions, isSync = false, } = mapArguments({file: initialFile, commandArguments: initialArguments, options: mergedOptions}); } = mapArguments({options: mergedOptions}); return { file, commandArguments, file: initialFile, commandArguments: initialArguments, options, isSync, };};modified:test/methods/command.js+15 added-107 removed
1-import path from 'node:path';1 import test from 'ava';2 import {3 execa,4 execaSync,5 $,6 execaNode,8- execaCommand,9- execaCommandSync,7 parseCommandString,8 } from '../../index.js';9 import {10 setFixtureDirectory,14- FIXTURES_DIRECTORY,11 FIXTURES_DIRECTORY_URL,12 } from '../helpers/fixtures-directory.js';17-import {QUOTE} from '../helpers/verbose.js';13 14 setFixtureDirectory();20-const STDIN_FIXTURE = path.join(FIXTURES_DIRECTORY, 'stdin.js');15 const ECHO_FIXTURE_URL = new URL('echo.js', FIXTURES_DIRECTORY_URL);16 17 const parseAndRunCommand = command => execa`${parseCommandString(command)}`;18 25-test('execaCommand()', async t => {26- const {stdout} = await execaCommand('echo.js foo bar');27- t.is(stdout, 'foo\nbar');28-});29-19 test('parseCommandString() + execa()', async t => {20 const {stdout} = await execa('echo.js', parseCommandString('foo bar'));21 t.is(stdout, 'foo\nbar');22 });23 35-test('execaCommandSync()', t => {36- const {stdout} = execaCommandSync('echo.js foo bar');37- t.is(stdout, 'foo\nbar');38-});39-24 test('parseCommandString() + execaSync()', t => {25 const {stdout} = execaSync('echo.js', parseCommandString('foo bar'));26 t.is(stdout, 'foo\nbar');27 });28 45-test('execaCommand`...`', async t => {46- const {stdout} = await execaCommand`${'echo.js foo bar'}`;47- t.is(stdout, 'foo\nbar');48-});49-29 test('parseCommandString() + execa`...`', async t => {30 const {stdout} = await execa`${parseCommandString('echo.js foo bar')}`;31 t.is(stdout, 'foo\nbar');32 });7 unmodified lines40 const {stdout} = await execa`echo.js ${'foo bar'} ${parseCommandString('foo bar')}`;41 t.is(stdout, 'foo bar\nfoo\nbar');42 });43 65-test('execaCommandSync`...`', t => {66- const {stdout} = execaCommandSync`${'echo.js foo bar'}`;67- t.is(stdout, 'foo\nbar');68-});69-44 test('parseCommandString() + execaSync`...`', t => {45 const {stdout} = execaSync`${parseCommandString('echo.js foo bar')}`;46 t.is(stdout, 'foo\nbar');47 });22 unmodified lines70 const {stdout} = await execaNode(ECHO_FIXTURE_URL, parseCommandString('foo bar'));71 t.is(stdout, 'foo\nbar');72 });73 100-test('execaCommand(options)`...`', async t => {101- const {stdout} = await execaCommand({stripFinalNewline: false})`${'echo.js foo bar'}`;102- t.is(stdout, 'foo\nbar\n');103-});104-105-test('execaCommandSync(options)`...`', t => {106- const {stdout} = execaCommandSync({stripFinalNewline: false})`${'echo.js foo bar'}`;107- t.is(stdout, 'foo\nbar\n');108-});109-110-test('execaCommand(options)()', async t => {111- const {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar');112- t.is(stdout, 'foo\nbar\n');113-});114-115-test('execaCommandSync(options)()', t => {116- const {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar');117- t.is(stdout, 'foo\nbar\n');118-});119-120-test('execaCommand().pipe(execaCommand())', async t => {121- const {stdout} = await execaCommand('echo.js foo bar').pipe(execaCommand(`node ${STDIN_FIXTURE}`));122- t.is(stdout, 'foo\nbar');123-});124-125-test('execaCommand().pipe(...) does not use execaCommand', async t => {126- const {escapedCommand} = await execaCommand('echo.js foo bar').pipe(`node ${STDIN_FIXTURE}`, {reject: false});127- t.true(escapedCommand.startsWith(`${QUOTE}node `));128-});129-130-test('execaCommand() bound options have lower priority', async t => {131- const {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar', {stripFinalNewline: true});132- t.is(stdout, 'foo\nbar');133-});134-135-test('execaCommandSync() bound options have lower priority', t => {136- const {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar', {stripFinalNewline: true});137- t.is(stdout, 'foo\nbar');138-});139-140-const testInvalidArgumentsArray = (t, execaMethod) => {141- t.throws(() => execaMethod('echo', ['foo']), {142- message: /The command and its arguments must be passed as a single string/,143- });144-};145-146-test('execaCommand() must not pass an array of arguments', testInvalidArgumentsArray, execaCommand);147-test('execaCommandSync() must not pass an array of arguments', testInvalidArgumentsArray, execaCommandSync);148-149-const testInvalidArgumentsTemplate = (t, execaMethod) => {150- t.throws(() => execaMethod`echo foo`, {151- message: /The command and its arguments must be passed as a single string/,152- });153-};154-155-test('execaCommand() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommand);156-test('execaCommandSync() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommandSync);157-74 const testInvalidArgumentsParse = (t, command) => {75 t.throws(() => parseCommandString(command), {76 message: /The command must be a string/,77 });78 };79 164-test('execaCommand() must not pass a number', testInvalidArgumentsParse, 0);165-test('execaCommand() must not pass undefined', testInvalidArgumentsParse, undefined);166-test('execaCommand() must not pass null', testInvalidArgumentsParse, null);167-test('execaCommand() must not pass a symbol', testInvalidArgumentsParse, Symbol('test'));168-test('execaCommand() must not pass an object', testInvalidArgumentsParse, {});169-test('execaCommand() must not pass an array', testInvalidArgumentsParse, []);80+test('parseCommandString() must not pass a number', testInvalidArgumentsParse, 0);81+test('parseCommandString() must not pass undefined', testInvalidArgumentsParse, undefined);82+test('parseCommandString() must not pass null', testInvalidArgumentsParse, null);83+test('parseCommandString() must not pass a symbol', testInvalidArgumentsParse, Symbol('test'));84+test('parseCommandString() must not pass an object', testInvalidArgumentsParse, {});85+test('parseCommandString() must not pass an array', testInvalidArgumentsParse, []);86 171-const testExecaCommandOutput = async (t, command, expectedOutput, execaMethod) => {87+const testParseCommandOutput = async (t, command, expectedOutput, execaMethod) => {88 const {stdout} = await execaMethod(command);89 t.is(stdout, expectedOutput);90 };91 176-test('execaCommand() allows escaping spaces in commands', testExecaCommandOutput, 'command\\ with\\ space.js foo bar', 'foo\nbar', execaCommand);177-test('execaCommand() trims', testExecaCommandOutput, ' echo.js foo bar ', 'foo\nbar', execaCommand);178-test('execaCommand() ignores consecutive spaces', testExecaCommandOutput, 'echo.js foo bar', 'foo\nbar', execaCommand);179-test('execaCommand() escapes other whitespaces', testExecaCommandOutput, 'echo.js foo\tbar', 'foo\tbar', execaCommand);180-test('execaCommand() allows escaping spaces', testExecaCommandOutput, 'echo.js foo\\ bar', 'foo bar', execaCommand);181-test('execaCommand() allows escaping backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\ bar', 'foo\\ bar', execaCommand);182-test('execaCommand() allows escaping multiple backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\\\ bar', execaCommand);183-test('execaCommand() allows escaping backslashes not before spaces', testExecaCommandOutput, 'echo.js foo\\bar baz', 'foo\\bar\nbaz', execaCommand);184-test('parseCommandString() allows escaping spaces in commands', testExecaCommandOutput, 'command\\ with\\ space.js foo bar', 'foo\nbar', parseAndRunCommand);185-test('parseCommandString() trims', testExecaCommandOutput, ' echo.js foo bar ', 'foo\nbar', parseAndRunCommand);186-test('parseCommandString() ignores consecutive spaces', testExecaCommandOutput, 'echo.js foo bar', 'foo\nbar', parseAndRunCommand);187-test('parseCommandString() escapes other whitespaces', testExecaCommandOutput, 'echo.js foo\tbar', 'foo\tbar', parseAndRunCommand);188-test('parseCommandString() allows escaping spaces', testExecaCommandOutput, 'echo.js foo\\ bar', 'foo bar', parseAndRunCommand);189-test('parseCommandString() allows escaping backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\ bar', 'foo\\ bar', parseAndRunCommand);190-test('parseCommandString() allows escaping multiple backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\\\ bar', parseAndRunCommand);191-test('parseCommandString() allows escaping backslashes not before spaces', testExecaCommandOutput, 'echo.js foo\\bar baz', 'foo\\bar\nbaz', parseAndRunCommand);92+test('parseCommandString() allows escaping spaces in commands', testParseCommandOutput, 'command\\ with\\ space.js foo bar', 'foo\nbar', parseAndRunCommand);93+test('parseCommandString() trims', testParseCommandOutput, ' echo.js foo bar ', 'foo\nbar', parseAndRunCommand);94+test('parseCommandString() ignores consecutive spaces', testParseCommandOutput, 'echo.js foo bar', 'foo\nbar', parseAndRunCommand);95+test('parseCommandString() escapes other whitespaces', testParseCommandOutput, 'echo.js foo\tbar', 'foo\tbar', parseAndRunCommand);96+test('parseCommandString() allows escaping spaces', testParseCommandOutput, 'echo.js foo\\ bar', 'foo bar', parseAndRunCommand);97+test('parseCommandString() allows escaping backslashes before spaces', testParseCommandOutput, 'echo.js foo\\\\ bar', 'foo\\ bar', parseAndRunCommand);98+test('parseCommandString() allows escaping multiple backslashes before spaces', testParseCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\\\ bar', parseAndRunCommand);99+test('parseCommandString() allows escaping backslashes not before spaces', testParseCommandOutput, 'echo.js foo\\bar baz', 'foo\\bar\nbaz', parseAndRunCommand);100 101 test('parseCommandString() can get empty strings', t => {102 t.deepEqual(parseCommandString(''), []);103 });5 unmodified linesmodified:test/methods/parameters-args.js-8 removed
12345656787 unmodified lines161718192223202122234 unmodified lines282930313637323334354 unmodified lines404142435051444546import test from 'ava';import { execa, execaSync, execaCommand, execaCommandSync, execaNode, $,} from '../../index.js';import {setFixtureDirectory} from '../helpers/fixtures-directory.js';7 unmodified lines};
test('execa()\'s second argument must be valid', testInvalidArguments, execa);test('execaSync()\'s second argument must be valid', testInvalidArguments, execaSync);test('execaCommand()\'s second argument must be valid', testInvalidArguments, execaCommand);test('execaCommandSync()\'s second argument must be valid', testInvalidArguments, execaCommandSync);test('execaNode()\'s second argument must be valid', testInvalidArguments, execaNode);test('$\'s second argument must be valid', testInvalidArguments, $);test('$.sync\'s second argument must be valid', testInvalidArguments, $.sync);
4 unmodified lines};
test('execa()\'s second argument must not be objects', testInvalidArgumentsItems, execa);test('execaSync()\'s second argument must not be objects', testInvalidArgumentsItems, execaSync);test('execaCommand()\'s second argument must not be objects', testInvalidArgumentsItems, execaCommand);test('execaCommandSync()\'s second argument must not be objects', testInvalidArgumentsItems, execaCommandSync);test('execaNode()\'s second argument must not be objects', testInvalidArgumentsItems, execaNode);test('$\'s second argument must not be objects', testInvalidArgumentsItems, $);test('$.sync\'s second argument must not be objects', testInvalidArgumentsItems, $.sync);
4 unmodified lines};
test('execa()\'s second argument must not include \\0', testNullByteArgument, execa);test('execaSync()\'s second argument must not include \\0', testNullByteArgument, execaSync);test('execaCommand()\'s second argument must not include \\0', testNullByteArgument, execaCommand);test('execaCommandSync()\'s second argument must not include \\0', testNullByteArgument, execaCommandSync);test('execaNode()\'s second argument must not include \\0', testNullByteArgument, execaNode);test('$\'s second argument must not include \\0', testNullByteArgument, $);test('$.sync\'s second argument must not include \\0', testNullByteArgument, $.sync);modified:test/methods/parameters-command.js-14 removed
2 unmodified lines3 import test from 'ava';4 import {5 execa,6 execaSync,7- execaCommand,8- execaCommandSync,7 execaNode,8 $,9 } from '../../index.js';10 import {setFixtureDirectory, FIXTURES_DIRECTORY_URL} from '../helpers/fixtures-directory.js';8 unmodified lines19 };20 21 test('execa()\'s command argument can be a file URL', testFileUrl, execa);22 test('execaSync()\'s command argument can be a file URL', testFileUrl, execaSync);25-test('execaCommand()\'s command argument can be a file URL', testFileUrl, execaCommand);26-test('execaCommandSync()\'s command argument can be a file URL', testFileUrl, execaCommandSync);23 test('execaNode()\'s command argument can be a file URL', testFileUrl, execaNode);24 test('$\'s command argument can be a file URL', testFileUrl, $);25 test('$.sync\'s command argument can be a file URL', testFileUrl, $.sync);26 5 unmodified lines32 };33 34 test('execa()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execa);35 test('execaSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaSync);40-test('execaCommand()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommand);41-test('execaCommandSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommandSync);36 test('execaNode()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaNode);37 test('$\'s command argument cannot be a non-file URL', testInvalidFileUrl, $);38 test('$.sync\'s command argument cannot be a non-file URL', testInvalidFileUrl, $.sync);39 4 unmodified lines44 };45 46 test('execa()\'s first argument must be defined', testInvalidCommand, undefined, execa);47 test('execaSync()\'s first argument must be defined', testInvalidCommand, undefined, execaSync);54-test('execaCommand()\'s first argument must be defined', testInvalidCommand, undefined, execaCommand);55-test('execaCommandSync()\'s first argument must be defined', testInvalidCommand, undefined, execaCommandSync);48 test('execaNode()\'s first argument must be defined', testInvalidCommand, undefined, execaNode);49 test('$\'s first argument must be defined', testInvalidCommand, undefined, $);50 test('$.sync\'s first argument must be defined', testInvalidCommand, undefined, $.sync);51 test('execa()\'s first argument must be valid', testInvalidCommand, true, execa);52 test('execaSync()\'s first argument must be valid', testInvalidCommand, true, execaSync);61-test('execaCommand()\'s first argument must be valid', testInvalidCommand, true, execaCommand);62-test('execaCommandSync()\'s first argument must be valid', testInvalidCommand, true, execaCommandSync);53 test('execaNode()\'s first argument must be valid', testInvalidCommand, true, execaNode);54 test('$\'s first argument must be valid', testInvalidCommand, true, $);55 test('$.sync\'s first argument must be valid', testInvalidCommand, true, $.sync);56 test('execa()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execa);57 test('execaSync()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaSync);68-test('execaCommand()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommand);69-test('execaCommandSync()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommandSync);58 test('execaNode()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaNode);59 test('$\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $);60 test('$.sync\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $.sync);61 6 unmodified lines68 };69 70 test('execa() use relative path with \'..\' chars', testRelativePath, execa);71 test('execaSync() use relative path with \'..\' chars', testRelativePath, execaSync);84-test('execaCommand() use relative path with \'..\' chars', testRelativePath, execaCommand);85-test('execaCommandSync() use relative path with \'..\' chars', testRelativePath, execaCommandSync);72 test('execaNode() use relative path with \'..\' chars', testRelativePath, execaNode);73 test('$ use relative path with \'..\' chars', testRelativePath, $);74 test('$.sync use relative path with \'..\' chars', testRelativePath, $.sync);modified:test/methods/parameters-options.js-4 removed
1 unmodified line2 import test from 'ava';3 import {4 execa,5 execaSync,6- execaCommand,7- execaCommandSync,6 execaNode,7 $,8 } from '../../index.js';9 import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';55 unmodified lines65 };66 67 test('execa()\'s third argument must be a plain object', testInvalidOptions, execa);68 test('execaSync()\'s third argument must be a plain object', testInvalidOptions, execaSync);71-test('execaCommand()\'s third argument must be a plain object', testInvalidOptions, execaCommand);72-test('execaCommandSync()\'s third argument must be a plain object', testInvalidOptions, execaCommandSync);69 test('execaNode()\'s third argument must be a plain object', testInvalidOptions, execaNode);70 test('$\'s third argument must be a plain object', testInvalidOptions, $);71 test('$.sync\'s third argument must be a plain object', testInvalidOptions, $.sync);modified:test-d/methods/command.test-d.ts+1 added-97 removed
1-import {expectType, expectError, expectAssignable} from 'tsd';1+import {expectType, expectError} from 'tsd';2 import {3 execa,4 execaSync,5 $,6 execaNode,7- execaCommand,8- execaCommandSync,7 parseCommandString,8 type Result,11- type ResultPromise,9 type SyncResult,10 } from '../../index.js';11 15-const fileUrl = new URL('file:///test');16-const stringArray = ['foo', 'bar'] as const;17-12 expectError(parseCommandString());13 expectError(parseCommandString(true));14 expectError(parseCommandString(['unicorns', 'arg']));15 8 unmodified lines24 25 expectType<Result<{}>>(await execa`unicorns ${parseCommandString('foo bar')}`);26 expectType<Result<{}>>(await execa('unicorns', parseCommandString('foo bar')));27 expectType<Result<{}>>(await execa('unicorns', ['foo', ...parseCommandString('bar')]));34-35-expectError(execaCommand());36-expectError(execaCommand(true));37-expectError(execaCommand(['unicorns', 'arg']));38-expectAssignable<ResultPromise>(execaCommand('unicorns'));39-expectError(execaCommand(fileUrl));40-41-expectError(execaCommand('unicorns', []));42-expectError(execaCommand('unicorns', ['foo']));43-expectError(execaCommand('unicorns', 'foo'));44-expectError(execaCommand('unicorns', [true]));45-46-expectAssignable<ResultPromise>(execaCommand('unicorns', {}));47-expectError(execaCommand('unicorns', [], {}));48-expectError(execaCommand('unicorns', [], []));49-expectError(execaCommand('unicorns', {other: true}));50-51-expectAssignable<ResultPromise>(execaCommand`unicorns`);52-expectType<Result<{}>>(await execaCommand('unicorns'));53-expectType<Result<{}>>(await execaCommand`unicorns`);54-55-expectAssignable<typeof execaCommand>(execaCommand({}));56-expectAssignable<ResultPromise>(execaCommand({})('unicorns'));57-expectAssignable<ResultPromise>(execaCommand({})`unicorns`);58-59-expectAssignable<{stdout: string}>(await execaCommand('unicorns'));60-expectAssignable<{stdout: Uint8Array}>(await execaCommand('unicorns', {encoding: 'buffer'}));61-expectAssignable<{stdout: string}>(await execaCommand({})('unicorns'));62-expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})('unicorns'));63-expectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})('unicorns'));64-expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})('unicorns'));65-expectAssignable<{stdout: string}>(await execaCommand({})`unicorns`);66-expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})`unicorns`);67-expectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})`unicorns`);68-expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})`unicorns`);69-70-expectType<Result<{}>>(await execaCommand`${'unicorns'}`);71-expectType<Result<{}>>(await execaCommand`unicorns ${'foo'}`);72-expectError(await execaCommand`unicorns ${'foo'} ${'bar'}`);73-expectError(await execaCommand`unicorns ${1}`);74-expectError(await execaCommand`unicorns ${stringArray}`);75-expectError(await execaCommand`unicorns ${[1, 2]}`);76-expectType<Result<{}>>(await execaCommand`unicorns ${false.toString()}`);77-expectError(await execaCommand`unicorns ${false}`);78-79-expectError(await execaCommand`unicorns ${await execaCommand`echo foo`}`);80-expectError(await execaCommand`unicorns ${await execaCommand({reject: false})`echo foo`}`);81-expectError(await execaCommand`unicorns ${execaCommand`echo foo`}`);82-expectError(await execaCommand`unicorns ${[await execaCommand`echo foo`, 'bar']}`);83-expectError(await execaCommand`unicorns ${[execaCommand`echo foo`, 'bar']}`);84-85-expectError(execaCommandSync());86-expectError(execaCommandSync(true));87-expectError(execaCommandSync(['unicorns', 'arg']));88-expectType<SyncResult<{}>>(execaCommandSync('unicorns'));89-expectError(execaCommandSync(fileUrl));90-expectError(execaCommandSync('unicorns', []));91-expectError(execaCommandSync('unicorns', ['foo']));92-expectType<SyncResult<{}>>(execaCommandSync('unicorns', {}));93-expectError(execaCommandSync('unicorns', [], {}));94-expectError(execaCommandSync('unicorns', 'foo'));95-expectError(execaCommandSync('unicorns', [true]));96-expectError(execaCommandSync('unicorns', [], []));97-expectError(execaCommandSync('unicorns', {other: true}));98-expectType<SyncResult<{}>>(execaCommandSync`unicorns`);99-expectAssignable<typeof execaCommandSync>(execaCommandSync({}));100-expectType<SyncResult<{}>>(execaCommandSync({})('unicorns'));101-expectType<SyncResult<{}>>(execaCommandSync({})`unicorns`);102-expectType<SyncResult<{}>>(execaCommandSync('unicorns'));103-expectType<SyncResult<{}>>(execaCommandSync`unicorns`);104-expectAssignable<{stdout: string}>(execaCommandSync('unicorns'));105-expectAssignable<{stdout: Uint8Array}>(execaCommandSync('unicorns', {encoding: 'buffer'}));106-expectAssignable<{stdout: string}>(execaCommandSync({})('unicorns'));107-expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})('unicorns'));108-expectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})('unicorns'));109-expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})('unicorns'));110-expectAssignable<{stdout: string}>(execaCommandSync({})`unicorns`);111-expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})`unicorns`);112-expectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})`unicorns`);113-expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})`unicorns`);114-expectType<SyncResult<{}>>(execaCommandSync`${'unicorns'}`);115-expectType<SyncResult<{}>>(execaCommandSync`unicorns ${'foo'}`);116-expectError(execaCommandSync`unicorns ${'foo'} ${'bar'}`);117-expectError(execaCommandSync`unicorns ${1}`);118-expectError(execaCommandSync`unicorns ${stringArray}`);119-expectError(execaCommandSync`unicorns ${[1, 2]}`);120-expectError(execaCommandSync`unicorns ${execaCommandSync`echo foo`}`);121-expectError(execaCommandSync`unicorns ${[execaCommandSync`echo foo`, 'bar']}`);122-expectType<SyncResult<{}>>(execaCommandSync`unicorns ${false.toString()}`);123-expectError(execaCommandSync`unicorns ${false}`);modified:types/methods/command.d.ts-95 removed
1-import type {Options, SyncOptions} from '../arguments/options.js';2-import type {SyncResult} from '../return/result.js';3-import type {ResultPromise} from '../subprocess/subprocess.js';4-import type {SimpleTemplateString} from './template.js';5-1 /**7-Executes a command. `command` is a string that includes both the `file` and its `arguments`.8-9-When `command` is a template string, it includes both the `file` and its `arguments`.10-11-`execaCommand(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.12-13-This is only intended for very specific cases, such as a REPL. This should be avoided otherwise.14-15-@param command - The program/script to execute and its arguments.16-@returns A `ResultPromise` that is both:17-- the subprocess.18-- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.19-@throws `ExecaError`20-21-@example22-```23-import {execaCommand} from 'execa';24-25-for await (const commandAndArguments of getReplLine()) {26- await execaCommand(commandAndArguments);27-}28-```29-*/30-export declare const execaCommand: ExecaCommandMethod<{}>;31-32-type ExecaCommandMethod<OptionsType extends Options> =33- & ExecaCommandBind<OptionsType>34- & ExecaCommandTemplate<OptionsType>35- & ExecaCommandArray<OptionsType>;36-37-// `execaCommand(options)` binding38-type ExecaCommandBind<OptionsType extends Options> =39- <NewOptionsType extends Options = {}>(options: NewOptionsType)40- => ExecaCommandMethod<OptionsType & NewOptionsType>;41-42-// `execaCommand`command`` template syntax43-type ExecaCommandTemplate<OptionsType extends Options> =44- (...templateString: SimpleTemplateString)45- => ResultPromise<OptionsType>;46-47-// `execaCommand('command', {})` array syntax48-type ExecaCommandArray<OptionsType extends Options> =49- <NewOptionsType extends Options = {}>(command: string, options?: NewOptionsType)50- => ResultPromise<OptionsType & NewOptionsType>;51-52-/**53-Same as `execaCommand()` but synchronous.54-55-When `command` is a template string, it includes both the `file` and its `arguments`.56-57-`execaCommandSync(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.58-59-Returns a subprocess `result` or throws an `error`. The `subprocess` is not returned: its methods and properties are not available.60-61-@param command - The program/script to execute and its arguments.62-@returns `SyncResult`63-@throws `ExecaSyncError`64-65-@example66-```67-import {execaCommandSync} from 'execa';68-69-for (const commandAndArguments of getReplLine()) {70- execaCommandSync(commandAndArguments);71-}72-```73-*/74-export declare const execaCommandSync: ExecaCommandSyncMethod<{}>;75-76-type ExecaCommandSyncMethod<OptionsType extends SyncOptions> =77- & ExecaCommandSyncBind<OptionsType>78- & ExecaCommandSyncTemplate<OptionsType>79- & ExecaCommandSyncArray<OptionsType>;80-81-// `execaCommandSync(options)` binding82-type ExecaCommandSyncBind<OptionsType extends SyncOptions> =83- <NewOptionsType extends SyncOptions = {}>(options: NewOptionsType)84- => ExecaCommandSyncMethod<OptionsType & NewOptionsType>;85-86-// `execaCommandSync`command`` template syntax87-type ExecaCommandSyncTemplate<OptionsType extends SyncOptions> =88- (...templateString: SimpleTemplateString)89- => SyncResult<OptionsType>;90-91-// `execaCommandSync('command', {})` array syntax92-type ExecaCommandSyncArray<OptionsType extends SyncOptions> =93- <NewOptionsType extends SyncOptions = {}>(command: string, options?: NewOptionsType)94- => SyncResult<OptionsType & NewOptionsType>;95-96-/**2 Split a `command` string into an array. For example, `'npm run build'` returns `['npm', 'run', 'build']` and `'argument otherArgument'` returns `['argument', 'otherArgument']`.3 4 @param command - The file to execute and/or its arguments.5 @returns fileOrArgument[]16 unmodified linesmodified:types/methods/template.d.ts-3 removed
12 unmodified lines13 14 // `...${...}...` template syntax15 export type TemplateString = readonly [TemplateStringsArray, ...readonly TemplateExpression[]];16 17-// `...${...}...` template syntax, but only allowing a single argument, for `execaCommand()`18-export type SimpleTemplateString = readonly [TemplateStringsArray, string?];19-17 export {};modified:index.d.ts+1 added-1 removed
11 unmodified lines12 export {ExecaError, ExecaSyncError} from './types/return/final-error.js';13 14 export {execa, type ExecaMethod} from './types/methods/main-async.js';15 export {execaSync, type ExecaSyncMethod} from './types/methods/main-sync.js';16-export {execaCommand, execaCommandSync, parseCommandString} from './types/methods/command.js';16+export {parseCommandString} from './types/methods/command.js';17 export {$, type ExecaScriptMethod, type ExecaScriptSyncMethod} from './types/methods/script.js';18 export {execaNode, type ExecaNodeMethod} from './types/methods/node.js';19 20 export {7 unmodified linesmodified:index.js-3 removed
1 import {createExeca} from './lib/methods/create.js';2-import {mapCommandAsync, mapCommandSync} from './lib/methods/command.js';2 import {mapNode} from './lib/methods/node.js';3 import {mapScriptAsync, setScriptSync, deepScriptOptions} from './lib/methods/script.js';4 import {getIpcExport} from './lib/ipc/methods.js';5 1 unmodified line7 export {ExecaError, ExecaSyncError} from './lib/return/final-error.js';8 9 export const execa = createExeca(() => ({}));10 export const execaSync = createExeca(() => ({isSync: true}));12-export const execaCommand = createExeca(mapCommandAsync);13-export const execaCommandSync = createExeca(mapCommandSync);11 export const execaNode = createExeca(mapNode);12 export const $ = createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);13 14 const {11 unmodified lines