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
Provenance
- Commit
3bb0d61- Tree
febc4d3- Author
ehmicky <ehmicky@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
9dc1141
2 files changed+39 added−25 removed
modified:index.d.ts+6 added-4 removed
915 unmodified lines916 ExecaChildPromise<OptionsType> &917 Promise<ExecaReturnValue<OptionsType>>;918 919 /**920-Executes a command using `file ...arguments`. `file` is a string or a file URL. `arguments` are an array of strings. Returns a `childProcess`.920+Executes a command using `file ...arguments`.921 922 Arguments are automatically escaped. They can contain any character, including spaces.923 924 This is the preferred method when executing single commands.175 unmodified lines1100 options?: OptionsType,1101 ): ExecaSyncReturnValue<OptionsType>;1102 1103 /**1104-Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.1104+Executes a command. The `command` string includes both the `file` and its `arguments`.1105 1106 Arguments are automatically escaped. They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.1107 1108 This is the preferred method when executing a user-supplied `command` string, such as in a REPL.185 unmodified lines1294 ): ExecaSyncReturnValue<StricterOptions<OptionsType, SyncOptions>>;1295 };1296 1297 /**1298-Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.1298+Executes a command. The `command` string includes both the `file` and its `arguments`.1299 1300-Arguments are automatically escaped. They can contain any character, but spaces must use `${}` like `` $`echo ${'has space'}` ``.1300+Arguments are automatically escaped. They can contain any character, but spaces, tabs and newlines must use `${}` like `` $`echo ${'has space'}` ``.1301 1302 This is the preferred method when executing multiple commands in a script file.1303 1304 The `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 lines1353 Same as `execa()` but using the `node` option.1354 1355 Executes a Node.js file using `node scriptPath ...arguments`.1356 1357+This is the preferred method when executing Node.js files.1358+1359 @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 linesmodified:readme.md+33 added-21 removed
238 unmodified lines239 ### Methods240 241 #### execa(file, arguments?, options?)242 243-Executes 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)247 248+Executes a command using `file ...arguments`.249+250 Arguments are [automatically escaped](#shell-syntax). They can contain any character, including spaces.251 252 This is the preferred method when executing single commands.253 254 #### $\`command\`255+#### $(options)\`command\`256 251-Executes 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)260 253-Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must use `${}` like `` $`echo ${'has space'}` ``.261+Executes a command. The `command` string includes both the `file` and its `arguments`.262 263+Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces, tabs and newlines must use `${}` like `` $`echo ${'has space'}` ``.264+265 This is the preferred method when executing multiple commands in a script file.266 267 The `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 lines271 For more information, please see [this section](#scripts-interface) and [this page](docs/scripts.md).272 273 #### $(options)274 265-Returns 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)277 278+Returns a new instance of [`$`](#command) but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.279+280 This can be used to either:281 - Set options for a specific command: `` $(options)`command` ``282 - Share options for multiple commands: `` const $$ = $(options); $$`command`; $$`otherCommand`; ``283 284 #### execaCommand(command, options?)285 273-Executes 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)289 290+Executes a command. The `command` string includes both the `file` and its `arguments`.291+292 Arguments are [automatically escaped](#shell-syntax). They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.293 294 This is the preferred method when executing a user-supplied `command` string, such as in a REPL.295 296 #### execaNode(scriptPath, arguments?, options?)297 298+`file`: `string | URL`\299+`arguments`: `string[]`\300+`options`: [`Options`](#options-1)\301+_Returns_: [`ChildProcess`](#childprocess)302+303 Same as [`execa()`](#execacommandcommand-options) but using the [`node`](#node) option.304 305 Executes a Node.js file using `node scriptPath ...arguments`.306 285-#### execaSync(file, arguments?, options?)307+This is the preferred method when executing Node.js files.308 287-Same as [`execa()`](#execacommandcommand-options) but synchronous.288-289-Cannot 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.290-291-Returns 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.292-309+#### execaSync(file, arguments?, options?)310+#### execaCommandSync(command, options?)311 #### $.sync\`command\`312 #### $.s\`command\`313+#### $.sync(options)\`command\`314+#### $.s(options)\`command\`315 296-Same as [$\`command\`](#command) but synchronous.316+Same as [`execa()`](#execacommandcommand-options), [`execaCommand()`](#execacommand-command-options), [$\`command\`](#command) but synchronous.317 318 Cannot 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.319 320 Returns 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.321 302-#### execaCommandSync(command, options?)303-304-Same as [`execaCommand()`](#execacommand-command-options) but synchronous.305-306-Cannot 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.307-308-Returns 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.309-322 ### Shell syntax323 324 For 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