basant307/AI_Governance_Project
048
1import {type Buffer} from 'node:buffer';2import {type ChildProcess} from 'node:child_process';3import {type Stream, type Readable as ReadableStream, type Writable as WritableStream} from 'node:stream';4 5export type StdioOption =6 | 'pipe'7 | 'overlapped'8 | 'ipc'9 | 'ignore'10 | 'inherit'11 | Stream12 | number13 | undefined;14 15type EncodingOption =16 | 'utf8'17 // eslint-disable-next-line unicorn/text-encoding-identifier-case18 | 'utf-8'19 | 'utf16le'20 | 'utf-16le'21 | 'ucs2'22 | 'ucs-2'23 | 'latin1'24 | 'binary'25 | 'ascii'26 | 'hex'27 | 'base64'28 | 'base64url'29 | 'buffer'30 | null31 | undefined;32type DefaultEncodingOption = 'utf8';33type BufferEncodingOption = 'buffer' | null;34 35export type CommonOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {36 /**37 Kill the spawned process when the parent process exits unless either:38 - the spawned process is [`detached`](https://nodejs.org/api/child_process.html#child_process_options_detached)39 - the parent process is terminated abruptly, for example, with `SIGKILL` as opposed to `SIGTERM` or a normal exit40 41 @default true42 */43 readonly cleanup?: boolean;44 45 /**46 Prefer locally installed binaries when looking for a binary to execute.47 48 If you `$ npm install foo`, you can then `execa('foo')`.49 50 @default `true` with `$`, `false` otherwise51 */52 readonly preferLocal?: boolean;53 54 /**55 Preferred path to find locally installed binaries in (use with `preferLocal`).56 57 @default process.cwd()58 */59 readonly localDir?: string | URL;60 61 /**62 Path to the Node.js executable to use in child processes.63 64 This can be either an absolute path or a path relative to the `cwd` option.65 66 Requires `preferLocal` to be `true`.67 68 For example, this can be used together with [`get-node`](https://github.com/ehmicky/get-node) to run a specific Node.js version in a child process.69 70 @default process.execPath71 */72 readonly execPath?: string;73 74 /**75 Buffer the output from the spawned process. When set to `false`, you must read the output of `stdout` and `stderr` (or `all` if the `all` option is `true`). Otherwise the returned promise will not be resolved/rejected.76 77 If the spawned process fails, `error.stdout`, `error.stderr`, and `error.all` will contain the buffered data.78 79 @default true80 */81 readonly buffer?: boolean;82 83 /**84 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).85 86 @default `inherit` with `$`, `pipe` otherwise87 */88 readonly stdin?: StdioOption;89 90 /**91 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).92 93 @default 'pipe'94 */95 readonly stdout?: StdioOption;96 97 /**98 Same options as [`stdio`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio).99 100 @default 'pipe'101 */102 readonly stderr?: StdioOption;103 104 /**105 Setting this to `false` resolves the promise with the error instead of rejecting it.106 107 @default true108 */109 readonly reject?: boolean;110 111 /**112 Add an `.all` property on the promise and the resolved value. The property contains the output of the process with `stdout` and `stderr` interleaved.113 114 @default false115 */116 readonly all?: boolean;117 118 /**119 Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.120 121 @default true122 */123 readonly stripFinalNewline?: boolean;124 125 /**126 Set to `false` if you don't want to extend the environment variables when providing the `env` property.127 128 @default true129 */130 readonly extendEnv?: boolean;131 132 /**133 Current working directory of the child process.134 135 @default process.cwd()136 */137 readonly cwd?: string | URL;138 139 /**140 Environment key-value pairs. Extends automatically from `process.env`. Set `extendEnv` to `false` if you don't want this.141 142 @default process.env143 */144 readonly env?: NodeJS.ProcessEnv;145 146 /**147 Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` or `file` if not specified.148 */149 readonly argv0?: string;150 151 /**152 Child's [stdio](https://nodejs.org/api/child_process.html#child_process_options_stdio) configuration.153 154 @default 'pipe'155 */156 readonly stdio?: 'pipe' | 'overlapped' | 'ignore' | 'inherit' | readonly StdioOption[];157 158 /**159 Specify the kind of serialization used for sending messages between processes when using the `stdio: 'ipc'` option or `execaNode()`:160 - `json`: Uses `JSON.stringify()` and `JSON.parse()`.161 - `advanced`: Uses [`v8.serialize()`](https://nodejs.org/api/v8.html#v8_v8_serialize_value)162 163 [More info.](https://nodejs.org/api/child_process.html#child_process_advanced_serialization)164 165 @default 'json'166 */167 readonly serialization?: 'json' | 'advanced';168 169 /**170 Prepare child to run independently of its parent process. Specific behavior [depends on the platform](https://nodejs.org/api/child_process.html#child_process_options_detached).171 172 @default false173 */174 readonly detached?: boolean;175 176 /**177 Sets the user identity of the process.178 */179 readonly uid?: number;180 181 /**182 Sets the group identity of the process.183 */184 readonly gid?: number;185 186 /**187 If `true`, runs `command` inside of a shell. Uses `/bin/sh` on UNIX and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.188 189 We recommend against using this option since it is:190 - not cross-platform, encouraging shell-specific syntax.191 - slower, because of the additional shell interpretation.192 - unsafe, potentially allowing command injection.193 194 @default false195 */196 readonly shell?: boolean | string;197 198 /**199 Specify the character encoding used to decode the `stdout` and `stderr` output. If set to `'buffer'` or `null`, then `stdout` and `stderr` will be a `Buffer` instead of a string.200 201 @default 'utf8'202 */203 readonly encoding?: EncodingType;204 205 /**206 If `timeout` is greater than `0`, the parent will send the signal identified by the `killSignal` property (the default is `SIGTERM`) if the child runs longer than `timeout` milliseconds.207 208 @default 0209 */210 readonly timeout?: number;211 212 /**213 Largest amount of data in bytes allowed on `stdout` or `stderr`. Default: 100 MB.214 215 @default 100_000_000216 */217 readonly maxBuffer?: number;218 219 /**220 Signal value to be used when the spawned process will be killed.221 222 @default 'SIGTERM'223 */224 readonly killSignal?: string | number;225 226 /**227 You can abort the spawned process using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).228 229 When `AbortController.abort()` is called, [`.isCanceled`](https://github.com/sindresorhus/execa#iscanceled) becomes `true`.230 231 @example232 ```233 import {execa} from 'execa';234 235 const abortController = new AbortController();236 const subprocess = execa('node', [], {signal: abortController.signal});237 238 setTimeout(() => {239 abortController.abort();240 }, 1000);241 242 try {243 await subprocess;244 } catch (error) {245 console.log(subprocess.killed); // true246 console.log(error.isCanceled); // true247 }248 ```249 */250 readonly signal?: AbortSignal;251 252 /**253 If `true`, no quoting or escaping of arguments is done on Windows. Ignored on other platforms. This is set to `true` automatically when the `shell` option is `true`.254 255 @default false256 */257 readonly windowsVerbatimArguments?: boolean;258 259 /**260 On Windows, do not create a new console window. Please note this also prevents `CTRL-C` [from working](https://github.com/nodejs/node/issues/29837) on Windows.261 262 @default true263 */264 readonly windowsHide?: boolean;265 266 /**267 Print each command on `stderr` before executing it.268 269 This can also be enabled by setting the `NODE_DEBUG=execa` environment variable in the current process.270 271 @default false272 */273 readonly verbose?: boolean;274};275 276export type Options<EncodingType extends EncodingOption = DefaultEncodingOption> = {277 /**278 Write some input to the `stdin` of your binary.279 280 If the input is a file, use the `inputFile` option instead.281 */282 readonly input?: string | Buffer | ReadableStream;283 284 /**285 Use a file as input to the the `stdin` of your binary.286 287 If the input is not a file, use the `input` option instead.288 */289 readonly inputFile?: string;290} & CommonOptions<EncodingType>;291 292export type SyncOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {293 /**294 Write some input to the `stdin` of your binary.295 296 If the input is a file, use the `inputFile` option instead.297 */298 readonly input?: string | Buffer;299 300 /**301 Use a file as input to the the `stdin` of your binary.302 303 If the input is not a file, use the `input` option instead.304 */305 readonly inputFile?: string;306} & CommonOptions<EncodingType>;307 308export type NodeOptions<EncodingType extends EncodingOption = DefaultEncodingOption> = {309 /**310 The Node.js executable to use.311 312 @default process.execPath313 */314 readonly nodePath?: string;315 316 /**317 List of [CLI options](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.318 319 @default process.execArgv320 */321 readonly nodeOptions?: string[];322} & Options<EncodingType>;323 324type StdoutStderrAll = string | Buffer | undefined;325 326export type ExecaReturnBase<StdoutStderrType extends StdoutStderrAll> = {327 /**328 The file and arguments that were run, for logging purposes.329 330 This is not escaped and should not be executed directly as a process, including using `execa()` or `execaCommand()`.331 */332 command: string;333 334 /**335 Same as `command` but escaped.336 337 This is meant to be copy and pasted into a shell, for debugging purposes.338 Since the escaping is fairly basic, this should not be executed directly as a process, including using `execa()` or `execaCommand()`.339 */340 escapedCommand: string;341 342 /**343 The numeric exit code of the process that was run.344 */345 exitCode: number;346 347 /**348 The output of the process on stdout.349 */350 stdout: StdoutStderrType;351 352 /**353 The output of the process on stderr.354 */355 stderr: StdoutStderrType;356 357 /**358 Whether the process failed to run.359 */360 failed: boolean;361 362 /**363 Whether the process timed out.364 */365 timedOut: boolean;366 367 /**368 Whether the process was killed.369 */370 killed: boolean;371 372 /**373 The name of the signal that was used to terminate the process. For example, `SIGFPE`.374 375 If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`.376 */377 signal?: string;378 379 /**380 A human-friendly description of the signal that was used to terminate the process. For example, `Floating point arithmetic error`.381 382 If a signal terminated the process, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.383 */384 signalDescription?: string;385 386 /**387 The `cwd` of the command if provided in the command options. Otherwise it is `process.cwd()`.388 */389 cwd: string;390};391 392export type ExecaSyncReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {393} & ExecaReturnBase<StdoutStderrType>;394 395/**396Result of a child process execution. On success this is a plain object. On failure this is also an `Error` instance.397 398The child process fails when:399- its exit code is not `0`400- it was killed with a signal401- timing out402- being canceled403- there's not enough memory or there are already too many child processes404*/405export type ExecaReturnValue<StdoutStderrType extends StdoutStderrAll = string> = {406 /**407 The output of the process with `stdout` and `stderr` interleaved.408 409 This is `undefined` if either:410 - the `all` option is `false` (default value)411 - `execaSync()` was used412 */413 all?: StdoutStderrType;414 415 /**416 Whether the process was canceled.417 418 You can cancel the spawned process using the [`signal`](https://github.com/sindresorhus/execa#signal-1) option.419 */420 isCanceled: boolean;421} & ExecaSyncReturnValue<StdoutStderrType>;422 423export type ExecaSyncError<StdoutStderrType extends StdoutStderrAll = string> = {424 /**425 Error message when the child process failed to run. In addition to the underlying error message, it also contains some information related to why the child process errored.426 427 The child process stderr then stdout are appended to the end, separated with newlines and not interleaved.428 */429 message: string;430 431 /**432 This is the same as the `message` property except it does not include the child process stdout/stderr.433 */434 shortMessage: string;435 436 /**437 Original error message. This is the same as the `message` property except it includes neither the child process stdout/stderr nor some additional information added by Execa.438 439 This is `undefined` unless the child process exited due to an `error` event or a timeout.440 */441 originalMessage?: string;442} & Error & ExecaReturnBase<StdoutStderrType>;443 444export type ExecaError<StdoutStderrType extends StdoutStderrAll = string> = {445 /**446 The output of the process with `stdout` and `stderr` interleaved.447 448 This is `undefined` if either:449 - the `all` option is `false` (default value)450 - `execaSync()` was used451 */452 all?: StdoutStderrType;453 454 /**455 Whether the process was canceled.456 */457 isCanceled: boolean;458} & ExecaSyncError<StdoutStderrType>;459 460export type KillOptions = {461 /**462 Milliseconds to wait for the child process to terminate before sending `SIGKILL`.463 464 Can be disabled with `false`.465 466 @default 5000467 */468 forceKillAfterTimeout?: number | false;469};470 471export type ExecaChildPromise<StdoutStderrType extends StdoutStderrAll> = {472 /**473 Stream combining/interleaving [`stdout`](https://nodejs.org/api/child_process.html#child_process_subprocess_stdout) and [`stderr`](https://nodejs.org/api/child_process.html#child_process_subprocess_stderr).474 475 This is `undefined` if either:476 - the `all` option is `false` (the default value)477 - both `stdout` and `stderr` options are set to [`'inherit'`, `'ipc'`, `Stream` or `integer`](https://nodejs.org/dist/latest-v6.x/docs/api/child_process.html#child_process_options_stdio)478 */479 all?: ReadableStream;480 481 catch<ResultType = never>(482 onRejected?: (reason: ExecaError<StdoutStderrType>) => ResultType | PromiseLike<ResultType>483 ): Promise<ExecaReturnValue<StdoutStderrType> | ResultType>;484 485 /**486 Same as the original [`child_process#kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal), except if `signal` is `SIGTERM` (the default value) and the child process is not terminated after 5 seconds, force it by sending `SIGKILL`. Note that this graceful termination does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events) (`SIGKILL` and `SIGTERM` has the same effect of force-killing the process immediately.) If you want to achieve graceful termination on Windows, you have to use other means, such as [`taskkill`](https://github.com/sindresorhus/taskkill).487 */488 kill(signal?: string, options?: KillOptions): void;489 490 /**491 Similar to [`childProcess.kill()`](https://nodejs.org/api/child_process.html#child_process_subprocess_kill_signal). This used to be preferred when cancelling the child process execution as the error is more descriptive and [`childProcessResult.isCanceled`](#iscanceled) is set to `true`. But now this is deprecated and you should either use `.kill()` or the `signal` option when creating the child process.492 */493 cancel(): void;494 495 /**496 [Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the child process's `stdout` to `target`, which can be:497 - Another `execa()` return value498 - A writable stream499 - A file path string500 501 If the `target` is another `execa()` return value, it is returned. Otherwise, the original `execa()` return value is returned. This allows chaining `pipeStdout()` then `await`ing the final result.502 503 The `stdout` option] must be kept as `pipe`, its default value.504 */505 pipeStdout?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;506 pipeStdout?(target: WritableStream | string): ExecaChildProcess<StdoutStderrType>;507 508 /**509 Like `pipeStdout()` but piping the child process's `stderr` instead.510 511 The `stderr` option must be kept as `pipe`, its default value.512 */513 pipeStderr?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;514 pipeStderr?(target: WritableStream | string): ExecaChildProcess<StdoutStderrType>;515 516 /**517 Combines both `pipeStdout()` and `pipeStderr()`.518 519 Either the `stdout` option or the `stderr` option must be kept as `pipe`, their default value. Also, the `all` option must be set to `true`.520 */521 pipeAll?<Target extends ExecaChildPromise<StdoutStderrAll>>(target: Target): Target;522 pipeAll?(target: WritableStream | string): ExecaChildProcess<StdoutStderrType>;523};524 525export type ExecaChildProcess<StdoutStderrType extends StdoutStderrAll = string> = ChildProcess &526ExecaChildPromise<StdoutStderrType> &527Promise<ExecaReturnValue<StdoutStderrType>>;528 529/**530Executes a command using `file ...arguments`. `arguments` are specified as an array of strings. Returns a `childProcess`.531 532Arguments are automatically escaped. They can contain any character, including spaces.533 534This is the preferred method when executing single commands.535 536@param file - The program/script to execute.537@param arguments - Arguments to pass to `file` on execution.538@returns An `ExecaChildProcess` that is both:539 - a `Promise` resolving or rejecting with a `childProcessResult`.540 - a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with some additional methods and properties.541@throws A `childProcessResult` error542 543@example <caption>Promise interface</caption>544```545import {execa} from 'execa';546 547const {stdout} = await execa('echo', ['unicorns']);548console.log(stdout);549//=> 'unicorns'550```551 552@example <caption>Redirect output to a file</caption>553```554import {execa} from 'execa';555 556// Similar to `echo unicorns > stdout.txt` in Bash557await execa('echo', ['unicorns']).pipeStdout('stdout.txt');558 559// Similar to `echo unicorns 2> stdout.txt` in Bash560await execa('echo', ['unicorns']).pipeStderr('stderr.txt');561 562// Similar to `echo unicorns &> stdout.txt` in Bash563await execa('echo', ['unicorns'], {all: true}).pipeAll('all.txt');564```565 566@example <caption>Redirect input from a file</caption>567```568import {execa} from 'execa';569 570// Similar to `cat < stdin.txt` in Bash571const {stdout} = await execa('cat', {inputFile: 'stdin.txt'});572console.log(stdout);573//=> 'unicorns'574```575 576@example <caption>Save and pipe output from a child process</caption>577```578import {execa} from 'execa';579 580const {stdout} = await execa('echo', ['unicorns']).pipeStdout(process.stdout);581// Prints `unicorns`582console.log(stdout);583// Also returns 'unicorns'584```585 586@example <caption>Pipe multiple processes</caption>587```588import {execa} from 'execa';589 590// Similar to `echo unicorns | cat` in Bash591const {stdout} = await execa('echo', ['unicorns']).pipeStdout(execa('cat'));592console.log(stdout);593//=> 'unicorns'594```595 596@example <caption>Handling errors</caption>597```598import {execa} from 'execa';599 600// Catching an error601try {602 await execa('unknown', ['command']);603} catch (error) {604 console.log(error);605 /*606 {607 message: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',608 errno: -2,609 code: 'ENOENT',610 syscall: 'spawn unknown',611 path: 'unknown',612 spawnargs: ['command'],613 originalMessage: 'spawn unknown ENOENT',614 shortMessage: 'Command failed with ENOENT: unknown command spawn unknown ENOENT',615 command: 'unknown command',616 escapedCommand: 'unknown command',617 stdout: '',618 stderr: '',619 failed: true,620 timedOut: false,621 isCanceled: false,622 killed: false,623 cwd: '/path/to/cwd'624 }625 \*\/626}627```628 629@example <caption>Graceful termination</caption>630```631const subprocess = execa('node');632 633setTimeout(() => {634 subprocess.kill('SIGTERM', {635 forceKillAfterTimeout: 2000636 });637}, 1000);638```639*/640export function execa(641 file: string,642 arguments?: readonly string[],643 options?: Options644): ExecaChildProcess;645export function execa(646 file: string,647 arguments?: readonly string[],648 options?: Options<BufferEncodingOption>649): ExecaChildProcess<Buffer>;650export function execa(file: string, options?: Options): ExecaChildProcess;651export function execa(file: string, options?: Options<BufferEncodingOption>): ExecaChildProcess<Buffer>;652 653/**654Same as `execa()` but synchronous.655 656@param file - The program/script to execute.657@param arguments - Arguments to pass to `file` on execution.658@returns A `childProcessResult` object659@throws A `childProcessResult` error660 661@example <caption>Promise interface</caption>662```663import {execa} from 'execa';664 665const {stdout} = execaSync('echo', ['unicorns']);666console.log(stdout);667//=> 'unicorns'668```669 670@example <caption>Redirect input from a file</caption>671```672import {execa} from 'execa';673 674// Similar to `cat < stdin.txt` in Bash675const {stdout} = execaSync('cat', {inputFile: 'stdin.txt'});676console.log(stdout);677//=> 'unicorns'678```679 680@example <caption>Handling errors</caption>681```682import {execa} from 'execa';683 684// Catching an error685try {686 execaSync('unknown', ['command']);687} catch (error) {688 console.log(error);689 /*690 {691 message: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT',692 errno: -2,693 code: 'ENOENT',694 syscall: 'spawnSync unknown',695 path: 'unknown',696 spawnargs: ['command'],697 originalMessage: 'spawnSync unknown ENOENT',698 shortMessage: 'Command failed with ENOENT: unknown command spawnSync unknown ENOENT',699 command: 'unknown command',700 escapedCommand: 'unknown command',701 stdout: '',702 stderr: '',703 failed: true,704 timedOut: false,705 isCanceled: false,706 killed: false,707 cwd: '/path/to/cwd'708 }709 \*\/710}711```712*/713export function execaSync(714 file: string,715 arguments?: readonly string[],716 options?: SyncOptions717): ExecaSyncReturnValue;718export function execaSync(719 file: string,720 arguments?: readonly string[],721 options?: SyncOptions<BufferEncodingOption>722): ExecaSyncReturnValue<Buffer>;723export function execaSync(file: string, options?: SyncOptions): ExecaSyncReturnValue;724export function execaSync(725 file: string,726 options?: SyncOptions<BufferEncodingOption>727): ExecaSyncReturnValue<Buffer>;728 729/**730Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.731 732Arguments are automatically escaped. They can contain any character, but spaces must be escaped with a backslash like `execaCommand('echo has\\ space')`.733 734This is the preferred method when executing a user-supplied `command` string, such as in a REPL.735 736@param command - The program/script to execute and its arguments.737@returns An `ExecaChildProcess` that is both:738 - a `Promise` resolving or rejecting with a `childProcessResult`.739 - a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with some additional methods and properties.740@throws A `childProcessResult` error741 742@example743```744import {execaCommand} from 'execa';745 746const {stdout} = await execaCommand('echo unicorns');747console.log(stdout);748//=> 'unicorns'749```750*/751export function execaCommand(command: string, options?: Options): ExecaChildProcess;752export function execaCommand(command: string, options?: Options<BufferEncodingOption>): ExecaChildProcess<Buffer>;753 754/**755Same as `execaCommand()` but synchronous.756 757@param command - The program/script to execute and its arguments.758@returns A `childProcessResult` object759@throws A `childProcessResult` error760 761@example762```763import {execaCommandSync} from 'execa';764 765const {stdout} = execaCommandSync('echo unicorns');766console.log(stdout);767//=> 'unicorns'768```769*/770export function execaCommandSync(command: string, options?: SyncOptions): ExecaSyncReturnValue;771export function execaCommandSync(command: string, options?: SyncOptions<BufferEncodingOption>): ExecaSyncReturnValue<Buffer>;772 773type TemplateExpression =774 | string775 | number776 | ExecaReturnValue<string | Buffer>777 | ExecaSyncReturnValue<string | Buffer>778 | Array<string | number | ExecaReturnValue<string | Buffer> | ExecaSyncReturnValue<string | Buffer>>;779 780type Execa$<StdoutStderrType extends StdoutStderrAll = string> = {781 /**782 Returns a new instance of `$` but with different default `options`. Consecutive calls are merged to previous ones.783 784 This can be used to either:785 - Set options for a specific command: `` $(options)`command` ``786 - Share options for multiple commands: `` const $$ = $(options); $$`command`; $$`otherCommand` ``787 788 @param options - Options to set789 @returns A new instance of `$` with those `options` set790 791 @example792 ```793 import {$} from 'execa';794 795 const $$ = $({stdio: 'inherit'});796 797 await $$`echo unicorns`;798 //=> 'unicorns'799 800 await $$`echo rainbows`;801 //=> 'rainbows'802 ```803 */804 (options: Options<undefined>): Execa$<StdoutStderrType>;805 (options: Options): Execa$;806 (options: Options<BufferEncodingOption>): Execa$<Buffer>;807 (808 templates: TemplateStringsArray,809 ...expressions: TemplateExpression[]810 ): ExecaChildProcess<StdoutStderrType>;811 812 /**813 Same as $\`command\` but synchronous.814 815 @returns A `childProcessResult` object816 @throws A `childProcessResult` error817 818 @example <caption>Basic</caption>819 ```820 import {$} from 'execa';821 822 const branch = $.sync`git branch --show-current`;823 $.sync`dep deploy --branch=${branch}`;824 ```825 826 @example <caption>Multiple arguments</caption>827 ```828 import {$} from 'execa';829 830 const args = ['unicorns', '&', 'rainbows!'];831 const {stdout} = $.sync`echo ${args}`;832 console.log(stdout);833 //=> 'unicorns & rainbows!'834 ```835 836 @example <caption>With options</caption>837 ```838 import {$} from 'execa';839 840 $.sync({stdio: 'inherit'})`echo unicorns`;841 //=> 'unicorns'842 ```843 844 @example <caption>Shared options</caption>845 ```846 import {$} from 'execa';847 848 const $$ = $({stdio: 'inherit'});849 850 $$.sync`echo unicorns`;851 //=> 'unicorns'852 853 $$.sync`echo rainbows`;854 //=> 'rainbows'855 ```856 */857 sync(858 templates: TemplateStringsArray,859 ...expressions: TemplateExpression[]860 ): ExecaSyncReturnValue<StdoutStderrType>;861};862 863/**864Executes a command. The `command` string includes both the `file` and its `arguments`. Returns a `childProcess`.865 866Arguments are automatically escaped. They can contain any character, but spaces must use `${}` like `` $`echo ${'has space'}` ``.867 868This is the preferred method when executing multiple commands in a script file.869 870The `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.871 872@returns An `ExecaChildProcess` that is both:873 - a `Promise` resolving or rejecting with a `childProcessResult`.874 - a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with some additional methods and properties.875@throws A `childProcessResult` error876 877@example <caption>Basic</caption>878```879import {$} from 'execa';880 881const branch = await $`git branch --show-current`;882await $`dep deploy --branch=${branch}`;883```884 885@example <caption>Multiple arguments</caption>886```887import {$} from 'execa';888 889const args = ['unicorns', '&', 'rainbows!'];890const {stdout} = await $`echo ${args}`;891console.log(stdout);892//=> 'unicorns & rainbows!'893```894 895@example <caption>With options</caption>896```897import {$} from 'execa';898 899await $({stdio: 'inherit'})`echo unicorns`;900//=> 'unicorns'901```902 903@example <caption>Shared options</caption>904```905import {$} from 'execa';906 907const $$ = $({stdio: 'inherit'});908 909await $$`echo unicorns`;910//=> 'unicorns'911 912await $$`echo rainbows`;913//=> 'rainbows'914```915*/916export const $: Execa$;917 918/**919Execute a Node.js script as a child process.920 921Arguments are automatically escaped. They can contain any character, including spaces.922 923This is the preferred method when executing Node.js files.924 925Like [`child_process#fork()`](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options):926 - the current Node version and options are used. This can be overridden using the `nodePath` and `nodeOptions` options.927 - the `shell` option cannot be used928 - an extra channel [`ipc`](https://nodejs.org/api/child_process.html#child_process_options_stdio) is passed to `stdio`929 930@param scriptPath - Node.js script to execute.931@param arguments - Arguments to pass to `scriptPath` on execution.932@returns An `ExecaChildProcess` that is both:933 - a `Promise` resolving or rejecting with a `childProcessResult`.934 - a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with some additional methods and properties.935@throws A `childProcessResult` error936 937@example938```939import {execa} from 'execa';940 941await execaNode('scriptPath', ['argument']);942```943*/944export function execaNode(945 scriptPath: string,946 arguments?: readonly string[],947 options?: NodeOptions948): ExecaChildProcess;949export function execaNode(950 scriptPath: string,951 arguments?: readonly string[],952 options?: NodeOptions<BufferEncodingOption>953): ExecaChildProcess<Buffer>;954export function execaNode(scriptPath: string, options?: NodeOptions): ExecaChildProcess;955export function execaNode(scriptPath: string, options?: NodeOptions<BufferEncodingOption>): ExecaChildProcess<Buffer>;956 