Skip to content
Myr

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

11 files+20 added−353 removed

modified:lib/methods/command.js-16 removed
modified:lib/methods/create.js+3 added-5 removed
modified:test/methods/command.js+15 added-107 removed
1import path from 'node:path';1import test from 'ava';2import {3 execa,4 execaSync,5 $,6 execaNode,8 execaCommand,9 execaCommandSync,7 parseCommandString,8} from '../../index.js';9import {10 setFixtureDirectory,14 FIXTURES_DIRECTORY,11 FIXTURES_DIRECTORY_URL,12} from '../helpers/fixtures-directory.js';17import {QUOTE} from '../helpers/verbose.js';1314setFixtureDirectory();20const STDIN_FIXTURE = path.join(FIXTURES_DIRECTORY, 'stdin.js');15const ECHO_FIXTURE_URL = new URL('echo.js', FIXTURES_DIRECTORY_URL);1617const parseAndRunCommand = command => execa`${parseCommandString(command)}`;1825test('execaCommand()', async t => {26 const {stdout} = await execaCommand('echo.js foo bar');27 t.is(stdout, 'foo\nbar');28});2919test('parseCommandString() + execa()', async t => {20 const {stdout} = await execa('echo.js', parseCommandString('foo bar'));21 t.is(stdout, 'foo\nbar');22});2335test('execaCommandSync()', t => {36 const {stdout} = execaCommandSync('echo.js foo bar');37 t.is(stdout, 'foo\nbar');38});3924test('parseCommandString() + execaSync()', t => {25 const {stdout} = execaSync('echo.js', parseCommandString('foo bar'));26 t.is(stdout, 'foo\nbar');27});2845test('execaCommand`...`', async t => {46 const {stdout} = await execaCommand`${'echo.js foo bar'}`;47 t.is(stdout, 'foo\nbar');48});4929test('parseCommandString() + execa`...`', async t => {30 const {stdout} = await execa`${parseCommandString('echo.js foo bar')}`;31 t.is(stdout, 'foo\nbar');32});
7 unmodified lines
40 const {stdout} = await execa`echo.js ${'foo bar'} ${parseCommandString('foo bar')}`;41 t.is(stdout, 'foo bar\nfoo\nbar');42});4365test('execaCommandSync`...`', t => {66 const {stdout} = execaCommandSync`${'echo.js foo bar'}`;67 t.is(stdout, 'foo\nbar');68});6944test('parseCommandString() + execaSync`...`', t => {45 const {stdout} = execaSync`${parseCommandString('echo.js foo bar')}`;46 t.is(stdout, 'foo\nbar');47});
22 unmodified lines
70 const {stdout} = await execaNode(ECHO_FIXTURE_URL, parseCommandString('foo bar'));71 t.is(stdout, 'foo\nbar');72});73100test('execaCommand(options)`...`', async t => {101 const {stdout} = await execaCommand({stripFinalNewline: false})`${'echo.js foo bar'}`;102 t.is(stdout, 'foo\nbar\n');103});104105test('execaCommandSync(options)`...`', t => {106 const {stdout} = execaCommandSync({stripFinalNewline: false})`${'echo.js foo bar'}`;107 t.is(stdout, 'foo\nbar\n');108});109110test('execaCommand(options)()', async t => {111 const {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar');112 t.is(stdout, 'foo\nbar\n');113});114115test('execaCommandSync(options)()', t => {116 const {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar');117 t.is(stdout, 'foo\nbar\n');118});119120test('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});124125test('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});129130test('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});134135test('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});139140const 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};145146test('execaCommand() must not pass an array of arguments', testInvalidArgumentsArray, execaCommand);147test('execaCommandSync() must not pass an array of arguments', testInvalidArgumentsArray, execaCommandSync);148149const 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};154155test('execaCommand() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommand);156test('execaCommandSync() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommandSync);15774const testInvalidArgumentsParse = (t, command) => {75 t.throws(() => parseCommandString(command), {76 message: /The command must be a string/,77 });78};79164test('execaCommand() must not pass a number', testInvalidArgumentsParse, 0);165test('execaCommand() must not pass undefined', testInvalidArgumentsParse, undefined);166test('execaCommand() must not pass null', testInvalidArgumentsParse, null);167test('execaCommand() must not pass a symbol', testInvalidArgumentsParse, Symbol('test'));168test('execaCommand() must not pass an object', testInvalidArgumentsParse, {});169test('execaCommand() must not pass an array', testInvalidArgumentsParse, []);80test('parseCommandString() must not pass a number', testInvalidArgumentsParse, 0);81test('parseCommandString() must not pass undefined', testInvalidArgumentsParse, undefined);82test('parseCommandString() must not pass null', testInvalidArgumentsParse, null);83test('parseCommandString() must not pass a symbol', testInvalidArgumentsParse, Symbol('test'));84test('parseCommandString() must not pass an object', testInvalidArgumentsParse, {});85test('parseCommandString() must not pass an array', testInvalidArgumentsParse, []);86171const testExecaCommandOutput = async (t, command, expectedOutput, execaMethod) => {87const testParseCommandOutput = async (t, command, expectedOutput, execaMethod) => {88 const {stdout} = await execaMethod(command);89 t.is(stdout, expectedOutput);90};91176test('execaCommand() allows escaping spaces in commands', testExecaCommandOutput, 'command\\ with\\ space.js foo bar', 'foo\nbar', execaCommand);177test('execaCommand() trims', testExecaCommandOutput, ' echo.js foo bar ', 'foo\nbar', execaCommand);178test('execaCommand() ignores consecutive spaces', testExecaCommandOutput, 'echo.js foo bar', 'foo\nbar', execaCommand);179test('execaCommand() escapes other whitespaces', testExecaCommandOutput, 'echo.js foo\tbar', 'foo\tbar', execaCommand);180test('execaCommand() allows escaping spaces', testExecaCommandOutput, 'echo.js foo\\ bar', 'foo bar', execaCommand);181test('execaCommand() allows escaping backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\ bar', 'foo\\ bar', execaCommand);182test('execaCommand() allows escaping multiple backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\\\ bar', execaCommand);183test('execaCommand() allows escaping backslashes not before spaces', testExecaCommandOutput, 'echo.js foo\\bar baz', 'foo\\bar\nbaz', execaCommand);184test('parseCommandString() allows escaping spaces in commands', testExecaCommandOutput, 'command\\ with\\ space.js foo bar', 'foo\nbar', parseAndRunCommand);185test('parseCommandString() trims', testExecaCommandOutput, ' echo.js foo bar ', 'foo\nbar', parseAndRunCommand);186test('parseCommandString() ignores consecutive spaces', testExecaCommandOutput, 'echo.js foo bar', 'foo\nbar', parseAndRunCommand);187test('parseCommandString() escapes other whitespaces', testExecaCommandOutput, 'echo.js foo\tbar', 'foo\tbar', parseAndRunCommand);188test('parseCommandString() allows escaping spaces', testExecaCommandOutput, 'echo.js foo\\ bar', 'foo bar', parseAndRunCommand);189test('parseCommandString() allows escaping backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\ bar', 'foo\\ bar', parseAndRunCommand);190test('parseCommandString() allows escaping multiple backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\\\ bar', parseAndRunCommand);191test('parseCommandString() allows escaping backslashes not before spaces', testExecaCommandOutput, 'echo.js foo\\bar baz', 'foo\\bar\nbaz', parseAndRunCommand);92test('parseCommandString() allows escaping spaces in commands', testParseCommandOutput, 'command\\ with\\ space.js foo bar', 'foo\nbar', parseAndRunCommand);93test('parseCommandString() trims', testParseCommandOutput, ' echo.js foo bar ', 'foo\nbar', parseAndRunCommand);94test('parseCommandString() ignores consecutive spaces', testParseCommandOutput, 'echo.js foo bar', 'foo\nbar', parseAndRunCommand);95test('parseCommandString() escapes other whitespaces', testParseCommandOutput, 'echo.js foo\tbar', 'foo\tbar', parseAndRunCommand);96test('parseCommandString() allows escaping spaces', testParseCommandOutput, 'echo.js foo\\ bar', 'foo bar', parseAndRunCommand);97test('parseCommandString() allows escaping backslashes before spaces', testParseCommandOutput, 'echo.js foo\\\\ bar', 'foo\\ bar', parseAndRunCommand);98test('parseCommandString() allows escaping multiple backslashes before spaces', testParseCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\\\ bar', parseAndRunCommand);99test('parseCommandString() allows escaping backslashes not before spaces', testParseCommandOutput, 'echo.js foo\\bar baz', 'foo\\bar\nbaz', parseAndRunCommand);100101test('parseCommandString() can get empty strings', t => {102 t.deepEqual(parseCommandString(''), []);103});
5 unmodified lines
modified:test/methods/parameters-args.js-8 removed
modified:test/methods/parameters-command.js-14 removed
2 unmodified lines
3import test from 'ava';4import {5 execa,6 execaSync,7 execaCommand,8 execaCommandSync,7 execaNode,8 $,9} from '../../index.js';10import {setFixtureDirectory, FIXTURES_DIRECTORY_URL} from '../helpers/fixtures-directory.js';
8 unmodified lines
19};2021test('execa()\'s command argument can be a file URL', testFileUrl, execa);22test('execaSync()\'s command argument can be a file URL', testFileUrl, execaSync);25test('execaCommand()\'s command argument can be a file URL', testFileUrl, execaCommand);26test('execaCommandSync()\'s command argument can be a file URL', testFileUrl, execaCommandSync);23test('execaNode()\'s command argument can be a file URL', testFileUrl, execaNode);24test('$\'s command argument can be a file URL', testFileUrl, $);25test('$.sync\'s command argument can be a file URL', testFileUrl, $.sync);26
5 unmodified lines
32};3334test('execa()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execa);35test('execaSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaSync);40test('execaCommand()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommand);41test('execaCommandSync()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommandSync);36test('execaNode()\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaNode);37test('$\'s command argument cannot be a non-file URL', testInvalidFileUrl, $);38test('$.sync\'s command argument cannot be a non-file URL', testInvalidFileUrl, $.sync);39
4 unmodified lines
44};4546test('execa()\'s first argument must be defined', testInvalidCommand, undefined, execa);47test('execaSync()\'s first argument must be defined', testInvalidCommand, undefined, execaSync);54test('execaCommand()\'s first argument must be defined', testInvalidCommand, undefined, execaCommand);55test('execaCommandSync()\'s first argument must be defined', testInvalidCommand, undefined, execaCommandSync);48test('execaNode()\'s first argument must be defined', testInvalidCommand, undefined, execaNode);49test('$\'s first argument must be defined', testInvalidCommand, undefined, $);50test('$.sync\'s first argument must be defined', testInvalidCommand, undefined, $.sync);51test('execa()\'s first argument must be valid', testInvalidCommand, true, execa);52test('execaSync()\'s first argument must be valid', testInvalidCommand, true, execaSync);61test('execaCommand()\'s first argument must be valid', testInvalidCommand, true, execaCommand);62test('execaCommandSync()\'s first argument must be valid', testInvalidCommand, true, execaCommandSync);53test('execaNode()\'s first argument must be valid', testInvalidCommand, true, execaNode);54test('$\'s first argument must be valid', testInvalidCommand, true, $);55test('$.sync\'s first argument must be valid', testInvalidCommand, true, $.sync);56test('execa()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execa);57test('execaSync()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaSync);68test('execaCommand()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommand);69test('execaCommandSync()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommandSync);58test('execaNode()\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaNode);59test('$\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $);60test('$.sync\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $.sync);61
6 unmodified lines
68};6970test('execa() use relative path with \'..\' chars', testRelativePath, execa);71test('execaSync() use relative path with \'..\' chars', testRelativePath, execaSync);84test('execaCommand() use relative path with \'..\' chars', testRelativePath, execaCommand);85test('execaCommandSync() use relative path with \'..\' chars', testRelativePath, execaCommandSync);72test('execaNode() use relative path with \'..\' chars', testRelativePath, execaNode);73test('$ use relative path with \'..\' chars', testRelativePath, $);74test('$.sync use relative path with \'..\' chars', testRelativePath, $.sync);
modified:test/methods/parameters-options.js-4 removed
1 unmodified line
2import test from 'ava';3import {4 execa,5 execaSync,6 execaCommand,7 execaCommandSync,6 execaNode,7 $,8} from '../../index.js';9import {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';
55 unmodified lines
65};6667test('execa()\'s third argument must be a plain object', testInvalidOptions, execa);68test('execaSync()\'s third argument must be a plain object', testInvalidOptions, execaSync);71test('execaCommand()\'s third argument must be a plain object', testInvalidOptions, execaCommand);72test('execaCommandSync()\'s third argument must be a plain object', testInvalidOptions, execaCommandSync);69test('execaNode()\'s third argument must be a plain object', testInvalidOptions, execaNode);70test('$\'s third argument must be a plain object', testInvalidOptions, $);71test('$.sync\'s third argument must be a plain object', testInvalidOptions, $.sync);
modified:test-d/methods/command.test-d.ts+1 added-97 removed
1import {expectType, expectError, expectAssignable} from 'tsd';1import {expectType, expectError} from 'tsd';2import {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';1115const fileUrl = new URL('file:///test');16const stringArray = ['foo', 'bar'] as const;1712expectError(parseCommandString());13expectError(parseCommandString(true));14expectError(parseCommandString(['unicorns', 'arg']));15
8 unmodified lines
2425expectType<Result<{}>>(await execa`unicorns ${parseCommandString('foo bar')}`);26expectType<Result<{}>>(await execa('unicorns', parseCommandString('foo bar')));27expectType<Result<{}>>(await execa('unicorns', ['foo', ...parseCommandString('bar')]));3435expectError(execaCommand());36expectError(execaCommand(true));37expectError(execaCommand(['unicorns', 'arg']));38expectAssignable<ResultPromise>(execaCommand('unicorns'));39expectError(execaCommand(fileUrl));4041expectError(execaCommand('unicorns', []));42expectError(execaCommand('unicorns', ['foo']));43expectError(execaCommand('unicorns', 'foo'));44expectError(execaCommand('unicorns', [true]));4546expectAssignable<ResultPromise>(execaCommand('unicorns', {}));47expectError(execaCommand('unicorns', [], {}));48expectError(execaCommand('unicorns', [], []));49expectError(execaCommand('unicorns', {other: true}));5051expectAssignable<ResultPromise>(execaCommand`unicorns`);52expectType<Result<{}>>(await execaCommand('unicorns'));53expectType<Result<{}>>(await execaCommand`unicorns`);5455expectAssignable<typeof execaCommand>(execaCommand({}));56expectAssignable<ResultPromise>(execaCommand({})('unicorns'));57expectAssignable<ResultPromise>(execaCommand({})`unicorns`);5859expectAssignable<{stdout: string}>(await execaCommand('unicorns'));60expectAssignable<{stdout: Uint8Array}>(await execaCommand('unicorns', {encoding: 'buffer'}));61expectAssignable<{stdout: string}>(await execaCommand({})('unicorns'));62expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})('unicorns'));63expectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})('unicorns'));64expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})('unicorns'));65expectAssignable<{stdout: string}>(await execaCommand({})`unicorns`);66expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})`unicorns`);67expectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})`unicorns`);68expectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})`unicorns`);6970expectType<Result<{}>>(await execaCommand`${'unicorns'}`);71expectType<Result<{}>>(await execaCommand`unicorns ${'foo'}`);72expectError(await execaCommand`unicorns ${'foo'} ${'bar'}`);73expectError(await execaCommand`unicorns ${1}`);74expectError(await execaCommand`unicorns ${stringArray}`);75expectError(await execaCommand`unicorns ${[1, 2]}`);76expectType<Result<{}>>(await execaCommand`unicorns ${false.toString()}`);77expectError(await execaCommand`unicorns ${false}`);7879expectError(await execaCommand`unicorns ${await execaCommand`echo foo`}`);80expectError(await execaCommand`unicorns ${await execaCommand({reject: false})`echo foo`}`);81expectError(await execaCommand`unicorns ${execaCommand`echo foo`}`);82expectError(await execaCommand`unicorns ${[await execaCommand`echo foo`, 'bar']}`);83expectError(await execaCommand`unicorns ${[execaCommand`echo foo`, 'bar']}`);8485expectError(execaCommandSync());86expectError(execaCommandSync(true));87expectError(execaCommandSync(['unicorns', 'arg']));88expectType<SyncResult<{}>>(execaCommandSync('unicorns'));89expectError(execaCommandSync(fileUrl));90expectError(execaCommandSync('unicorns', []));91expectError(execaCommandSync('unicorns', ['foo']));92expectType<SyncResult<{}>>(execaCommandSync('unicorns', {}));93expectError(execaCommandSync('unicorns', [], {}));94expectError(execaCommandSync('unicorns', 'foo'));95expectError(execaCommandSync('unicorns', [true]));96expectError(execaCommandSync('unicorns', [], []));97expectError(execaCommandSync('unicorns', {other: true}));98expectType<SyncResult<{}>>(execaCommandSync`unicorns`);99expectAssignable<typeof execaCommandSync>(execaCommandSync({}));100expectType<SyncResult<{}>>(execaCommandSync({})('unicorns'));101expectType<SyncResult<{}>>(execaCommandSync({})`unicorns`);102expectType<SyncResult<{}>>(execaCommandSync('unicorns'));103expectType<SyncResult<{}>>(execaCommandSync`unicorns`);104expectAssignable<{stdout: string}>(execaCommandSync('unicorns'));105expectAssignable<{stdout: Uint8Array}>(execaCommandSync('unicorns', {encoding: 'buffer'}));106expectAssignable<{stdout: string}>(execaCommandSync({})('unicorns'));107expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})('unicorns'));108expectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})('unicorns'));109expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})('unicorns'));110expectAssignable<{stdout: string}>(execaCommandSync({})`unicorns`);111expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})`unicorns`);112expectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})`unicorns`);113expectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})`unicorns`);114expectType<SyncResult<{}>>(execaCommandSync`${'unicorns'}`);115expectType<SyncResult<{}>>(execaCommandSync`unicorns ${'foo'}`);116expectError(execaCommandSync`unicorns ${'foo'} ${'bar'}`);117expectError(execaCommandSync`unicorns ${1}`);118expectError(execaCommandSync`unicorns ${stringArray}`);119expectError(execaCommandSync`unicorns ${[1, 2]}`);120expectError(execaCommandSync`unicorns ${execaCommandSync`echo foo`}`);121expectError(execaCommandSync`unicorns ${[execaCommandSync`echo foo`, 'bar']}`);122expectType<SyncResult<{}>>(execaCommandSync`unicorns ${false.toString()}`);123expectError(execaCommandSync`unicorns ${false}`);
modified:types/methods/command.d.ts-95 removed
1import type {Options, SyncOptions} from '../arguments/options.js';2import type {SyncResult} from '../return/result.js';3import type {ResultPromise} from '../subprocess/subprocess.js';4import type {SimpleTemplateString} from './template.js';51/**7Executes a command. `command` is a string that includes both the `file` and its `arguments`.89When `command` is a template string, it includes both the `file` and its `arguments`.1011`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.1213This is only intended for very specific cases, such as a REPL. This should be avoided otherwise.1415@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`2021@example22```23import {execaCommand} from 'execa';2425for await (const commandAndArguments of getReplLine()) {26 await execaCommand(commandAndArguments);27}28```29*/30export declare const execaCommand: ExecaCommandMethod<{}>;3132type ExecaCommandMethod<OptionsType extends Options> =33 & ExecaCommandBind<OptionsType>34 & ExecaCommandTemplate<OptionsType>35 & ExecaCommandArray<OptionsType>;3637// `execaCommand(options)` binding38type ExecaCommandBind<OptionsType extends Options> =39 <NewOptionsType extends Options = {}>(options: NewOptionsType)40 => ExecaCommandMethod<OptionsType & NewOptionsType>;4142// `execaCommand`command`` template syntax43type ExecaCommandTemplate<OptionsType extends Options> =44 (...templateString: SimpleTemplateString)45 => ResultPromise<OptionsType>;4647// `execaCommand('command', {})` array syntax48type ExecaCommandArray<OptionsType extends Options> =49 <NewOptionsType extends Options = {}>(command: string, options?: NewOptionsType)50 => ResultPromise<OptionsType & NewOptionsType>;5152/**53Same as `execaCommand()` but synchronous.5455When `command` is a template string, it includes both the `file` and its `arguments`.5657`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.5859Returns a subprocess `result` or throws an `error`. The `subprocess` is not returned: its methods and properties are not available.6061@param command - The program/script to execute and its arguments.62@returns `SyncResult`63@throws `ExecaSyncError`6465@example66```67import {execaCommandSync} from 'execa';6869for (const commandAndArguments of getReplLine()) {70 execaCommandSync(commandAndArguments);71}72```73*/74export declare const execaCommandSync: ExecaCommandSyncMethod<{}>;7576type ExecaCommandSyncMethod<OptionsType extends SyncOptions> =77 & ExecaCommandSyncBind<OptionsType>78 & ExecaCommandSyncTemplate<OptionsType>79 & ExecaCommandSyncArray<OptionsType>;8081// `execaCommandSync(options)` binding82type ExecaCommandSyncBind<OptionsType extends SyncOptions> =83 <NewOptionsType extends SyncOptions = {}>(options: NewOptionsType)84 => ExecaCommandSyncMethod<OptionsType & NewOptionsType>;8586// `execaCommandSync`command`` template syntax87type ExecaCommandSyncTemplate<OptionsType extends SyncOptions> =88 (...templateString: SimpleTemplateString)89 => SyncResult<OptionsType>;9091// `execaCommandSync('command', {})` array syntax92type ExecaCommandSyncArray<OptionsType extends SyncOptions> =93 <NewOptionsType extends SyncOptions = {}>(command: string, options?: NewOptionsType)94 => SyncResult<OptionsType & NewOptionsType>;9596/**2Split a `command` string into an array. For example, `'npm run build'` returns `['npm', 'run', 'build']` and `'argument otherArgument'` returns `['argument', 'otherArgument']`.34@param command - The file to execute and/or its arguments.5@returns fileOrArgument[]
16 unmodified lines
modified:types/methods/template.d.ts-3 removed
12 unmodified lines
1314// `...${...}...` template syntax15export type TemplateString = readonly [TemplateStringsArray, ...readonly TemplateExpression[]];1617// `...${...}...` template syntax, but only allowing a single argument, for `execaCommand()`18export type SimpleTemplateString = readonly [TemplateStringsArray, string?];1917export {};
modified:index.d.ts+1 added-1 removed
11 unmodified lines
12export {ExecaError, ExecaSyncError} from './types/return/final-error.js';1314export {execa, type ExecaMethod} from './types/methods/main-async.js';15export {execaSync, type ExecaSyncMethod} from './types/methods/main-sync.js';16export {execaCommand, execaCommandSync, parseCommandString} from './types/methods/command.js';16export {parseCommandString} from './types/methods/command.js';17export {$, type ExecaScriptMethod, type ExecaScriptSyncMethod} from './types/methods/script.js';18export {execaNode, type ExecaNodeMethod} from './types/methods/node.js';1920export {
7 unmodified lines
modified:index.js-3 removed
1import {createExeca} from './lib/methods/create.js';2import {mapCommandAsync, mapCommandSync} from './lib/methods/command.js';2import {mapNode} from './lib/methods/node.js';3import {mapScriptAsync, setScriptSync, deepScriptOptions} from './lib/methods/script.js';4import {getIpcExport} from './lib/ipc/methods.js';5
1 unmodified line
7export {ExecaError, ExecaSyncError} from './lib/return/final-error.js';89export const execa = createExeca(() => ({}));10export const execaSync = createExeca(() => ({isSync: true}));12export const execaCommand = createExeca(mapCommandAsync);13export const execaCommandSync = createExeca(mapCommandSync);11export const execaNode = createExeca(mapNode);12export const $ = createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);1314const {
11 unmodified lines