Skip to content
Myr

Improve documentation of main methods (#860)

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

authored by ehmicky · committed by GitHub · parent 9dc1141 · Browse files · 2 files+39 added−25 removed
This commit

State

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

Diff stats

2 files+39 added−25 removed

  • other:+39 added−25 removed

2 files+39 added−25 removed

modified:index.d.ts+6 added-4 removed
915 unmodified lines
916ExecaChildPromise<OptionsType> &917Promise<ExecaReturnValue<OptionsType>>;918919/**920Executes a command using `file ...arguments`. `file` is a string or a file URL. `arguments` are an array of strings. Returns a `childProcess`.920Executes a command using `file ...arguments`.921922Arguments are automatically escaped. They can contain any character, including spaces.923924This is the preferred method when executing single commands.
175 unmodified lines
1100 options?: OptionsType,1101): ExecaSyncReturnValue<OptionsType>;11021103/**1104Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.1104Executes a command. The `command` string includes both the `file` and its `arguments`.11051106Arguments are automatically escaped. They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.11071108This is the preferred method when executing a user-supplied `command` string, such as in a REPL.
185 unmodified lines
1294 ): ExecaSyncReturnValue<StricterOptions<OptionsType, SyncOptions>>;1295};12961297/**1298Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.1298Executes a command. The `command` string includes both the `file` and its `arguments`.12991300Arguments are automatically escaped. They can contain any character, but spaces must use `${}` like `` $`echo ${'has space'}` ``.1300Arguments are automatically escaped. They can contain any character, but spaces, tabs and newlines must use `${}` like `` $`echo ${'has space'}` ``.13011302This is the preferred method when executing multiple commands in a script file.13031304The `command` string can inject any `${value}` with the following types: string, number, `childProcess` or an array of those types. For example: `` $`echo one ${'two'} ${3} ${['four', 'five']}` ``. For `${childProcess}`, the process's `stdout` is used.
48 unmodified lines
1353Same as `execa()` but using the `node` option.13541355Executes a Node.js file using `node scriptPath ...arguments`.13561357This is the preferred method when executing Node.js files.13581359@param scriptPath - Node.js script to execute, as a string or file URL1360@param arguments - Arguments to pass to `scriptPath` on execution.1361@returns An `ExecaChildProcess` that is both:1362- a `Promise` resolving or rejecting with a `childProcessResult`.
19 unmodified lines
modified:readme.md+33 added-21 removed
238 unmodified lines
239### Methods240241#### execa(file, arguments?, options?)242243Executes a command using `file ...arguments`. `file` is a string or a file URL. `arguments` are an array of strings. Returns a [`childProcess`](#childprocess).243`file`: `string | URL`\244`arguments`: `string[]`\245`options`: [`Options`](#options-1)\246_Returns_: [`ChildProcess`](#childprocess)247248Executes a command using `file ...arguments`.249250Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.251252This is the preferred method when executing single commands.253254#### $\`command\`255#### $(options)\`command\`256251Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a [`childProcess`](#childprocess).257`command`: `string`\258`options`: [`Options`](#options-1)\259_Returns_: [`ChildProcess`](#childprocess)260253Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must use `${}` like `` $`echo ${'has space'}` ``.261Executes a command. The `command` string includes both the `file` and its `arguments`.262263Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces, tabs and newlines must use `${}` like `` $`echo ${'has space'}` ``.264265This is the preferred method when executing multiple commands in a script file.266267The `command` string can inject any `${value}` with the following types: string, number, [`childProcess`](#childprocess) or an array of those types. For example: `` $`echo one ${'two'} ${3} ${['four', 'five']}` ``. For `${childProcess}`, the process's `stdout` is used.268
2 unmodified lines
271For more information, please see [this section](#scripts-interface) and [this page](docs/scripts.md).272273#### $(options)274265Returns a new instance of [`$`](#command) but with different default `options`. Consecutive calls are merged to previous ones.275`options`: [`Options`](#options-1)\276_Returns_: [`$`](#command)277278Returns a new instance of [`$`](#command) but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.279280This can be used to either:281- Set options for a specific command: `` $(options)`command` ``282- Share options for multiple commands: `` const $$ = $(options); $$`command`; $$`otherCommand`; ``283284#### execaCommand(command, options?)285273Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a [`childProcess`](#childprocess).286`command`: `string`\287`options`: [`Options`](#options-1)\288_Returns_: [`ChildProcess`](#childprocess)289290Executes a command. The `command` string includes both the `file` and its `arguments`.291292Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.293294This is the preferred method when executing a user-supplied `command` string, such as in a REPL.295296#### execaNode(scriptPath, arguments?, options?)297298`file`: `string | URL`\299`arguments`: `string[]`\300`options`: [`Options`](#options-1)\301_Returns_: [`ChildProcess`](#childprocess)302303Same as [`execa()`](#execacommandcommand-options) but using the [`node`](#node) option.304305Executes a Node.js file using `node scriptPath ...arguments`.306285#### execaSync(file, arguments?, options?)307This is the preferred method when executing Node.js files.308287Same as [`execa()`](#execacommandcommand-options) but synchronous.288289Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.290291Returns or throws a [`childProcessResult`](#childProcessResult). The [`childProcess`](#childprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipesecondchildprocess-pipeoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.292309#### execaSync(file, arguments?, options?)310#### execaCommandSync(command, options?)311#### $.sync\`command\`312#### $.s\`command\`313#### $.sync(options)\`command\`314#### $.s(options)\`command\`315296Same as [$\`command\`](#command) but synchronous.316Same as [`execa()`](#execacommandcommand-options), [`execaCommand()`](#execacommand-command-options), [$\`command\`](#command) but synchronous.317318Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.319320Returns or throws a [`childProcessResult`](#childProcessResult). The [`childProcess`](#childprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipesecondchildprocess-pipeoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.321302#### execaCommandSync(command, options?)303304Same as [`execaCommand()`](#execacommand-command-options) but synchronous.305306Cannot use the following options: [`all`](#all-2), [`cleanup`](#cleanup), [`buffer`](#buffer), [`detached`](#detached), [`ipc`](#ipc), [`serialization`](#serialization), [`signal`](#signal) and [`lines`](#lines). Also, the [`stdin`](#stdin), [`stdout`](#stdout-1), [`stderr`](#stderr-1), [`stdio`](#stdio-1) and [`input`](#input) options cannot be an array, an iterable or a web stream. Node.js streams [must have a file descriptor](#redirect-a-nodejs-stream-fromto-stdinstdoutstderr) unless the `input` option is used.307308Returns or throws a [`childProcessResult`](#childProcessResult). The [`childProcess`](#childprocess) is not returned: its methods and properties are not available. This includes [`.kill()`](https://nodejs.org/api/child_process.html#subprocesskillsignal), [`.pid`](https://nodejs.org/api/child_process.html#subprocesspid), [`.pipe()`](#pipesecondchildprocess-pipeoptions) and the [`.stdin`/`.stdout`/`.stderr`](https://nodejs.org/api/child_process.html#subprocessstdout) streams.309322### Shell syntax323324For all the [methods above](#methods), no shell interpreter (Bash, cmd.exe, etc.) is used unless the [`shell` option](#shell) is set. This means shell-specific characters and expressions (`$variable`, `&&`, `||`, `;`, `|`, etc.) have no special meaning and do not need to be escaped.325
700 unmodified lines