[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nindent_style = tab\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.yml]\nindent_style = space\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n"
  },
  {
    "path": ".github/codecov.yml",
    "content": "codecov:\n  notify:\n    after_n_builds: 6\n"
  },
  {
    "path": ".github/security.md",
    "content": "# Security Policy\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\non:\n  - push\n  - pull_request\njobs:\n  test:\n    name: Node.js ${{ matrix.node-version }} on ${{ matrix.os }}\n    runs-on: ${{ matrix.os }}-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version:\n          - 24\n          - 18\n        os:\n          - ubuntu\n          - macos\n          - windows\n    steps:\n      - uses: actions/cache@v4\n        with:\n          path: .lycheecache\n          key: cache-lychee-${{ github.sha }}\n          restore-keys: cache-lychee-\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: ${{ matrix.node-version }}\n      - run: npm install\n      - uses: lycheeverse/lychee-action@v1\n        with:\n          args: --cache --verbose --no-progress --include-fragments --exclude packagephobia --exclude /pull/ --exclude linkedin --exclude stackoverflow --exclude stackexchange --exclude github.com/nodejs/node --exclude file:///test --exclude invalid.com '*.md' 'docs/*.md' '.github/**/*.md' '*.json' '*.js' 'lib/**/*.js' 'test/**/*.js' '*.ts' 'test-d/**/*.ts'\n          fail: true\n        if: ${{ matrix.os == 'ubuntu' && matrix.node-version == 24 }}\n      - run: npm run lint\n      - run: npm run type\n      - run: npm run unit\n      - uses: codecov/codecov-action@v4\n        with:\n          token: ${{ secrets.CODECOV_TOKEN }}\n          flags: '${{ matrix.os }}, node-${{ matrix.node-version }}'\n          fail_ci_if_error: false\n          verbose: true\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nyarn.lock\n.nyc_output\ncoverage\n"
  },
  {
    "path": ".npmrc",
    "content": "package-lock=false\n"
  },
  {
    "path": "docs/api.md",
    "content": "<picture>\n       <source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n       <img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 📔 API reference\n\nThis lists all available [methods](#methods) and their [options](#options-1). This also describes the properties of the [subprocess](#subprocess), [result](#result) and [error](#execaerror) they return.\n\n## Methods\n\n### execa(file, arguments?, options?)\n\n`file`: `string | URL`\\\n`arguments`: `string[]`\\\n`options`: [`Options`](#options-1)\\\n_Returns_: [`ResultPromise`](#return-value)\n\nExecutes a command using `file ...arguments`.\n\nMore info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).\n\n### $(file, arguments?, options?)\n\n`file`: `string | URL`\\\n`arguments`: `string[]`\\\n`options`: [`Options`](#options-1)\\\n_Returns_: [`ResultPromise`](#return-value)\n\nSame as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).\n\nThis is the preferred method when executing multiple commands in a script file.\n\n[More info.](scripts.md)\n\n### execaNode(scriptPath, arguments?, options?)\n\n`scriptPath`: `string | URL`\\\n`arguments`: `string[]`\\\n`options`: [`Options`](#options-1)\\\n_Returns_: [`ResultPromise`](#return-value)\n\nSame as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.\nExecutes a Node.js file using `node scriptPath ...arguments`.\n\nThis is the preferred method when executing Node.js files.\n\n[More info.](node.md)\n\n### execaSync(file, arguments?, options?)\n### $.sync(file, arguments?, options?)\n### $.s(file, arguments?, options?)\n\n`file`: `string | URL`\\\n`arguments`: `string[]`\\\n`options`: [`SyncOptions`](#options-1)\\\n_Returns_: [`SyncResult`](#return-value)\n\nSame as [`execa()`](#execafile-arguments-options) and [`$`](#file-arguments-options) but synchronous.\n\nReturns a subprocess [`result`](#result) or throws an [`error`](#execasyncerror). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.\n\nThose methods are discouraged as they hold the CPU and lack multiple features.\n\n[More info.](execution.md#synchronous-execution)\n\n### execa\\`command\\`\n### $\\`command\\`\n### execaNode\\`command\\`\n### execaSync\\`command\\`\n### $.sync\\`command\\`\n### $.s\\`command\\`\n\n`command`: `string`\\\n_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)\n\nSame as [`execa()`](#execafile-arguments-options), [`$()`](#file-arguments-options), [`execaNode()`](#execanodescriptpath-arguments-options) and [`execaSync()`](#execasyncfile-arguments-options) but using a [template string](execution.md#template-string-syntax). `command` includes both the `file` and its `arguments`.\n\nMore info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).\n\n### execa(options)\\`command\\`\n### $(options)\\`command\\`\n### execaNode(options)\\`command\\`\n### execaSync(options)\\`command\\`\n### $.sync(options)\\`command\\`\n### $.s(options)\\`command\\`\n\n`command`: `string`\\\n`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\\\n_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)\n\nSame as [```execa`command` ```](#execacommand) but with [options](#options-1).\n\n[More info.](execution.md#template-string-syntax)\n\n### execa(options)\n### $(options)\n### execaNode(options)\n### execaSync(options)\n### $.sync(options)\n### $.s(options)\n\n`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\\\n_Returns_: [`ExecaMethod`](#execafile-arguments-options), [`ExecaScriptMethod`](#file-arguments-options), [`ExecaNodeMethod`](#execanodescriptpath-arguments-options), [`ExecaSyncMethod`](#execasyncfile-arguments-options), [`ExecaScriptSyncMethod`](#syncfile-arguments-options)\n\nReturns a new instance of those methods but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.\n\n[More info.](execution.md#globalshared-options)\n\n### parseCommandString(command)\n\n`command`: `string`\\\n_Returns_: `string[]`\n\nSplit a `command` string into an array. For example, `'npm run build'` returns `['npm', 'run', 'build']` and `'argument otherArgument'` returns `['argument', 'otherArgument']`.\n\n[More info.](escaping.md#user-defined-input)\n\n### sendMessage(message, sendMessageOptions?)\n\n`message`: [`Message`](ipc.md#message-type)\\\n`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\\\n_Returns_: `Promise<void>`\n\nSend a `message` to the parent process.\n\nThis requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.\n\n[More info.](ipc.md#exchanging-messages)\n\n#### sendMessageOptions\n\n_Type_: `object`\n\n#### sendMessageOptions.strict\n\n_Type_: `boolean`\\\n_Default_: `false`\n\nThrow when the other process is not receiving or listening to messages.\n\n[More info.](ipc.md#ensure-messages-are-received)\n\n### getOneMessage(getOneMessageOptions?)\n\n`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\\\n_Returns_: [`Promise<Message>`](ipc.md#message-type)\n\nReceive a single `message` from the parent process.\n\nThis requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.\n\n[More info.](ipc.md#exchanging-messages)\n\n#### getOneMessageOptions\n\n_Type_: `object`\n\n#### getOneMessageOptions.filter\n\n_Type_: [`(Message) => boolean`](ipc.md#message-type)\n\nIgnore any `message` that returns `false`.\n\n[More info.](ipc.md#filter-messages)\n\n#### getOneMessageOptions.reference\n\n_Type_: `boolean`\\\n_Default_: `true`\n\nKeep the subprocess alive while `getOneMessage()` is waiting.\n\n[More info.](ipc.md#keeping-the-subprocess-alive)\n\n### getEachMessage(getEachMessageOptions?)\n\n`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\\\n_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)\n\nIterate over each `message` from the parent process.\n\nThis requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.\n\n[More info.](ipc.md#listening-to-messages)\n\n#### getEachMessageOptions\n\n_Type_: `object`\n\n#### getEachMessageOptions.reference\n\n_Type_: `boolean`\\\n_Default_: `true`\n\nKeep the subprocess alive while `getEachMessage()` is waiting.\n\n[More info.](ipc.md#keeping-the-subprocess-alive)\n\n### getCancelSignal()\n\n_Returns_: [`Promise<AbortSignal>`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nRetrieves the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) shared by the [`cancelSignal`](#optionscancelsignal) option.\n\nThis can only be called inside a subprocess. This requires the [`gracefulCancel`](#optionsgracefulcancel) option to be `true`.\n\n[More info.](termination.md#graceful-termination)\n\n## Return value\n\n_TypeScript:_ [`ResultPromise`](typescript.md)\\\n_Type:_ `Promise<object> | Subprocess`\n\nThe return value of all [asynchronous methods](#methods) is both:\n- the [subprocess](#subprocess).\n- a `Promise` either resolving with its successful [`result`](#result), or rejecting with its [`error`](#execaerror).\n\n[More info.](execution.md#subprocess)\n\n## Subprocess\n\n_TypeScript:_ [`Subprocess`](typescript.md)\n\n[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.\n\n### subprocess\\[Symbol.asyncIterator\\]()\n\n_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)\n\nSubprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.\n\n[More info.](lines.md#progressive-splitting)\n\n### subprocess.iterable(readableOptions?)\n\n`readableOptions`: [`ReadableOptions`](#readableoptions)\\\n_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)\n\nSame as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.\n\n[More info.](lines.md#progressive-splitting)\n\n### subprocess.pipe(file, arguments?, options?)\n\n`file`: `string | URL`\\\n`arguments`: `string[]`\\\n`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\\\n_Returns_: [`Promise<Result>`](#result)\n\n[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' [`stdout`](#subprocessstdout) to a second Execa subprocess' [`stdin`](#subprocessstdin). This resolves with that second subprocess' [result](#result). If either subprocess is rejected, this is rejected with that subprocess' [error](#execaerror) instead.\n\nThis follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options-1) and [pipe-specific options](#pipeoptions) can be specified.\n\n[More info.](pipe.md#array-syntax)\n\n### subprocess.pipe\\`command\\`\n### subprocess.pipe(options)\\`command\\`\n\n`command`: `string`\\\n`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\\\n_Returns_: [`Promise<Result>`](#result)\n\nLike [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using a [`command` template string](execution.md#template-string-syntax) instead. This follows the same syntax as `execa` [template strings](execution.md#template-string-syntax).\n\n[More info.](pipe.md#template-string-syntax)\n\n### subprocess.pipe(secondSubprocess, pipeOptions?)\n\n`secondSubprocess`: [`ResultPromise`](#return-value)\\\n`pipeOptions`: [`PipeOptions`](#pipeoptions)\\\n_Returns_: [`Promise<Result>`](#result)\n\nLike [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using the [return value](#return-value) of another [`execa()`](#execafile-arguments-options) call instead.\n\n[More info.](pipe.md#advanced-syntax)\n\n#### pipeOptions\n\n_Type:_ `object`\n\n#### pipeOptions.from\n\n_Type:_ `\"stdout\" | \"stderr\" | \"all\" | \"fd3\" | \"fd4\" | ...`\\\n_Default:_ `\"stdout\"`\n\nWhich stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n`\"all\"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.\n\n[More info.](pipe.md#source-file-descriptor)\n\n#### pipeOptions.to\n\n_Type:_ `\"stdin\" | \"fd3\" | \"fd4\" | ...`\\\n_Default:_ `\"stdin\"`\n\nWhich [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n[More info.](pipe.md#destination-file-descriptor)\n\n#### pipeOptions.unpipeSignal\n\n_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nUnpipe the subprocess when the signal aborts.\n\n[More info.](pipe.md#unpipe)\n\n### subprocess.kill(signal, error?)\n### subprocess.kill(error?)\n\n`signal`: `string | number`\\\n`error`: `Error`\\\n_Returns_: `boolean`\n\nSends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the [`killSignal`](#optionskillsignal) option. `killSignal` defaults to `SIGTERM`, which [terminates](#erroristerminated) the subprocess.\n\nThis returns `false` when the signal could not be sent, for example when the subprocess has already exited.\n\nWhen an error is passed as argument, it is set to the subprocess' [`error.cause`](#errorcause). The subprocess is then terminated with the default signal. This does not emit the [`error` event](https://nodejs.org/api/child_process.html#event-error).\n\n[More info.](termination.md)\n\n### subprocess.pid\n\n_Type:_ `number | undefined`\n\nProcess identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).\n\nThis is `undefined` if the subprocess failed to spawn.\n\n[More info.](termination.md#inter-process-termination)\n\n### subprocess.sendMessage(message, sendMessageOptions)\n\n`message`: [`Message`](ipc.md#message-type)\\\n`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\\\n_Returns_: `Promise<void>`\n\nSend a `message` to the subprocess.\n\nThis requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.\n\n[More info.](ipc.md#exchanging-messages)\n\n### subprocess.getOneMessage(getOneMessageOptions?)\n\n`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\\\n_Returns_: [`Promise<Message>`](ipc.md#message-type)\n\nReceive a single `message` from the subprocess.\n\nThis requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.\n\n[More info.](ipc.md#exchanging-messages)\n\n### subprocess.getEachMessage(getEachMessageOptions?)\n\n`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\\\n_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)\n\nIterate over each `message` from the subprocess.\n\nThis requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.\n\n[More info.](ipc.md#listening-to-messages)\n\n### subprocess.stdin\n\n_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)\n\nThe subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.\n\nThis is `null` if the [`stdin`](#optionsstdin) option is set to [`'inherit'`](input.md#terminal-input), [`'ignore'`](input.md#ignore-input), [`Readable`](streams.md#input) or [`integer`](input.md#terminal-input).\n\n[More info.](streams.md#manual-streaming)\n\n### subprocess.stdout\n\n_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)\n\nThe subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.\n\nThis is `null` if the [`stdout`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\n[More info.](streams.md#manual-streaming)\n\n### subprocess.stderr\n\n_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)\n\nThe subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.\n\nThis is `null` if the [`stderr`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\n[More info.](streams.md#manual-streaming)\n\n### subprocess.all\n\n_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)\n\nStream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).\n\nThis requires the [`all`](#optionsall) option to be `true`.\n\nThis is `undefined` if [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\nMore info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).\n\n### subprocess.stdio\n\n_Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)\n\nThe subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.\n\nEach array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Stream`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\n[More info.](streams.md#manual-streaming)\n\n### subprocess.readable(readableOptions?)\n\n`readableOptions`: [`ReadableOptions`](#readableoptions)\\\n_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream\n\nConverts the subprocess to a readable stream.\n\n[More info.](streams.md#converting-a-subprocess-to-a-stream)\n\n#### readableOptions\n\n_Type:_ `object`\n\n#### readableOptions.from\n\n_Type:_ `\"stdout\" | \"stderr\" | \"all\" | \"fd3\" | \"fd4\" | ...`\\\n_Default:_ `\"stdout\"`\n\nWhich stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n`\"all\"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.\n\n[More info.](streams.md#different-file-descriptor)\n\n#### readableOptions.binary\n\n_Type:_ `boolean`\\\n_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)\n\nIf `false`, iterates over lines. Each line is a string.\n\nIf `true`, iterates over arbitrary chunks of data. Each line is an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (with [`subprocess.iterable()`](#subprocessiterablereadableoptions)) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)).\n\nThis is always `true` when the [`encoding`](#optionsencoding) option is binary.\n\nMore info for [iterables](binary.md#iterable) and [streams](binary.md#streams).\n\n#### readableOptions.preserveNewlines\n\n_Type:_ `boolean`\\\n_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)\n\nIf both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.\n\n[More info.](lines.md#iterable)\n\n### subprocess.writable(writableOptions?)\n\n`writableOptions`: [`WritableOptions`](#writableoptions)\\\n_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream\n\nConverts the subprocess to a writable stream.\n\n[More info.](streams.md#converting-a-subprocess-to-a-stream)\n\n#### writableOptions\n\n_Type:_ `object`\n\n#### writableOptions.to\n\n_Type:_ `\"stdin\" | \"fd3\" | \"fd4\" | ...`\\\n_Default:_ `\"stdin\"`\n\nWhich [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n[More info.](streams.md#different-file-descriptor)\n\n### subprocess.duplex(duplexOptions?)\n\n`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\\\n_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream\n\nConverts the subprocess to a duplex stream.\n\n[More info.](streams.md#converting-a-subprocess-to-a-stream)\n\n## Result\n\n_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md)\\\n_Type:_ `object`\n\n[Result](execution.md#result) of a subprocess successful execution.\n\nWhen the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.\n\n### result.stdout\n\n_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`\n\nThe output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).\n\nThis is `undefined` if the [`stdout`](#optionsstdout) option is set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\nThis is an array if the [`lines`](#optionslines) option is `true`, or if the `stdout` option is a [transform in object mode](transform.md#object-mode).\n\n[More info.](output.md#stdout-and-stderr)\n\n### result.stderr\n\n_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`\n\nThe output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).\n\nThis is `undefined` if the [`stderr`](#optionsstderr) option is set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\nThis is an array if the [`lines`](#optionslines) option is `true`, or if the `stderr` option is a [transform in object mode](transform.md#object-mode).\n\n[More info.](output.md#stdout-and-stderr)\n\n### result.all\n\n_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`\n\nThe output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.\n\nThis requires the [`all`](#optionsall) option to be `true`.\n\nThis is `undefined` if both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\nThis is an array if the [`lines`](#optionslines) option is `true`, or if either the `stdout` or `stderr` option is a [transform in object mode](transform.md#object-mode).\n\n[More info.](output.md#interleaved-output)\n\n### result.stdio\n\n_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`\n\nThe output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).\n\nItems are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.\n\nItems are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).\n\n[More info.](output.md#additional-file-descriptors)\n\n### result.ipcOutput\n\n_Type_: [`Message[]`](ipc.md#message-type)\n\nAll the messages [sent by the subprocess](#sendmessagemessage-sendmessageoptions) to the current process.\n\nThis is empty unless the [`ipc`](#optionsipc) option is `true`. Also, this is empty if the [`buffer`](#optionsbuffer) option is `false`.\n\n[More info.](ipc.md#retrieve-all-messages)\n\n### result.pipedFrom\n\n_Type:_ [`Array<Result | ExecaError>`](#result)\n\n[Results](#result) of the other subprocesses that were piped into this subprocess.\n\nThis array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.\n\n[More info.](pipe.md#result)\n\n### result.command\n\n_Type:_ `string`\n\nThe file and [arguments](input.md#command-arguments) that were run.\n\n[More info.](debugging.md#command)\n\n### result.escapedCommand\n\n_Type:_ `string`\n\nSame as [`command`](#resultcommand) but escaped.\n\n[More info.](debugging.md#command)\n\n### result.cwd\n\n_Type:_ `string`\n\nThe [current directory](#optionscwd) in which the command was run.\n\n[More info.](environment.md#current-directory)\n\n### result.durationMs\n\n_Type:_ `number`\n\nDuration of the subprocess, in milliseconds.\n\n[More info.](debugging.md#duration)\n\n### result.failed\n\n_Type:_ `boolean`\n\nWhether the subprocess failed to run.\n\nWhen this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.\n\n[More info.](errors.md#subprocess-failure)\n\n## ExecaError\n## ExecaSyncError\n\n_Type:_ `Error`\n\nResult of a subprocess [failed execution](errors.md#subprocess-failure).\n\nThis error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.\n\nThis has the same shape as [successful results](#result), with the following additional properties.\n\n[More info.](errors.md)\n\n### error.message\n\n_Type:_ `string`\n\nError message when the subprocess [failed](errors.md#subprocess-failure) to run.\n\n[More info.](errors.md#error-message)\n\n### error.shortMessage\n\n_Type:_ `string`\n\nThis is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).\n\n[More info.](errors.md#error-message)\n\n### error.originalMessage\n\n_Type:_ `string | undefined`\n\nOriginal error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.\n\n[More info.](errors.md#error-message)\n\n### error.cause\n\n_Type:_ `unknown | undefined`\n\nUnderlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).\n\nThis is usually an `Error` instance.\n\n[More info.](termination.md#error-message-and-stack-trace)\n\n### error.code\n\n_Type:_ `string | undefined`\n\nNode.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.\n\n### error.timedOut\n\n_Type:_ `boolean`\n\nWhether the subprocess timed out due to the [`timeout`](#optionstimeout) option.\n\n[More info.](termination.md#timeout)\n\n### error.isCanceled\n\n_Type:_ `boolean`\n\nWhether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.\n\n[More info.](termination.md#canceling)\n\n### error.isGracefullyCanceled\n\n_Type:_ `boolean`\n\nWhether the subprocess was canceled using both the [`cancelSignal`](#optionscancelsignal) and the [`gracefulCancel`](#optionsgracefulcancel) options.\n\n[More info.](termination.md#graceful-termination)\n\n### error.isMaxBuffer\n\n_Type:_ `boolean`\n\nWhether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.\n\n[More info.](output.md#big-output)\n\n### error.isTerminated\n\n_Type:_ `boolean`\n\nWhether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:\n- The current process.\n- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).\n\n[More info.](termination.md#signal-name-and-description)\n\n### error.isForcefullyTerminated\n\n_Type:_ `boolean`\n\nWhether the subprocess was terminated by the [`SIGKILL`](termination.md#sigkill) signal sent by the [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.\n\n[More info.](termination.md#forceful-termination)\n\n### error.exitCode\n\n_Type:_ `number | undefined`\n\nThe numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.\n\nThis is `undefined` when the subprocess could not be spawned or was terminated by a [signal](#errorsignal).\n\n[More info.](errors.md#exit-code)\n\n### error.signal\n\n_Type:_ `string | undefined`\n\nThe name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:\n- The current process.\n- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).\n\nIf a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.\n\n[More info.](termination.md#signal-name-and-description)\n\n### error.signalDescription\n\n_Type:_ `string | undefined`\n\nA human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.\n\nIf a signal terminated the subprocess, 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.\n\n[More info.](termination.md#signal-name-and-description)\n\n## Options\n\n_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md)\\\n_Type:_ `object`\n\nThis lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).\n\nThe following options [can specify different values](output.md#stdoutstderr-specific-options) for [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr): [`verbose`](#optionsverbose), [`lines`](#optionslines), [`stripFinalNewline`](#optionsstripfinalnewline), [`buffer`](#optionsbuffer), [`maxBuffer`](#optionsmaxbuffer).\n\n### options.preferLocal\n\n_Type:_ `boolean`\\\n_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwise\n\nPrefer locally installed binaries when looking for a binary to execute.\n\n[More info.](environment.md#local-binaries)\n\n### options.localDir\n\n_Type:_ `string | URL`\\\n_Default:_ [`cwd`](#optionscwd) option\n\nPreferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.\n\n[More info.](environment.md#local-binaries)\n\n### options.node\n\n_Type:_ `boolean`\\\n_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise\n\nIf `true`, runs with Node.js. The first argument must be a Node.js file.\n\nThe subprocess inherits the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) and version. This can be overridden using the [`nodeOptions`](#optionsnodeoptions) and [`nodePath`](#optionsnodepath) options.\n\n[More info.](node.md)\n\n### options.nodeOptions\n\n_Type:_ `string[]`\\\n_Default:_ [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI flags)\n\nList of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).\n\nRequires the [`node`](#optionsnode) option to be `true`.\n\n[More info.](node.md#nodejs-cli-flags)\n\n### options.nodePath\n\n_Type:_ `string | URL`\\\n_Default:_ [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)\n\nPath to the Node.js executable.\n\nRequires the [`node`](#optionsnode) option to be `true`.\n\n[More info.](node.md#nodejs-version)\n\n### options.shell\n\n_Type:_ `boolean | string | URL`\\\n_Default:_ `false`\n\nIf `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).\n\nUses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/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.\n\nWe [recommend against](shell.md#avoiding-shells) using this option.\n\n[More info.](shell.md)\n\n### options.cwd\n\n_Type:_ `string | URL`\\\n_Default:_ `process.cwd()`\n\nCurrent [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.\n\nThis is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.\n\n[More info.](environment.md#current-directory)\n\n### options.env\n\n_Type:_ `object`\\\n_Default:_ [`process.env`](https://nodejs.org/api/process.html#processenv)\n\n[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).\n\nUnless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).\n\n[More info.](input.md#environment-variables)\n\n### options.extendEnv\n\n_Type:_ `boolean`\\\n_Default:_ `true`\n\nIf `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).\nIf `false`, only the `env` option is used, not `process.env`.\n\n[More info.](input.md#environment-variables)\n\n### options.input\n\n_Type:_ `string | Uint8Array | stream.Readable`\n\nWrite some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).\n\nSee also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.\n\n[More info.](input.md#string-input)\n\n### options.inputFile\n\n_Type:_ `string | URL`\n\nUse a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).\n\nSee also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.\n\n[More info.](input.md#file-input)\n\n### options.stdin\n\n_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\\\n_Type:_ `string | number | stream.Readable | ReadableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string | Uint8Array | unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\\\n_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwise\n\nHow to setup the subprocess' [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](streams.md#manual-streaming), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](input.md#ignore-input), [`'inherit'`](input.md#terminal-input), a [file descriptor integer](input.md#terminal-input), a [Node.js `Readable` stream](streams.md#input), a web [`ReadableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](input.md#file-input), a [file URL](input.md#file-input), an [`Iterable`](streams.md#iterables-as-input) (including an [array of strings](input.md#string-input)), an [`AsyncIterable`](streams.md#iterables-as-input), an [`Uint8Array`](binary.md#binary-input), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).\n\nThis can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.\n\nMore info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).\n\n### options.stdout\n\n_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\\\n_Type:_ `string | number | stream.Writable | WritableStream | TransformStream | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown>  | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\\\n_Default:_ `pipe`\n\nHow to setup the subprocess' [standard output](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](output.md#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](output.md#ignore-output), [`'inherit'`](output.md#terminal-output), a [file descriptor integer](output.md#terminal-output), a [Node.js `Writable` stream](streams.md#output), a web [`WritableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](output.md#file-output), a [file URL](output.md#file-output), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).\n\nThis can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.\n\nMore info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).\n\n### options.stderr\n\n_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\\\n_Type:_ `string | number | stream.Writable | WritableStream | TransformStream | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\\\n_Default:_ `pipe`\n\nHow to setup the subprocess' [standard error](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](output.md#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](output.md#ignore-output), [`'inherit'`](output.md#terminal-output), a [file descriptor integer](output.md#terminal-output), a [Node.js `Writable` stream](streams.md#output), a web [`WritableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](output.md#file-output), a [file URL](output.md#file-output), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).\n\nThis can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.\n\nMore info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).\n\n### options.stdio\n\n_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\\\n_Type:_ `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}>` (or a tuple of those types)\\\n_Default:_ `pipe`\n\nLike the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options but for all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.\n\nA single string can be used [as a shortcut](output.md#shortcut).\n\nThe array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr).\n\nMore info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).\n\n### options.all\n\n_Type:_ `boolean`\\\n_Default:_ `false`\n\nAdd a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.\n\n[More info.](output.md#interleaved-output)\n\n### options.encoding\n\n_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\\\n_Default:_ `'utf8'`\n\nIf the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).\n\nIf it outputs binary data instead, this should be either:\n- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).\n- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.\n\nThe output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).\n\n[More info.](binary.md)\n\n### options.lines\n\n_Type:_ `boolean`\\\n_Default:_ `false`\n\nSet [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.\n\nThis cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).\n\nBy default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).\n\n[More info.](lines.md#simple-splitting)\n\n### options.stripFinalNewline\n\n_Type:_ `boolean`\\\n_Default:_ `true`\n\nStrip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.\n\nIf the [`lines`](#optionslines) option is true, this applies to each output line instead.\n\nBy default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).\n\n[More info.](lines.md#newlines)\n\n### options.maxBuffer\n\n_Type:_ `number`\\\n_Default:_ `100_000_000`\n\nLargest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).\n\nBy default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).\n\nWhen reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.\n\n[More info.](output.md#big-output)\n\n### options.buffer\n\n_Type:_ `boolean`\\\n_Default:_ `true`\n\nWhen `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.\n\nBy default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).\n\n[More info.](output.md#low-memory)\n\n### options.ipc\n\n_Type:_ `boolean`\\\n_Default:_ `true` if the [`node`](#optionsnode), [`ipcInput`](#optionsipcinput) or [`gracefulCancel`](#optionsgracefulcancel) option is set, `false` otherwise\n\nEnables exchanging messages with the subprocess using [`subprocess.sendMessage(message)`](#subprocesssendmessagemessage-sendmessageoptions), [`subprocess.getOneMessage()`](#subprocessgetonemessagegetonemessageoptions) and [`subprocess.getEachMessage()`](#subprocessgeteachmessagegeteachmessageoptions).\n\nThe subprocess must be a Node.js file.\n\n[More info.](ipc.md)\n\n### options.serialization\n\n_Type:_ `'json' | 'advanced'`\\\n_Default:_ `'advanced'`\n\nSpecify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.\n\n[More info.](ipc.md#message-type)\n\n### options.ipcInput\n\n_Type_: [`Message`](ipc.md#message-type)\n\nSends an IPC message when the subprocess starts.\n\nThe subprocess must be a [Node.js file](#optionsnode). The value's [type](ipc.md#message-type) depends on the [`serialization`](#optionsserialization) option.\n\nMore info [here](ipc.md#send-an-initial-message) and [there](input.md#any-input-type).\n\n### options.verbose\n\n_Type:_ `'none' | 'short' | 'full' | Function`\\\n_Default:_ `'none'`\n\nIf `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.\n\nIf `verbose` is `'full'` or a function, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and [IPC messages](ipc.md) are also printed.\n\nA [function](#verbose-function) can be passed to customize logging. Please see [this page](debugging.md#custom-logging) for more information.\n\nBy default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).\n\n[More info.](debugging.md#verbose-mode)\n\n### options.reject\n\n_Type:_ `boolean`\\\n_Default:_ `true`\n\nSetting this to `false` resolves the [result's promise](#return-value) with the [error](#execaerror) instead of rejecting it.\n\n[More info.](errors.md#preventing-exceptions)\n\n### options.timeout\n\n_Type:_ `number`\\\n_Default:_ `0`\n\nIf `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds.\n\nOn timeout, [`error.timedOut`](#errortimedout) becomes `true`.\n\n[More info.](termination.md#timeout)\n\n### options.cancelSignal\n\n_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nWhen the `cancelSignal` is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), terminate the subprocess using a `SIGTERM` signal.\n\nWhen aborted, [`error.isCanceled`](#erroriscanceled) becomes `true`.\n\n[More info.](termination.md#canceling)\n\n### options.gracefulCancel\n\n_Type:_ `boolean`\\\n_Default:_: `false`\n\nWhen the [`cancelSignal`](#optionscancelsignal) option is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), do not send any [`SIGTERM`](termination.md#canceling). Instead, abort the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) returned by [`getCancelSignal()`](#getcancelsignal). The subprocess should use it to terminate gracefully.\n\nThe subprocess must be a [Node.js file](#optionsnode).\n\nWhen aborted, [`error.isGracefullyCanceled`](#errorisgracefullycanceled) becomes `true`.\n\n[More info.](termination.md#graceful-termination)\n\n### options.forceKillAfterDelay\n\n_Type:_ `number | false`\\\n_Default:_ `5000`\n\nIf the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).\n\nWhen this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.\n\n[More info.](termination.md#forceful-termination)\n\n### options.killSignal\n\n_Type:_ `string | number`\\\n_Default:_ `'SIGTERM'`\n\nDefault [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.\n\nThis can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).\n\n[More info.](termination.md#default-signal)\n\n### options.detached\n\n_Type:_ `boolean`\\\n_Default:_ `false`\n\nRun the subprocess independently from the current process.\n\n[More info.](environment.md#background-subprocess)\n\n### options.cleanup\n\n_Type:_ `boolean`\\\n_Default:_ `true`\n\nKill the subprocess when the current process exits.\n\n[More info.](termination.md#current-process-exit)\n\n### options.uid\n\n_Type:_ `number`\\\n_Default:_ current user identifier\n\nSets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.\n\n[More info.](windows.md#uid-and-gid)\n\n### options.gid\n\n_Type:_ `number`\\\n_Default:_ current group identifier\n\nSets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.\n\n[More info.](windows.md#uid-and-gid)\n\n### options.argv0\n\n_Type:_ `string`\\\n_Default:_ file being executed\n\nValue of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.\n\n### options.windowsHide\n\n_Type:_ `boolean`\\\n_Default:_ `true`\n\nOn Windows, do not create a new console window.\n\n[More info.](windows.md#console-window)\n\n### options.windowsVerbatimArguments\n\n_Type:_ `boolean`\\\n_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise\n\nIf `false`, escapes the command arguments on Windows.\n\n[More info.](windows.md#escaping)\n\n## Verbose function\n\n_Type_: `(string, VerboseObject) => string | undefined`\n\nFunction passed to the [`verbose`](#optionsverbose) option to customize logging.\n\n[More info.](debugging.md#custom-logging)\n\n### Verbose object\n\n_Type_: `VerboseObject` or `SyncVerboseObject`\n\nSubprocess event object, for logging purpose, using the [`verbose`](#optionsverbose) option.\n\n#### verboseObject.type\n\n_Type_: `string`\n\nEvent type. This can be:\n- `'command'`: subprocess start\n- `'output'`: `stdout`/`stderr` [output](output.md#stdout-and-stderr)\n- `'ipc'`: IPC [output](ipc.md#retrieve-all-messages)\n- `'error'`: subprocess [failure](errors.md#subprocess-failure)\n- `'duration'`: subprocess success or failure\n\n#### verboseObject.message\n\n_Type_: `string`\n\nDepending on [`verboseObject.type`](#verboseobjecttype), this is:\n- `'command'`: the [`result.escapedCommand`](#resultescapedcommand)\n- `'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)\n- `'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)\n- `'error'`: the [`error.shortMessage`](#errorshortmessage)\n- `'duration'`: the [`result.durationMs`](#resultdurationms)\n\n#### verboseObject.escapedCommand\n\n_Type_: `string`\n\nThe file and [arguments](input.md#command-arguments) that were run. This is the same as [`result.escapedCommand`](#resultescapedcommand).\n\n#### verboseObject.options\n\n_Type_: [`Options`](#options-1) or [`SyncOptions`](#options-1)\n\nThe [options](#options-1) passed to the subprocess.\n\n#### verboseObject.commandId\n\n_Type_: `string`\n\nSerial number identifying the subprocess within the current process. It is incremented from `'0'`.\n\nThis is helpful when multiple subprocesses are running at the same time.\n\nThis is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.\n\n#### verboseObject.timestamp\n\n_Type_: `Date`\n\nEvent date/time.\n\n#### verboseObject.result\n\n_Type_: [`Result`](#result), [`SyncResult`](#result) or `undefined`\n\nSubprocess [result](#result).\n\nThis is `undefined` if [`verboseObject.type`](#verboseobjecttype) is `'command'`, `'output'` or `'ipc'`.\n\n#### verboseObject.piped\n\n_Type_: `boolean`\n\nWhether another subprocess is [piped](pipe.md) into this subprocess. This is `false` when [`result.pipedFrom`](#resultfailed) is empty.\n\n## Transform options\n\nA transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.\n\nA transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.\n\n[More info.](transform.md)\n\n### transformOptions.transform\n\n_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`\n\nMap or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.\n\nMore info [here](transform.md#summary) and [there](transform.md#sharing-state).\n\n### transformOptions.final\n\n_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`\n\nCreate additional lines after the last one.\n\n[More info.](transform.md#finalizing)\n\n### transformOptions.binary\n\n_Type:_ `boolean`\\\n_Default:_ `false`\n\nIf `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.\n\n[More info.](binary.md#transforms)\n\n### transformOptions.preserveNewlines\n\n_Type:_ `boolean`\\\n_Default:_ `false`\n\nIf `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.\n\n[More info.](lines.md#transforms)\n\n### transformOptions.objectMode\n\n_Type:_ `boolean`\\\n_Default:_ `false`\n\nIf `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.\n\n[More info.](transform.md#object-mode)\n\n<hr>\n\n[**Previous**: 🔍 Differences with Bash and zx](bash.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/bash.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🔍 Differences with Bash and zx\n\nThis page describes the differences between [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)), Execa, and [zx](https://github.com/google/zx). Execa intends to be more:\n- [Simple](#simplicity): minimalistic API, no [globals](#global-variables), no [binary](#main-binary), no builtin CLI utilities.\n- [Cross-platform](#shell): [no shell](shell.md) is used, only JavaScript.\n- [Secure](#escaping): no shell injection.\n- [Featureful](#simplicity): all Execa features are available ([text lines iteration](#iterate-over-output-lines), [advanced piping](#piping-stdout-to-another-command), [simple IPC](#ipc), [passing any input type](#pass-any-input-type), [returning any output type](#return-any-output-type), [transforms](#transforms), [web streams](#web-streams), [convert to Duplex stream](#convert-to-duplex-stream), [cleanup on exit](termination.md#current-process-exit), [graceful termination](#graceful-termination), [forceful termination](termination.md#forceful-termination), and [more](../readme.md#documentation)).\n- [Easy to debug](#debugging): [verbose mode](#verbose-mode-single-command), [detailed errors](#detailed-errors), [messages and stack traces](#cancelation), stateless API.\n- [Performant](#performance)\n\n## Flexibility\n\nUnlike shell languages like Bash, libraries like Execa and zx enable you to write scripts with a more featureful programming language (JavaScript). This allows complex logic (such as [parallel execution](#parallel-commands)) to be expressed easily. This also lets you use any Node.js package.\n\n## Shell\n\nThe main difference between Execa and zx is that Execa does not require any shell. Shell-specific keywords and features are [written in JavaScript](#variable-substitution) instead.\n\nThis is more cross-platform. For example, your code works the same on Windows machines without Bash installed.\n\nAlso, there is no shell syntax to remember: everything is just plain JavaScript.\n\nIf you really need a shell though, the [`shell`](shell.md) option can be used.\n\n## Simplicity\n\nExeca's scripting API mostly consists of only two methods: [`` $`command` ``](shell.md) and [`$(options)`](execution.md#globalshared-options).\n\n[No special binary](#main-binary) is recommended, no [global variable](#global-variables) is injected: scripts are regular Node.js files.\n\nExeca is a thin wrapper around the core Node.js [`child_process` module](https://nodejs.org/api/child_process.html). It lets you use any of its native features.\n\n## Modularity\n\nzx includes many builtin utilities: [`fetch()`](#http-requests), [`question()`](#cli-prompts), [`sleep()`](#sleep), [`echo()`](#printing-to-stdout), [`stdin()`](#retrieve-stdin), [`retry()`](#retry-on-error), [`spinner()`](#cli-spinner), [`globby`](#globbing), [`chalk`](https://github.com/chalk/chalk), [`fs`](https://github.com/jprichardson/node-fs-extra), [`os`](https://nodejs.org/api/os.html), [`path`](https://nodejs.org/api/path.html), [`yaml`](https://github.com/eemeli/yaml), [`which`](https://github.com/npm/node-which), [`ps`](https://github.com/webpod/ps), [`tmpfile()`](#temporary-file), [`argv`](#cli-arguments), Markdown scripts, remote scripts.\n\nExeca does not include any utility: it focuses on being small and modular instead. [Any Node.js package](https://github.com/sindresorhus/awesome-nodejs#command-line-utilities) can be used in your scripts.\n\n## Performance\n\nSpawning a shell for every command comes at a performance cost, which Execa avoids.\n\n## Debugging\n\nSubprocesses can be hard to debug, which is why Execa includes a [`verbose`](#verbose-mode-single-command) option. It includes [more information](debugging.md#full-mode) than zx: timestamps, command completion and duration, interleaved commands, IPC messages.\n\nAlso, Execa's error messages and [properties](#detailed-errors) are very detailed to make it clear to determine why a subprocess failed. Error messages and stack traces can be set with [`subprocess.kill(error)`](termination.md#error-message-and-stack-trace).\n\nFinally, unlike Bash and zx, which are stateful (options, current directory, etc.), Execa is [purely functional](#current-directory), which also helps with debugging.\n\n## Examples\n\n### Main binary\n\n```sh\n# Bash\nbash file.sh\n```\n\n```js\n// zx\nzx file.js\n\n// or a shebang can be used:\n//   #!/usr/bin/env zx\n```\n\n```js\n// Execa scripts are just regular Node.js files\nnode file.js\n```\n\n### Global variables\n\n```js\n// zx\nawait $`npm run build`;\n```\n\n```js\n// Execa\nimport {$} from 'execa';\n\nawait $`npm run build`;\n```\n\n[More info.](execution.md)\n\n### Command execution\n\n```sh\n# Bash\nnpm run build\n```\n\n```js\n// zx\nawait $`npm run build`;\n```\n\n```js\n// Execa\nawait $`npm run build`;\n```\n\n[More info.](execution.md)\n\n### Multiline commands\n\n```sh\n# Bash\nnpm run build \\\n\t--example-flag-one \\\n\t--example-flag-two\n```\n\n```js\n// zx\nawait $`npm run build ${[\n\t'--example-flag-one',\n\t'--example-flag-two',\n]}`;\n```\n\n```js\n// Execa\nawait $`npm run build\n\t--example-flag-one\n\t--example-flag-two`;\n```\n\n[More info.](execution.md#multiple-lines)\n\n### Concatenation\n\n```sh\n# Bash\ntmpDirectory=\"/tmp\"\nmkdir \"$tmpDirectory/filename\"\n```\n\n```js\n// zx\nconst tmpDirectory = '/tmp'\nawait $`mkdir ${tmpDirectory}/filename`;\n```\n\n```js\n// Execa\nconst tmpDirectory = '/tmp'\nawait $`mkdir ${tmpDirectory}/filename`;\n```\n\n[More info.](execution.md#concatenation)\n\n### Variable substitution\n\n```sh\n# Bash\necho $LANG\n```\n\n```js\n// zx\nawait $`echo $LANG`;\n```\n\n```js\n// Execa\nawait $`echo ${process.env.LANG}`;\n```\n\n[More info.](input.md#environment-variables)\n\n### Escaping\n\n```sh\n# Bash\necho 'one two'\n```\n\n```js\n// zx\nawait $`echo ${'one two'}`;\n```\n\n```js\n// Execa\nawait $`echo ${'one two'}`;\n```\n\n[More info.](escaping.md)\n\n### Escaping multiple arguments\n\n```sh\n# Bash\necho 'one two' '$'\n```\n\n```js\n// zx\nawait $`echo ${['one two', '$']}`;\n```\n\n```js\n// Execa\nawait $`echo ${['one two', '$']}`;\n```\n\n[More info.](execution.md#multiple-arguments)\n\n### Subcommands\n\n```sh\n# Bash\necho \"$(npm run build)\"\n```\n\n```js\n// zx\nconst result = await $`npm run build`;\nawait $`echo ${result}`;\n```\n\n```js\n// Execa\nconst result = await $`npm run build`;\nawait $`echo ${result}`;\n```\n\n[More info.](execution.md#subcommands)\n\n### Serial commands\n\n```sh\n# Bash\nnpm run build && npm run test\n```\n\n```js\n// zx\nawait $`npm run build && npm run test`;\n```\n\n```js\n// Execa\nawait $`npm run build`;\nawait $`npm run test`;\n```\n\n### Parallel commands\n\n```sh\n# Bash\nnpm run build &\nnpm run test &\n```\n\n```js\n// zx\nawait Promise.all([$`npm run build`, $`npm run test`]);\n```\n\n```js\n// Execa\nawait Promise.all([$`npm run build`, $`npm run test`]);\n```\n\n### Global/shared options\n\n```sh\n# Bash\noptions=\"timeout 5\"\n$options npm run init\n$options npm run build\n$options npm run test\n```\n\n```js\n// zx\nconst $$ = $({verbose: true});\n\nawait $$`npm run init`;\nawait $$`npm run build`;\nawait $$`npm run test`;\n```\n\n```js\n// Execa\nimport {$ as $_} from 'execa';\n\nconst $ = $_({verbose: true});\n\nawait $`npm run init`;\nawait $`npm run build`;\nawait $`npm run test`;\n```\n\n[More info.](execution.md#globalshared-options)\n\n### Environment variables\n\n```sh\n# Bash\nEXAMPLE=1 npm run build\n```\n\n```js\n// zx\nawait $({env: {EXAMPLE: '1'}})`npm run build`;\n```\n\n```js\n// Execa\nawait $({env: {EXAMPLE: '1'}})`npm run build`;\n```\n\n[More info.](input.md#environment-variables)\n\n### Local binaries\n\n```sh\n# Bash\nnpx tsc --version\n```\n\n```js\n// zx\nawait $({preferLocal: true})`tsc --version`;\n```\n\n```js\n// Execa\nawait $({preferLocal: true})`tsc --version`;\n```\n\n[More info.](environment.md#local-binaries)\n\n### Retrieve stdin\n\n```sh\n# Bash\nread content\n```\n\n```js\n// zx\nconst content = await stdin();\n```\n\n```js\n// Execa\nimport getStdin from 'get-stdin';\n\nconst content = await getStdin();\n```\n\n[More info.](https://github.com/sindresorhus/get-stdin)\n\n### Pass input to stdin\n\n```sh\n# Bash\ncat <<<\"example\"\n```\n\n```js\n// zx\n$({input: 'example'})`cat`;\n```\n\n```js\n// Execa\n$({input: 'example'})`cat`;\n```\n\n### Pass any input type\n\n```sh\n# Bash only allows passing strings as input\n```\n\n```js\n// zx only allows passing specific input types\n```\n\n```js\n// Execa - main.js\nconst ipcInput = [\n\t{task: 'lint', ignore: /test\\.js/},\n\t{task: 'copy', files: new Set(['main.js', 'index.js']),\n}];\nawait $({ipcInput})`node build.js`;\n```\n\n```js\n// Execa - build.js\nimport {getOneMessage} from 'execa';\n\nconst ipcInput = await getOneMessage();\n```\n\n[More info.](ipc.md#send-an-initial-message)\n\n### Return any output type\n\n```sh\n# Bash only allows returning strings as output\n```\n\n```js\n// zx only allows returning specific output types\n```\n\n```js\n// Execa - main.js\nconst {ipcOutput} = await $({ipc: true})`node build.js`;\nconsole.log(ipcOutput[0]); // {kind: 'start', timestamp: date}\nconsole.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}\n```\n\n```js\n// Execa - build.js\nimport {sendMessage} from 'execa';\n\nawait sendMessage({kind: 'start', timestamp: new Date()});\nawait runBuild();\nawait sendMessage({kind: 'stop', timestamp: new Date()});\n```\n\n[More info.](ipc.md#retrieve-all-messages)\n\n### Printing to stdout\n\n```sh\n# Bash\necho example\n```\n\n```js\n// zx\necho`example`;\n```\n\n```js\n// Execa\nconsole.log('example');\n```\n\n### Silent stdout\n\n```sh\n# Bash\nnpm run build > /dev/null\n```\n\n```js\n// zx\nawait $`npm run build`.quiet();\n```\n\n```js\n// Execa does not print stdout by default\nawait $`npm run build`;\n```\n\n### Binary output\n\n```sh\n# Bash usually requires redirecting binary output\nzip -r - input.txt > output.txt\n```\n\n```js\n// zx\nconst stdout = await $`zip -r - input.txt`.buffer();\n```\n\n```js\n// Execa\nconst {stdout} = await $({encoding: 'buffer'})`zip -r - input.txt`;\n```\n\n[More info.](binary.md#binary-output)\n\n### Verbose mode (single command)\n\n```sh\n# Bash\nset -v\nnpm run build\nset +v\n```\n\n```js\n// zx\nawait $`npm run build`.verbose();\n```\n\n```js\n// Execa\nawait $({verbose: 'full'})`npm run build`;\n```\n\n[More info.](debugging.md#verbose-mode)\n\n### Verbose mode (global)\n\n```sh\n# Bash\nset -v\nnpm run build\n```\n\n```\n// zx\n$ zx --verbose file.js\n$ npm run build\nBuilding...\nDone.\n```\n\n```\n$ NODE_DEBUG=execa node file.js\n[19:49:00.360] [0] $ npm run build\n[19:49:00.360] [0]   Building...\n[19:49:00.360] [0]   Done.\n[19:49:00.383] [0] √ (done in 23ms)\n```\n\n[More info.](debugging.md#global-mode)\n\n### Piping stdout to another command\n\n```sh\n# Bash\necho npm run build | sort | head -n2\n```\n\n```js\n// zx\nawait $`npm run build`\n\t.pipe($`sort`)\n\t.pipe($`head -n2`);\n```\n\n```js\n// Execa\nawait $`npm run build`\n\t.pipe`sort`\n\t.pipe`head -n2`;\n```\n\n[More info.](pipe.md)\n\n### Piping stdout and stderr to another command\n\n```sh\n# Bash\nnpm run build |& cat\n```\n\n```js\n// zx\nconst subprocess = $`npm run build`;\nconst cat = $`cat`;\nsubprocess.pipe(cat);\nsubprocess.stderr.pipe(cat.stdin);\nawait Promise.all([subprocess, cat]);\n```\n\n```js\n// Execa\nawait $({all: true})`npm run build`\n\t.pipe({from: 'all'})`cat`;\n```\n\n[More info.](pipe.md#source-file-descriptor)\n\n### Piping stdout to a file\n\n```sh\n# Bash\nnpm run build > output.txt\n```\n\n```js\n// zx\nimport {createWriteStream} from 'node:fs';\n\nawait $`npm run build`.pipe(createWriteStream('output.txt'));\n```\n\n```js\n// Execa\nawait $({stdout: {file: 'output.txt'}})`npm run build`;\n```\n\n[More info.](output.md#file-output)\n\n### Append stdout to a file\n\n```sh\n# Bash\nnpm run build >> output.txt\n```\n\n```js\n// zx\nimport {createWriteStream} from 'node:fs';\n\nawait $`npm run build`.pipe(createWriteStream('output.txt', {flags: 'a'}));\n```\n\n```js\n// Execa\nawait $({stdout: {file: 'output.txt', append: true}})`npm run build`;\n```\n\n[More info.](output.md#file-output)\n\n### Piping interleaved stdout and stderr to a file\n\n```sh\n# Bash\nnpm run build &> output.txt\n```\n\n```js\n// zx\nimport {createWriteStream} from 'node:fs';\n\nconst subprocess = $`npm run build`;\nconst fileStream = createWriteStream('output.txt');\nsubprocess.pipe(fileStream);\nsubprocess.stderr.pipe(fileStream);\nawait subprocess;\n```\n\n```js\n// Execa\nconst output = {file: 'output.txt'};\nawait $({stdout: output, stderr: output})`npm run build`;\n```\n\n[More info.](output.md#file-output)\n\n### Piping stdin from a file\n\n```sh\n# Bash\ncat < input.txt\n```\n\n```js\n// zx\nconst cat = $`cat`;\nfs.createReadStream('input.txt').pipe(cat.stdin);\nawait cat;\n```\n\n```js\n// Execa\nawait $({inputFile: 'input.txt'})`cat`;\n```\n\n[More info.](input.md#file-input)\n\n### Web streams\n\n```js\n// zx does not support web streams\n```\n\n```js\n// Execa\nconst response = await fetch('https://example.com');\nawait $({stdin: response.body})`npm run build`;\n```\n\n[More info.](streams.md#web-streams)\n\n### Convert to Duplex stream\n\n```js\n// zx does not support converting subprocesses to streams\n```\n\n```js\n// Execa\nimport {pipeline} from 'node:stream/promises';\nimport {createReadStream, createWriteStream} from 'node:fs';\n\nawait pipeline(\n\tcreateReadStream('./input.txt'),\n\t$`node ./transform.js`.duplex(),\n\tcreateWriteStream('./output.txt'),\n);\n```\n\n[More info.](streams.md#convert)\n\n### Handle pipeline errors\n\n```sh\n# Bash\nset -e\nnpm run crash | sort | head -n2\n```\n\n```js\n// zx\ntry {\n\tawait $`npm run crash`\n\t\t.pipe($`sort`)\n\t\t.pipe($`head -n2`);\n// This is never reached.\n// The process crashes instead.\n} catch (error) {\n\tconsole.error(error);\n}\n```\n\n```js\n// Execa\ntry {\n\tawait $`npm run build`\n\t\t.pipe`sort`\n\t\t.pipe`head -n2`;\n} catch (error) {\n\tconsole.error(error);\n}\n```\n\n[More info.](pipe.md#errors)\n\n### Return all pipeline results\n\n```sh\n# Bash only allows returning each command's exit code\nnpm run crash | sort | head -n2\n# 1 0 0\necho \"${PIPESTATUS[@]}\"\n```\n\n```js\n// zx only returns the last command's result\n```\n\n```js\n// Execa\nconst destinationResult = await execa`npm run build`\n\t.pipe`head -n 2`;\nconsole.log(destinationResult.stdout); // First 2 lines of `npm run build`\n\nconst sourceResult = destinationResult.pipedFrom[0];\nconsole.log(sourceResult.stdout); // Full output of `npm run build`\n```\n\n[More info.](pipe.md#result)\n\n### Split output into lines\n\n```sh\n# Bash\nnpm run build | IFS='\\n' read -ra lines\n```\n\n```js\n// zx\nconst lines = await $`npm run build`.lines();\n```\n\n```js\n// Execa\nconst lines = await $({lines: true})`npm run build`;\n```\n\n[More info.](lines.md#simple-splitting)\n\n### Iterate over output lines\n\n```sh\n# Bash\nwhile read\ndo\n\tif [[ \"$REPLY\" == *ERROR* ]]\n\tthen\n\t\techo \"$REPLY\"\n\tfi\ndone < <(npm run build)\n```\n\n```js\n// zx does not allow easily iterating over output lines.\n// Also, the iteration does not handle subprocess errors.\n```\n\n```js\n// Execa\nfor await (const line of $`npm run build`) {\n\tif (line.includes('ERROR')) {\n\t\tconsole.log(line);\n\t}\n}\n```\n\n[More info.](lines.md#progressive-splitting)\n\n### Detailed errors\n\n```sh\n# Bash communicates errors only through the exit code and stderr\ntimeout 1 sleep 2\necho $?\n```\n\n```js\n// zx\nawait $`sleep 2`.timeout('1ms');\n// Error:\n//   at file:///home/me/Desktop/example.js:6:12\n//   exit code: null\n//   signal: SIGTERM\n```\n\n```js\n// Execa\nawait $({timeout: 1})`sleep 2`;\n// ExecaError: Command timed out after 1 milliseconds: sleep 2\n//     at file:///home/me/Desktop/example.js:2:20\n//     at ... {\n//   shortMessage: 'Command timed out after 1 milliseconds: sleep 2\\nTimed out',\n//   originalMessage: '',\n//   command: 'sleep 2',\n//   escapedCommand: 'sleep 2',\n//   cwd: '/path/to/cwd',\n//   durationMs: 19.95693,\n//   failed: true,\n//   timedOut: true,\n//   isCanceled: false,\n//   isTerminated: true,\n//   isMaxBuffer: false,\n//   signal: 'SIGTERM',\n//   signalDescription: 'Termination',\n//   stdout: '',\n//   stderr: '',\n//   stdio: [undefined, '', ''],\n//   pipedFrom: []\n// }\n```\n\n[More info.](errors.md)\n\n### Exit codes\n\n```sh\n# Bash\nnpm run build\necho $?\n```\n\n```js\n// zx\nconst {exitCode} = await $`npm run build`.nothrow();\n```\n\n```js\n// Execa\nconst {exitCode} = await $({reject: false})`npm run build`;\n```\n\n[More info.](errors.md#exit-code)\n\n### Timeouts\n\n```sh\n# Bash\ntimeout 5 npm run build\n```\n\n```js\n// zx\nawait $`npm run build`.timeout('5s');\n```\n\n```js\n// Execa\nawait $({timeout: 5000})`npm run build`;\n```\n\n[More info.](termination.md#timeout)\n\n### Current filename\n\n```sh\n# Bash\necho \"$(basename \"$0\")\"\n```\n\n```js\n// zx\nawait $`echo ${__filename}`;\n```\n\n```js\n// Execa\nawait $`echo ${import.meta.filename}`;\n```\n\n### Current directory\n\n```sh\n# Bash\ncd project\n```\n\n```js\n// zx\nconst $$ = $({cwd: 'project'});\n\n// Or:\ncd('project');\n```\n\n```js\n// Execa\nconst $$ = $({cwd: 'project'});\n```\n\n[More info.](environment.md#current-directory)\n\n### Background subprocess\n\n```sh\n# Bash\nnpm run build &\n```\n\n```js\n// zx\nawait $({detached: true})`npm run build`;\n```\n\n```js\n// Execa\nawait $({detached: true})`npm run build`;\n```\n\n[More info.](environment.md#background-subprocess)\n\n### IPC\n\n```sh\n# Bash does not allow simple IPC\n```\n\n```js\n// zx does not allow simple IPC\n```\n\n```js\n// Execa\nconst subprocess = $({node: true})`script.js`;\n\nfor await (const message of subprocess.getEachMessage()) {\n\tif (message === 'ping') {\n\t\tawait subprocess.sendMessage('pong');\n\t}\n});\n```\n\n[More info.](ipc.md)\n\n### Transforms\n\n```sh\n# Bash does not allow transforms\n```\n\n```js\n// zx does not allow transforms\n```\n\n```js\n// Execa\nconst transform = function * (line) {\n\tif (!line.includes('secret')) {\n\t\tyield line;\n\t}\n};\n\nawait $({stdout: [transform, 'inherit']})`echo ${'This is a secret.'}`;\n```\n\n[More info.](transform.md)\n\n### Signal termination\n\n```sh\n# Bash\nkill $PID\n```\n\n```js\n// zx\nsubprocess.kill();\n```\n\n```js\n// Execa\nsubprocess.kill();\n\n// Or with an error message and stack trace:\nsubprocess.kill(error);\n```\n\n[More info.](termination.md#signal-termination)\n\n### Default signal\n\n```sh\n# Bash does not allow changing the default termination signal\n```\n\n```js\n// zx only allows changing the signal used for timeouts\nconst $$ = $({timeoutSignal: 'SIGINT'});\n```\n\n```js\n// Execa\nconst $ = $_({killSignal: 'SIGINT'});\n```\n\n[More info.](termination.md#default-signal)\n\n### Cancelation\n\n```sh\n# Bash\nkill $PID\n```\n\n```js\n// zx\nconst controller = new AbortController();\nawait $({signal: controller.signal})`node long-script.js`;\n```\n\n```js\n// Execa\nconst controller = new AbortController();\nawait $({cancelSignal: controller.signal})`node long-script.js`;\n```\n\n[More info.](termination.md#canceling)\n\n### Graceful termination\n\n```sh\n# Bash\ntrap cleanup SIGTERM\n```\n\n```js\n// zx\n// This does not work on Windows\nprocess.on('SIGTERM', () => {\n\t// ...\n});\n```\n\n```js\n// Execa - main.js\nconst controller = new AbortController();\nawait $({\n\tcancelSignal: controller.signal,\n\tgracefulCancel: true,\n})`node build.js`;\n```\n\n```js\n// Execa - build.js\nimport {getCancelSignal} from 'execa';\n\nconst cancelSignal = await getCancelSignal();\nawait fetch('https://example.com', {signal: cancelSignal});\n```\n\n### Interleaved output\n\n```sh\n# Bash prints stdout and stderr interleaved\n```\n\n```js\n// zx\nconst all = String(await $`node example.js`);\n```\n\n```js\n// Execa\nconst {all} = await $({all: true})`node example.js`;\n```\n\n[More info.](output.md#interleaved-output)\n\n### PID\n\n```sh\n# Bash\nnpm run build &\necho $!\n```\n\n```js\n// zx does not return `subprocess.pid`\n```\n\n```js\n// Execa\nconst {pid} = $`npm run build`;\n```\n\n[More info.](termination.md#inter-process-termination)\n\n### CLI arguments\n\n```js\n// zx\nconst {myCliFlag} = argv;\n```\n\n```js\n// Execa\nimport {parseArgs} from 'node:util';\n\nconst {myCliFlag} = parseArgs({strict: false}).values;\n```\n\n[More info.](https://nodejs.org/api/util.html#utilparseargsconfig)\n\n### CLI prompts\n\n```sh\n# Bash\nread -p \"Question? \" answer\n```\n\n```js\n// zx\nconst answer = await question('Question? ');\n```\n\n```js\n// Execa\nimport input from '@inquirer/input';\n\nconst answer = await input({message: 'Question?'});\n```\n\n[More info.](https://github.com/SBoudrias/Inquirer.js)\n\n### CLI spinner\n\n```sh\n# Bash does not provide with a builtin spinner\n```\n\n```js\n// zx\nawait spinner(() => $`node script.js`);\n```\n\n```js\n// Execa\nimport {oraPromise} from 'ora';\n\nawait oraPromise($`node script.js`);\n```\n\n[More info.](https://github.com/sindresorhus/ora)\n\n### Sleep\n\n```sh\n# Bash\nsleep 5\n```\n\n```js\n// zx\nawait sleep(5000);\n```\n\n```js\n// Execa\nimport {setTimeout} from 'node:timers/promises';\n\nawait setTimeout(5000);\n```\n\n[More info.](https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options)\n\n### Globbing\n\n```sh\n# Bash\nls packages/*\n```\n\n```js\n// zx\nconst files = await glob(['packages/*']);\n```\n\n```js\n// Execa\nimport {glob} from 'node:fs/promises';\n\nconst files = await Array.fromAsync(glob('packages/*'));\n```\n\n[More info.](https://nodejs.org/api/fs.html#fspromisesglobpattern-options)\n\n### Temporary file\n\n```js\n// zx\nconst filePath = tmpfile();\n```\n\n```js\n// Execa\nimport tempfile from 'tempfile';\n\nconst filePath = tempfile();\n```\n\n[More info.](https://github.com/sindresorhus/tempfile)\n\n### HTTP requests\n\n```sh\n# Bash\ncurl https://github.com\n```\n\n```js\n// zx\nawait fetch('https://github.com');\n```\n\n```js\n// Execa\nawait fetch('https://github.com');\n```\n\n[More info.](https://nodejs.org/api/globals.html#fetch)\n\n### Retry on error\n\n```js\n// zx\nawait retry(\n\t5,\n\t() => $`curl -sSL https://sindresorhus.com/unicorn`,\n)\n```\n\n```js\n// Execa\nimport pRetry from 'p-retry';\n\nawait pRetry(\n\t() => $`curl -sSL https://sindresorhus.com/unicorn`,\n\t{retries: 5},\n);\n```\n\n[More info.](https://github.com/sindresorhus/p-retry)\n\n<hr>\n\n[**Next**: 🐭 Small packages](small.md)\\\n[**Previous**: 📎 Windows](windows.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/binary.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🤖 Binary data\n\n## Binary input\n\nThere are multiple ways to pass binary input using the [`stdin`](api.md#optionsstdin), [`input`](api.md#optionsinput) or [`inputFile`](api.md#optionsinputfile) options: `Uint8Array`s, [files](input.md#file-input), [streams](streams.md) or [other subprocesses](pipe.md).\n\nThis is required if the subprocess input includes [null bytes](https://en.wikipedia.org/wiki/Null_character).\n\n```js\nimport {execa} from 'execa';\n\nconst binaryData = new Uint8Array([/* ... */]);\nawait execa({stdin: binaryData})`hexdump`;\n```\n\n## Binary output\n\nBy default, the subprocess [output](api.md#resultstdout) is a [UTF8](https://en.wikipedia.org/wiki/UTF-8) string. If it is binary, the [`encoding`](api.md#optionsencoding) option should be set to `'buffer'` instead. The output will be an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).\n\n```js\nconst {stdout} = await execa({encoding: 'buffer'})`zip -r - input.txt`;\nconsole.log(stdout.byteLength);\n```\n\n## Encoding\n\nWhen the output is binary, the [`encoding`](api.md#optionsencoding) option can also be set to [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64) or [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications). The output will be a string then.\n\n```js\nconst {stdout} = await execa({encoding: 'hex'})`zip -r - input.txt`;\nconsole.log(stdout); // Hexadecimal string\n```\n\n## Iterable\n\nBy default, the subprocess [iterates](lines.md#progressive-splitting) over line strings. However, if the [`encoding`](api.md#optionsencoding) subprocess option is binary, or if the [`binary`](api.md#readableoptionsbinary) iterable option is `true`, it iterates over arbitrary chunks of [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) data instead.\n\n```js\nfor await (const data of execa({encoding: 'buffer'})`zip -r - input.txt`) {\n\t/* ... */\n}\n```\n\n## Transforms\n\nThe same applies to transforms. When the [`encoding`](api.md#optionsencoding) subprocess option is binary, or when the [`binary`](api.md#transformoptionsbinary) transform option is `true`, it iterates over arbitrary chunks of [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) data instead.\n\nHowever, transforms can always `yield` either a `string` or an `Uint8Array`, regardless of whether the output is binary or not.\n\n```js\nconst transform = function * (data) {\n\t/* ... */\n}\n\nawait execa({stdout: {transform, binary: true}})`zip -r - input.txt`;\n```\n\n## Streams\n\n[Streams produced](streams.md#converting-a-subprocess-to-a-stream) by [`subprocess.readable()`](api.md#subprocessreadablereadableoptions) and [`subprocess.duplex()`](api.md#subprocessduplexduplexoptions) are binary by default, which means they iterate over arbitrary [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) chunks. However, if the [`binary`](api.md#readableoptionsbinary) option is `false`, they iterate over line strings instead, and the stream is [in object mode](https://nodejs.org/api/stream.html#object-mode).\n\n```js\nconst readable = execa`npm run build`.readable({binary: false});\nreadable.on('data', lineString => {\n\t/* ... */\n});\n```\n\n<hr>\n\n[**Next**: 🧙 Transforms](transform.md)\\\n[**Previous**: 📃 Text lines](lines.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/debugging.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🐛 Debugging\n\n## Command\n\n[`error.command`](api.md#resultcommand) contains the file and [arguments](input.md#command-arguments) that were run. It is intended for logging or debugging.\n\n[`error.escapedCommand`](api.md#resultescapedcommand) is the same, except control characters are escaped. This makes it safe to either print or copy and paste in a terminal, for debugging purposes.\n\nSince the escaping is fairly basic, neither `error.command` nor `error.escapedCommand` should be executed directly, including using [`execa()`](api.md#execafile-arguments-options) or [`parseCommandString()`](api.md#parsecommandstringcommand).\n\n```js\nimport {execa} from 'execa';\n\ntry {\n\tawait execa`npm run build\\ntask`;\n} catch (error) {\n\tconsole.error(error.command); // \"npm run build\\ntask\"\n\tconsole.error(error.escapedCommand); // \"npm run 'build\\\\ntask'\"\n\tthrow error;\n}\n```\n\n## Duration\n\n```js\ntry {\n\tconst result = await execa`npm run build`;\n\tconsole.log('Command duration:', result.durationMs); // 150\n} catch (error) {\n\tconsole.error('Command duration:', error.durationMs); // 150\n\tthrow error;\n}\n```\n\n## Verbose mode\n\n### Short mode\n\nWhen the [`verbose`](api.md#optionsverbose) option is `'short'`, the [command](#command), [duration](#duration) and [error messages](errors.md#error-message) are printed on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).\n\n```js\n// build.js\nawait execa({verbose: 'short'})`npm run build`;\n```\n\n```\n$ node build.js\n[20:36:11.043] [0] $ npm run build\n[20:36:11.885] [0] ✔ (done in 842ms)\n```\n\n### Full mode\n\nWhen the [`verbose`](api.md#optionsverbose) option is `'full'`, the subprocess' [`stdout`, `stderr`](output.md) and [IPC messages](ipc.md) are also logged. They are all printed on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).\n\nThe output is not logged if either:\n- The [`stdout`](api.md#optionsstdout)/[`stderr`](api.md#optionsstderr) option is [`'ignore'`](output.md#ignore-output) or [`'inherit'`](output.md#terminal-output).\n- The `stdout`/`stderr` is redirected to [a stream](streams.md#output), [a file](output.md#file-output), [a file descriptor](output.md#terminal-output), or [another subprocess](pipe.md).\n- The [`encoding`](api.md#optionsencoding) option is [binary](binary.md#binary-output).\n\n```js\n// build.js\nawait execa({verbose: 'full'})`npm run build`;\nawait execa({verbose: 'full'})`npm run test`;\n```\n\n```\n$ node build.js\n[00:57:44.581] [0] $ npm run build\n[00:57:44.653] [0]   Building application...\n[00:57:44.653] [0]   Done building.\n[00:57:44.658] [0] ✔ (done in 78ms)\n[00:57:44.658] [1] $ npm run test\n[00:57:44.740] [1]   Running tests...\n[00:57:44.740] [1]   Error: the entrypoint is invalid.\n[00:57:44.747] [1] ✘ Command failed with exit code 1: npm run test\n[00:57:44.747] [1] ✘ (done in 89ms)\n```\n\n### Global mode\n\nWhen the `NODE_DEBUG=execa` [environment variable](https://en.wikipedia.org/wiki/Environment_variable) is set, the [`verbose`](api.md#optionsverbose) option defaults to `'full'` for all commands.\n\n```js\n// build.js\n\n// This is logged by default\nawait execa`npm run build`;\n// This is not logged\nawait execa({verbose: 'none'})`npm run test`;\n```\n\n```\n$ NODE_DEBUG=execa node build.js\n```\n\n### Colors\n\nWhen printed to a terminal, the verbose mode uses colors.\n\n<img alt=\"execa verbose output\" src=\"../media/verbose.png\" width=\"603\">\n\n## Custom logging\n\n### Verbose function\n\nThe [`verbose`](api.md#optionsverbose) option can be a function to customize logging.\n\nIt is called once per log line. The first argument is the default log line string. The second argument is the same information but as an object instead (documented [here](api.md#verbose-object)).\n\nIf a string is returned, it is printed on `stderr`. If `undefined` is returned, nothing is printed.\n\n### Filter logs\n\n```js\nimport {execa as execa_} from 'execa';\n\n// Only print log lines showing the subprocess duration\nconst execa = execa_({\n\tverbose(verboseLine, {type}) {\n\t\treturn type === 'duration' ? verboseLine : undefined;\n\t},\n});\n```\n\n### Transform logs\n\n```js\nimport {execa as execa_} from 'execa';\n\n// Prepend current process' PID\nconst execa = execa_({\n\tverbose(verboseLine) {\n\t\treturn `[${process.pid}] ${verboseLine}`;\n\t},\n});\n```\n\n### Custom log format\n\n```js\nimport {execa as execa_} from 'execa';\n\n// Use a different format for the timestamp\nconst execa = execa_({\n\tverbose(verboseLine, {timestamp}) {\n\t\treturn verboseLine.replace(timestampRegExp, timestamp.toISOString());\n\t},\n});\n\n// Timestamp at the start of each log line\nconst timestampRegExp = /\\d{2}:\\d{2}:\\d{2}\\.\\d{3}/;\n```\n\n### JSON logging\n\n```js\nimport {execa as execa_} from 'execa';\n\nconst execa = execa_({\n\tverbose(verboseLine, verboseObject) {\n\t\treturn JSON.stringify(verboseObject);\n\t},\n});\n```\n\n### Advanced logging\n\n```js\nimport {execa as execa_} from 'execa';\nimport {createLogger, transports} from 'winston';\n\n// Log to a file using Winston\nconst transport = new transports.File({filename: 'logs.txt'});\nconst logger = createLogger({transports: [transport]});\nconst LOG_LEVELS = {\n\tcommand: 'info',\n\toutput: 'verbose',\n\tipc: 'verbose',\n\terror: 'error',\n\tduration: 'info',\n};\n\nconst execa = execa_({\n\tverbose(verboseLine, {message, ...verboseObject}) {\n\t\tconst level = LOG_LEVELS[verboseObject.type];\n\t\tlogger[level](message, verboseObject);\n\t},\n});\n```\n\n<hr>\n\n[**Next**: 📎 Windows](windows.md)\\\n[**Previous**: 📞 Inter-process communication](ipc.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/environment.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🌐 Environment\n\n## Current directory\n\nThe [current directory](https://en.wikipedia.org/wiki/Working_directory) when running the command can be set with the [`cwd`](api.md#optionscwd) option.\n\n```js\nimport {execa} from 'execa';\n\nawait execa({cwd: '/path/to/cwd'})`npm run build`;\n```\n\nAnd be retrieved with the [`result.cwd`](api.md#resultcwd) property.\n\n```js\nconst {cwd} = await execa`npm run build`;\n```\n\n## Local binaries\n\nPackage managers like `npm` install local binaries in `./node_modules/.bin`.\n\n```sh\n$ npm install -D eslint\n```\n\n```js\nawait execa('./node_modules/.bin/eslint');\n```\n\nThe [`preferLocal`](api.md#optionspreferlocal) option can be used to execute those local binaries.\n\n```js\nawait execa({preferLocal: true})`eslint`;\n```\n\nThose are searched in the current or any parent directory. The [`localDir`](api.md#optionslocaldir) option can select a different directory.\n\n```js\nawait execa({preferLocal: true, localDir: '/path/to/dir'})`eslint`;\n```\n\n## Current package's binary\n\nExeca can be combined with [`get-bin-path`](https://github.com/ehmicky/get-bin-path) to test the current package's binary. As opposed to hard-coding the path to the binary, this validates that the `package.json` [`bin`](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#bin) field is correctly set up.\n\n```js\nimport {execa} from 'execa';\nimport {getBinPath} from 'get-bin-path';\n\nconst binPath = await getBinPath();\nawait execa(binPath);\n```\n\n## Background subprocess\n\nWhen the [`detached`](api.md#optionsdetached) option is `true`, the subprocess [runs independently](https://en.wikipedia.org/wiki/Background_process) from the current process.\n\nSpecific behavior depends on the platform. [More info.](https://nodejs.org/api/child_process.html#child_process_options_detached)\n\n```js\nawait execa({detached: true})`npm run start`;\n```\n\n<hr>\n\n[**Next**: ❌ Errors](errors.md)\\\n[**Previous**: 🐢 Node.js files](node.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/errors.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# ❌ Errors\n\n## Subprocess failure\n\nWhen the subprocess fails, the promise returned by [`execa()`](api.md#execafile-arguments-options) is rejected with an [`ExecaError`](api.md#execaerror) instance. The `error` has the same shape as successful [results](api.md#result), with a few additional [error-specific fields](api.md#execaerror). [`error.failed`](api.md#resultfailed) is always `true`.\n\n```js\nimport {execa, ExecaError} from 'execa';\n\ntry {\n\tconst result = await execa`npm run build`;\n\tconsole.log(result.failed); // false\n} catch (error) {\n\tif (error instanceof ExecaError) {\n\t\tconsole.error(error.failed); // true\n\t}\n}\n```\n\n## Preventing exceptions\n\nWhen the [`reject`](api.md#optionsreject) option is `false`, the `error` is returned instead.\n\n```js\nconst resultOrError = await execa({reject: false})`npm run build`;\nif (resultOrError.failed) {\n\tconsole.error(resultOrError);\n}\n```\n\n## Exit code\n\nThe subprocess fails when its [exit code](https://en.wikipedia.org/wiki/Exit_status) is not `0`. The exit code is available as [`error.exitCode`](api.md#errorexitcode). It is `undefined` when the subprocess fails to spawn or when it was [terminated by a signal](termination.md#signal-termination).\n\n```js\ntry {\n\tawait execa`npm run build`;\n} catch (error) {\n\t// Either non-0 integer or undefined\n\tconsole.error(error.exitCode);\n}\n```\n\n## Failure reason\n\nThe subprocess can fail for other reasons. Some of them can be detected using a specific boolean property:\n- [`error.timedOut`](api.md#errortimedout): [`timeout`](termination.md#timeout) option.\n- [`error.isCanceled`](api.md#erroriscanceled): [`cancelSignal`](termination.md#canceling) option.\n- [`error.isGracefullyCanceled`](api.md#errorisgracefullycanceled): `cancelSignal` option, if the [`gracefulCancel`](termination.md#graceful-termination) option is `true`.\n- [`error.isMaxBuffer`](api.md#errorismaxbuffer): [`maxBuffer`](output.md#big-output) option.\n- [`error.isTerminated`](api.md#erroristerminated): [signal termination](termination.md#signal-termination). This includes the [`timeout`](termination.md#timeout) and [`forceKillAfterDelay`](termination.md#forceful-termination) options since those terminate the subprocess with a [signal](termination.md#default-signal). This also includes the [`cancelSignal`](termination.md#canceling) option unless the [`gracefulCancel`](termination.md#graceful-termination) option is `true`. This does not include the [`maxBuffer`](output.md#big-output) option.\n\nOtherwise, the subprocess failed because either:\n- An exception was thrown in a [stream](streams.md) or [transform](transform.md).\n- The command's executable file was not found.\n- An invalid [option](api.md#options-1) was passed.\n- There was not enough memory or too many subprocesses.\n\n```js\ntry {\n\tawait execa`npm run build`;\n} catch (error) {\n\tif (error.timedOut) {\n\t\thandleTimeout(error);\n\t}\n\n\tthrow error;\n}\n```\n\n## Error message\n\nFor better [debugging](debugging.md), [`error.message`](api.md#errormessage) includes both:\n- The command and the [reason it failed](#failure-reason).\n- Its [`stdout`, `stderr`](output.md#stdout-and-stderr), [other file descriptors'](output.md#additional-file-descriptors) output and [IPC messages](ipc.md), separated with newlines and not [interleaved](output.md#interleaved-output).\n\n[`error.shortMessage`](api.md#errorshortmessage) is the same but without `stdout`, `stderr` nor IPC messages.\n\n[`error.originalMessage`](api.md#errororiginalmessage) is the same but also without the command. This exists only in specific instances, such as when calling [`subprocess.kill(error)`](termination.md#error-message-and-stack-trace), using the [`cancelSignal`](termination.md#canceling) option, passing an invalid command or [option](api.md#options-1), or throwing an exception in a [stream](streams.md) or [transform](transform.md).\n\n```js\ntry {\n\tawait execa`npm run build`;\n} catch (error) {\n\tconsole.error(error.originalMessage);\n\t// The task \"build\" does not exist.\n\n\tconsole.error(error.shortMessage);\n\t// Command failed with exit code 3: npm run build\n\t// The task \"build\" does not exist.\n\n\tconsole.error(error.message);\n\t// Command failed with exit code 3: npm run build\n\t// The task \"build\" does not exist.\n\t// [stderr contents...]\n\t// [stdout contents...]\n}\n```\n\n<hr>\n\n[**Next**: 🏁 Termination](termination.md)\\\n[**Previous**: 🌐 Environment](environment.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/escaping.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 💬 Escaping/quoting\n\n## Array syntax\n\nWhen using the [array syntax](execution.md#array-syntax), arguments are automatically escaped. They can contain any character, including spaces, tabs and newlines. However, they cannot contain [null bytes](https://en.wikipedia.org/wiki/Null_character): [binary inputs](binary.md#binary-input) should be used instead.\n\n```js\nimport {execa} from 'execa';\n\nawait execa('npm', ['run', 'task with space']);\n```\n\n## Template string syntax\n\nThe same applies when using the [template string syntax](execution.md#template-string-syntax). However, spaces, tabs and newlines must use `${}`.\n\n```js\nawait execa`npm run ${'task with space'}`;\n```\n\n## User-defined input\n\nThe above syntaxes allow the file and its arguments to be user-defined by passing a variable.\n\n```js\nimport {execa} from 'execa';\n\nconst file = 'npm';\nconst commandArguments = ['run', 'task with space'];\nawait execa`${file} ${commandArguments}`;\n\nawait execa(file, commandArguments);\n```\n\nIf the file and/or multiple arguments are supplied as a single string, [`parseCommandString()`](api.md#parsecommandstringcommand) can split it into an array.\n\n```js\nimport {execa, parseCommandString} from 'execa';\n\nconst commandString = 'npm run task';\nconst commandArray = parseCommandString(commandString);\nawait execa`${commandArray}`;\n\nconst [file, ...commandArguments] = commandArray;\nawait execa(file, commandArguments);\n```\n\nSpaces are used as delimiters. They can be escaped with a backslash.\n\n```js\nawait execa`${parseCommandString('npm run task\\\\ with\\\\ space')}`;\n```\n\n## Shells\n\n[Shells](shell.md) ([Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)), [cmd.exe](https://en.wikipedia.org/wiki/Cmd.exe), etc.) are not used unless the [`shell`](api.md#optionsshell) option is set. This means shell-specific syntax has no special meaning and does not need to be escaped:\n- Quotes: `\"value\"`, `'value'`, `$'value'`\n- Characters: `$variable`, `&&`, `||`, `;`, `|`\n- Globbing: `*`, `**`\n- Expressions: `$?`, `~`\n\n```js\n// This prints `$TASK_NAME`, not `build`\nawait execa({env: {TASK_NAME: 'build'}})`echo $TASK_NAME`;\n```\n\nIf you do set the `shell` option, arguments will not be automatically escaped anymore. Instead, they will be concatenated as a single string using spaces as delimiters.\n\n```js\nawait execa({shell: true})`npm ${'run'} ${'task with space'}`;\n// Is the same as:\nawait execa({shell: true})`npm run task with space`;\n```\n\nTherefore, you need to manually quote the arguments, using the shell-specific syntax.\n\n```js\nawait execa({shell: true})`npm ${'run'} ${'\"task with space\"'}`;\n// Is the same as:\nawait execa({shell: true})`npm run \"task with space\"`;\n```\n\nSometimes a shell command is passed as argument to an executable that runs it indirectly. In that case, that shell command must quote its own arguments.\n\n```js\nconst command = 'npm run \"task with space\"';\nawait execa`ssh host ${command}`;\n```\n\n<hr>\n\n[**Next**: 💻 Shell](shell.md)\\\n[**Previous**: ️▶️ Basic execution](execution.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/execution.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# ▶️ Basic execution\n\n## Array syntax\n\n```js\nimport {execa} from 'execa';\n\nawait execa('npm', ['run', 'build']);\n```\n\n## Template string syntax\n\nAll [available methods](api.md#methods) can use either the [array syntax](#array-syntax) or the template string syntax, which are equivalent.\n\n```js\nawait execa`npm run build`;\n```\n\n### String argument\n\n```js\nawait execa`npm run ${'task with space'}`;\n```\n\n### Number argument\n\n```js\nawait execa`npm run build --concurrency ${2}`;\n```\n\n### Subcommands\n\n```js\nconst result = await execa`get-concurrency`;\n\n// Uses `result.stdout`\nawait execa`npm run build --concurrency ${result}`;\n```\n\n### Concatenation\n\n```js\nconst tmpDirectory = '/tmp';\nawait execa`mkdir ${tmpDirectory}/filename`;\n```\n\n### Multiple arguments\n\n```js\nconst result = await execa`get-concurrency`;\n\nawait execa`npm ${['run', 'build', '--concurrency', result]}`;\n```\n\n### No arguments\n\n```js\nawait execa`npm run build ${[]}`;\n// Same as:\nawait execa('npm', ['run', 'build']);\n```\n\n### Empty string argument\n\n```js\nawait execa`npm run build ${''}`;\n// Same as:\nawait execa('npm', ['run', 'build', '']);\n```\n\n### Conditional argument\n\n```js\nconst commandArguments = failFast ? ['--fail-fast'] : [];\nawait execa`npm run build ${commandArguments}`;\n```\n\n### Multiple lines\n\n```js\nawait execa`npm run build\n\t--concurrency 2\n\t--fail-fast`;\n```\n\n### Shells\n\nBy default, any shell-specific syntax has no special meaning and does not need to be escaped. This prevents [shell injections](https://en.wikipedia.org/wiki/Code_injection#Shell_injection). [More info.](escaping.md#shells)\n\n```js\n// This prints `$TASK_NAME`, not `build`\nawait execa({env: {TASK_NAME: 'build'}})`echo $TASK_NAME`;\n```\n\n## Options\n\n[Options](api.md#options-1) can be passed to influence the execution's behavior.\n\n### Array syntax\n\n```js\nawait execa('npm', ['run', 'build'], {timeout: 5000});\n```\n\n### Template string syntax\n\n```js\nawait execa({timeout: 5000})`npm run build`;\n```\n\n### Global/shared options\n\n```js\nconst timedExeca = execa({timeout: 5000});\n\nawait timedExeca('npm', ['run', 'build']);\nawait timedExeca`npm run test`;\n```\n\n## Return value\n\n### Subprocess\n\nThe subprocess is returned as soon as it is spawned. It is a [`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with [additional methods and properties](api.md#subprocess).\n\n```js\nconst subprocess = execa`npm run build`;\nconsole.log(subprocess.pid);\n```\n\n### Result\n\nThe subprocess is also a `Promise` that resolves with the [`result`](api.md#result).\n\n```js\nconst {stdout} = await execa`npm run build`;\n```\n\n### Synchronous execution\n\n[`execaSync()`](api.md#execasyncfile-arguments-options) and [`$.sync()`](api.md#syncfile-arguments-options) return the [`result`](api.md#result) without needing to `await`. The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.\n\n```js\nimport {execaSync} from 'execa';\n\nconst {stdout} = execaSync`npm run build`;\n```\n\nSynchronous execution is generally discouraged as it holds the CPU and prevents parallelization. Also, the following features cannot be used:\n- Streams: [`subprocess.stdin`](api.md#subprocessstdin), [`subprocess.stdout`](api.md#subprocessstdout), [`subprocess.stderr`](api.md#subprocessstderr), [`subprocess.readable()`](api.md#subprocessreadablereadableoptions), [`subprocess.writable()`](api.md#subprocesswritablewritableoptions), [`subprocess.duplex()`](api.md#subprocessduplexduplexoptions).\n- The [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) and [`stdio`](api.md#optionsstdio) options cannot be [`'overlapped'`](api.md#optionsstdout), an [async iterable](lines.md#progressive-splitting), an async [transform](transform.md), a [`Duplex`](transform.md#duplextransform-streams), nor a [web stream](streams.md#web-streams). Node.js streams can be passed but only if either they [have a file descriptor](streams.md#file-descriptors), or the [`input`](api.md#optionsinput) option is used.\n- Signal termination: [`subprocess.kill()`](api.md#subprocesskillerror), [`subprocess.pid`](api.md#subprocesspid), [`cleanup`](api.md#optionscleanup) option, [`cancelSignal`](api.md#optionscancelsignal) option, [`forceKillAfterDelay`](api.md#optionsforcekillafterdelay) option.\n- Piping multiple subprocesses: [`subprocess.pipe()`](api.md#subprocesspipefile-arguments-options).\n- [`subprocess.iterable()`](lines.md#progressive-splitting).\n- [IPC](ipc.md): [`sendMessage()`](api.md#sendmessagemessage-sendmessageoptions), [`getOneMessage()`](api.md#getonemessagegetonemessageoptions), [`getEachMessage()`](api.md#geteachmessagegeteachmessageoptions), [`result.ipcOutput`](output.md#any-output-type), [`ipc`](api.md#optionsipc) option, [`serialization`](api.md#optionsserialization) option, [`ipcInput`](input.md#any-input-type) option.\n- [`result.all`](api.md#resultall) is not interleaved.\n- [`detached`](api.md#optionsdetached) option.\n- The [`maxBuffer`](api.md#optionsmaxbuffer) option is always measured in bytes, not in characters, [lines](api.md#optionslines) nor [objects](transform.md#object-mode). Also, it ignores transforms and the [`encoding`](api.md#optionsencoding) option.\n\n<hr>\n\n[**Next**: 💬 Escaping/quoting](escaping.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/input.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🎹 Input\n\n## Command arguments\n\nThe simplest way to pass input to a subprocess is to use command arguments.\n\n```js\nimport {execa} from 'execa';\n\nconst commandArgument = 'build';\nawait execa`node child.js ${commandArgument}`;\n```\n\nIf the subprocess is a Node.js file, those are available using [`process.argv`](https://nodejs.org/api/process.html#processargv).\n\n```js\n// child.js\nimport process from 'node:process';\n\nconst commandArgument = process.argv[2];\n```\n\n## Environment variables\n\nUnlike [command arguments](#command-arguments), [environment variables](https://en.wikipedia.org/wiki/Environment_variable) have names. They are commonly used to configure applications.\n\nIf the subprocess spawns its own subprocesses, they inherit environment variables. To isolate subprocesses from each other, either command arguments or [`stdin`](#string-input) should be preferred instead.\n\n```js\n// Keep the current process' environment variables, and set `NO_COLOR`\nawait execa({env: {NO_COLOR: 'true'}})`node child.js`;\n// Discard the current process' environment variables, only pass `NO_COLOR`\nawait execa({env: {NO_COLOR: 'true'}, extendEnv: false})`node child.js`;\n```\n\nIf the subprocess is a Node.js file, environment variables are available using [`process.env`](https://nodejs.org/api/process.html#processenv).\n\n```js\n// child.js\nimport process from 'node:process';\n\nconsole.log(process.env.NO_COLOR);\n```\n\n## String input\n\nAlternatively, input can be provided to [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). Unlike [command arguments](#command-arguments) and [environment variables](#environment-variables) which have [size](https://unix.stackexchange.com/questions/120642/what-defines-the-maximum-size-for-a-command-single-argument) [limits](https://stackoverflow.com/questions/1078031/what-is-the-maximum-size-of-a-linux-environment-variable-value), `stdin` works when the input is big. Also, the input can be redirected from the [terminal](#terminal-input), a [file](#file-input), another [subprocess](pipe.md) or a [stream](streams.md#manual-streaming). Finally, this is required when the input might contain [null bytes](https://en.wikipedia.org/wiki/Null_character), for example when it might be [binary](binary.md#binary-input).\n\nIf the input is already available as a string, it can be passed directly to the [`input`](api.md#optionsinput) option.\n\n```js\nawait execa({input: 'stdinInput'})`npm run scaffold`;\n```\n\nThe [`stdin`](api.md#optionsstdin) option can also be used, although the string must be wrapped in two arrays for [syntax reasons](output.md#multiple-targets).\n\n```js\nawait execa({stdin: [['stdinInput']]})`npm run scaffold`;\n```\n\n## Ignore input\n\n```js\nconst subprocess = execa({stdin: 'ignore'})`npm run scaffold`;\nconsole.log(subprocess.stdin); // undefined\nawait subprocess;\n```\n\n## File input\n\n```js\nawait execa({inputFile: 'input.txt'})`npm run scaffold`;\n// Or:\nawait execa({stdin: {file: 'input.txt'}})`npm run scaffold`;\n// Or:\nawait execa({stdin: new URL('file:///path/to/input.txt')})`npm run scaffold`;\n```\n\n## Terminal input\n\nThe parent process' input can be re-used in the subprocess by passing `'inherit'`. This is especially useful to receive interactive input in command line applications.\n\n```js\nawait execa({stdin: 'inherit'})`npm run scaffold`;\n```\n\n## Any input type\n\nIf the subprocess [uses Node.js](node.md), [almost any type](ipc.md#message-type) can be passed to the subprocess using the [`ipcInput`](ipc.md#send-an-initial-message) option. The subprocess retrieves that input using [`getOneMessage()`](api.md#getonemessagegetonemessageoptions).\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst ipcInput = [\n\t{task: 'lint', ignore: /test\\.js/},\n\t{task: 'copy', files: new Set(['main.js', 'index.js']),\n}];\nawait execaNode({ipcInput})`build.js`;\n```\n\n```js\n// build.js\nimport {getOneMessage} from 'execa';\n\nconst ipcInput = await getOneMessage();\n```\n\n## Multiple inputs\n\nThe input can come from multiple sources by setting the [`stdin`](api.md#optionsstdin) option to an array of values. Alternatively the [`input`](api.md#optionsinput), [`inputFile`](api.md#optionsinputfile) and [`stdin`](api.md#optionsstdin) options can be combined.\n\nThe following example redirects `stdin` from both the [terminal](#terminal-input) and an `input.txt` [file](#file-input).\n\n```js\nawait execa({stdin: ['inherit', {file: 'input.txt'}]})`npm run scaffold`;\n```\n\n__Loss of TTY control:__ Please note that when a file descriptor is configured with a combination of `'inherit'` and other values, this file descriptor will never refer to a TTY in the subprocess, even if in the current process it does.\n\n## Additional file descriptors\n\nThe [`stdio`](api.md#optionsstdio) option can be used to pass some input to any [file descriptor](https://en.wikipedia.org/wiki/File_descriptor), as opposed to only [`stdin`](api.md#optionsstdin).\n\n```js\n// Pass input to the file descriptor number 3\nawait execa({\n\tstdio: ['pipe', 'pipe', 'pipe', new Uint8Array([/* ... */])],\n})`npm run build`;\n```\n\n<hr>\n\n[**Next**: 📢 Output](output.md)\\\n[**Previous**: 🏁 Termination](termination.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/ipc.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 📞 Inter-process communication\n\n## Exchanging messages\n\nWhen the [`ipc`](api.md#optionsipc) option is `true`, the current process and subprocess can exchange messages. This only works if the subprocess is a [Node.js file](node.md).\n\nThe `ipc` option defaults to `true` when using [`execaNode()`](node.md#run-nodejs-files) or the [`node`](node.md#run-nodejs-files) option.\n\nPlease note that unlike `node:child_process` [`spawn()`](https://nodejs.org/api/child_process.html#optionsstdio), the [`stdio` option](api.md#optionsstdio) does not support the `'ipc'` value. Instead, the [`ipc`](api.md#optionsipc) option must be set to `true`.\n\nThe current process sends messages with [`subprocess.sendMessage(message)`](api.md#subprocesssendmessagemessage-sendmessageoptions) and receives them with [`subprocess.getOneMessage()`](api.md#subprocessgetonemessagegetonemessageoptions).\n\nThe subprocess uses [`sendMessage(message)`](api.md#sendmessagemessage-sendmessageoptions) and [`getOneMessage()`](api.md#getonemessagegetonemessageoptions). Those are the same methods, but imported directly from the `'execa'` module.\n\n```js\n// parent.js\nimport {execaNode} from 'execa';\n\nconst subprocess = execaNode`child.js`;\nawait subprocess.sendMessage('Hello from parent');\nconst message = await subprocess.getOneMessage();\nconsole.log(message); // 'Hello from child'\nawait subprocess;\n```\n\n```js\n// child.js\nimport {getOneMessage, sendMessage} from 'execa';\n\nconst message = await getOneMessage(); // 'Hello from parent'\nconst newMessage = message.replace('parent', 'child'); // 'Hello from child'\nawait sendMessage(newMessage);\n```\n\n## Listening to messages\n\nThe methods described above read a single message. On the other hand, [`subprocess.getEachMessage()`](api.md#subprocessgeteachmessagegeteachmessageoptions) and [`getEachMessage()`](api.md#geteachmessagegeteachmessageoptions) return an [async iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols). This should be preferred when listening to multiple messages.\n\n[`subprocess.getEachMessage()`](api.md#subprocessgeteachmessagegeteachmessageoptions) waits for the subprocess to end (even when using [`break`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break) or [`return`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)). It throws if the subprocess [fails](api.md#result). This means you do not need to `await` the subprocess' [promise](execution.md#result).\n\n```js\n// parent.js\nimport {execaNode} from 'execa';\n\nconst subprocess = execaNode`child.js`;\nawait subprocess.sendMessage(0);\n\n// This loop ends when the subprocess exits.\n// It throws if the subprocess fails.\nfor await (const message of subprocess.getEachMessage()) {\n\tconsole.log(message); // 1, 3, 5, 7, 9\n\tawait subprocess.sendMessage(message + 1);\n}\n```\n\n```js\n// child.js\nimport {sendMessage, getEachMessage} from 'execa';\n\n// The subprocess exits when hitting `break`\nfor await (const message of getEachMessage()) {\n\tif (message === 10) {\n\t\tbreak;\n\t}\n\n\tconsole.log(message); // 0, 2, 4, 6, 8\n\tawait sendMessage(message + 1);\n}\n```\n\n## Filter messages\n\n```js\nimport {getOneMessage} from 'execa';\n\nconst startMessage = await getOneMessage({\n\tfilter: message => message.type === 'start',\n});\n```\n\n```js\nimport {getEachMessage} from 'execa';\n\nfor await (const message of getEachMessage()) {\n\tif (message.type === 'start') {\n\t\t// ...\n\t}\n}\n```\n\n## Ensure messages are received\n\nWhen a message is sent by one process, the other process must receive it using [`getOneMessage()`](#exchanging-messages), [`getEachMessage()`](#listening-to-messages), or automatically with [`result.ipcOutput`](api.md#resultipcoutput). If not, that message is silently discarded.\n\nIf the [`strict: true`](api.md#sendmessageoptionsstrict) option is passed to [`subprocess.sendMessage(message)`](api.md#subprocesssendmessagemessage-sendmessageoptions) or [`sendMessage(message)`](api.md#sendmessagemessage-sendmessageoptions), an error is thrown instead. This helps identifying subtle race conditions like the following example.\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst subprocess = execaNode`build.js`;\n// This `build` message is received\nawait subprocess.sendMessage('build', {strict: true});\n// This `lint` message is not received, so it throws\nawait subprocess.sendMessage('lint', {strict: true});\nawait subprocess;\n```\n\n```js\n// build.js\nimport {getOneMessage} from 'execa';\n\n// Receives the 'build' message\nconst task = await getOneMessage();\n// The `lint` message is sent while `runTask()` is ongoing\n// Therefore the `lint` message is discarded\nawait runTask(task);\n\n// Does not receive the `lint` message\n// Without `strict`, this would wait forever\nconst secondTask = await getOneMessage();\nawait runTask(secondTask);\n```\n\n## Retrieve all messages\n\nThe [`result.ipcOutput`](api.md#resultipcoutput) array contains all the messages sent by the subprocess. In many situations, this is simpler than using [`subprocess.getOneMessage()`](api.md#subprocessgetonemessagegetonemessageoptions) and [`subprocess.getEachMessage()`](api.md#subprocessgeteachmessagegeteachmessageoptions).\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst {ipcOutput} = await execaNode`build.js`;\nconsole.log(ipcOutput[0]); // {kind: 'start', timestamp: date}\nconsole.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}\n```\n\n```js\n// build.js\nimport {sendMessage} from 'execa';\n\nawait sendMessage({kind: 'start', timestamp: new Date()});\nawait runBuild();\nawait sendMessage({kind: 'stop', timestamp: new Date()});\n```\n\n## Send an initial message\n\nThe [`ipcInput`](api.md#optionsipcinput) option sends a message to the [Node.js subprocess](node.md) when it starts.\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst ipcInput = [\n\t{task: 'lint', ignore: /test\\.js/},\n\t{task: 'copy', files: new Set(['main.js', 'index.js']),\n}];\nawait execaNode({ipcInput})`build.js`;\n```\n\n```js\n// build.js\nimport {getOneMessage} from 'execa';\n\nconst ipcInput = await getOneMessage();\n```\n\n## Message type\n\nBy default, messages are serialized using [`structuredClone()`](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm). This supports most types including objects, arrays, `Error`, `Date`, `RegExp`, `Map`, `Set`, `bigint`, `Uint8Array`, and circular references. This throws when passing functions, symbols or promises (including inside an object or array).\n\nTo limit messages to JSON instead, the [`serialization`](api.md#optionsserialization) option can be set to `'json'`.\n\n```js\nimport {execaNode} from 'execa';\n\nawait execaNode({serialization: 'json'})`child.js`;\n```\n\n## Messages order\n\nThe messages are always received in the same order they were sent. Even when sent all at once.\n\n```js\nimport {sendMessage} from 'execa';\n\nawait Promise.all([\n\tsendMessage('first'),\n\tsendMessage('second'),\n\tsendMessage('third'),\n]);\n```\n\n## Keeping the subprocess alive\n\nBy default, the subprocess is kept alive as long as [`getOneMessage()`](api.md#getonemessagegetonemessageoptions) or [`getEachMessage()`](api.md#geteachmessagegeteachmessageoptions) is waiting. This is recommended if you're sure the current process will send a message, as this prevents the subprocess from exiting too early.\n\nHowever, if you don't know whether a message will be sent, this can leave the subprocess hanging forever. In that case, the [`reference: false`](api.md#geteachmessageoptionsreference) option can be set.\n\n```js\nimport {getEachMessage} from 'execa';\n\n// {type: 'gracefulExit'} is sometimes received, but not always\nfor await (const message of getEachMessage({reference: false})) {\n\tif (message.type === 'gracefulExit') {\n\t\tgracefulExit();\n\t}\n}\n```\n\n## Debugging\n\nWhen the [`verbose`](api.md#optionsverbose) option is `'full'`, the IPC messages sent by the subprocess to the current process are [printed on the console](debugging.md#full-mode).\n\nAlso, when the subprocess [failed](errors.md#subprocess-failure), [`error.ipcOutput`](api.md) contains all the messages sent by the subprocess. Those are also shown at the end of the [error message](errors.md#error-message).\n\n<hr>\n\n[**Next**: 🐛 Debugging](debugging.md)\\\n[**Previous**: ⏳️ Streams](streams.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/lines.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 📃 Text lines\n\n## Simple splitting\n\nIf the [`lines`](api.md#optionslines) option is `true`, the output is split into lines, as an array of strings.\n\n```js\nimport {execa} from 'execa';\n\nconst lines = await execa({lines: true})`npm run build`;\nconsole.log(lines.join('\\n'));\n```\n\n## Iteration\n\n### Progressive splitting\n\nThe subprocess' return value is an [async iterable](api.md#subprocesssymbolasynciterator). It iterates over the output's lines while the subprocess is still running.\n\n```js\nfor await (const line of execa`npm run build`) {\n\tif (line.includes('ERROR')) {\n\t\tconsole.log(line);\n\t}\n}\n```\n\nAlternatively, [`subprocess.iterable()`](api.md#subprocessiterablereadableoptions) can be called to pass [iterable options](api.md#readableoptions).\n\nThe iteration waits for the subprocess to end (even when using [`break`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/break) or [`return`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return)). It throws if the subprocess [fails](api.md#result). This means you do not need to `await` the subprocess' [promise](execution.md#result).\n\n```js\nfor await (const line of execa`npm run build`.iterable())) {\n\t/* ... */\n}\n```\n\n### Stdout/stderr\n\nBy default, the subprocess' [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) is used. The [`from`](api.md#readableoptionsfrom) iterable option can select a different file descriptor, such as [`'stderr'`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)), [`'all'`](output.md#interleaved-output) or [`'fd3'`](output.md#additional-file-descriptors).\n\n```js\nfor await (const stderrLine of execa`npm run build`.iterable({from: 'stderr'})) {\n\t/* ... */\n}\n```\n\n## Newlines\n\n### Final newline\n\nThe final newline is stripped from the output's last line, unless the [`stripFinalNewline`](api.md#optionsstripfinalnewline) option is `false`.\n\n```js\nconst {stdout} = await execa({stripFinalNewline: false})`npm run build`;\nconsole.log(stdout.endsWith('\\n')); // true\n```\n\n### Array of lines\n\nWhen using the [`lines`](#simple-splitting) option, newlines are stripped from each line, unless the [`stripFinalNewline`](api.md#optionsstripfinalnewline) option is `false`.\n\n```js\n// Each line now ends with '\\n'.\n// The last `line` might or might not end with '\\n', depending on the output.\nconst lines = await execa({lines: true, stripFinalNewline: false})`npm run build`;\nconsole.log(lines.join(''));\n```\n\n### Iterable\n\nWhen [iterating](#progressive-splitting) over lines, newlines are stripped from each line, unless the [`preserveNewlines`](api.md#readableoptionspreservenewlines) iterable option is `true`.\n\nThis option can also be used with [streams produced](streams.md#converting-a-subprocess-to-a-stream) by [`subprocess.readable()`](api.md#subprocessreadablereadableoptions) or [`subprocess.duplex()`](api.md#subprocessduplexduplexoptions), providing the [`binary`](binary.md#streams) option is `false`.\n\n```js\n// `line` now ends with '\\n'.\n// The last `line` might or might not end with '\\n', depending on the output.\nfor await (const line of execa`npm run build`.iterable({preserveNewlines: true})) {\n\t/* ... */\n}\n```\n\n### Transforms\n\nWhen using [transforms](transform.md), newlines are stripped from each `line` argument, unless the [`preserveNewlines`](api.md#transformoptionspreservenewlines) transform option is `true`.\n\n```js\n// `line` now ends with '\\n'.\n// The last `line` might or might not end with '\\n', depending on the output.\nconst transform = function * (line) { /* ... */ };\n\nawait execa({stdout: {transform, preserveNewlines: true}})`npm run build`;\n```\n\nEach `yield` produces at least one line. Calling `yield` multiple times or calling `yield *` produces multiples lines.\n\n```js\nconst transform = function * (line) {\n\tyield 'Important note:';\n\tyield 'Read the comments below.';\n\n\t// Or:\n\tyield * [\n\t\t'Important note:',\n\t\t'Read the comments below.',\n\t];\n\n\t// Is the same as:\n\tyield 'Important note:\\nRead the comments below.\\n';\n\n\tyield line;\n};\n\nawait execa({stdout: transform})`npm run build`;\n```\n\nHowever, if the [`preserveNewlines`](api.md#transformoptionspreservenewlines) transform option is `true`, multiple `yield`s produce a single line instead.\n\n```js\nconst transform = function * (line) {\n\tyield 'Important note: ';\n\tyield 'Read the comments below.\\n';\n\n\t// Is the same as:\n\tyield 'Important note: Read the comments below.\\n';\n\n\tyield line;\n};\n\nawait execa({stdout: {transform, preserveNewlines: true}})`npm run build`;\n```\n\n<hr>\n\n[**Next**: 🤖 Binary data](binary.md)\\\n[**Previous**: 📢 Output](output.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/node.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🐢 Node.js files\n\n## Run Node.js files\n\n```js\nimport {execaNode, execa} from 'execa';\n\nawait execaNode`file.js argument`;\n// Is the same as:\nawait execa({node: true})`file.js argument`;\n// Or:\nawait execa`node file.js argument`;\n```\n\n## Node.js CLI flags\n\nWhen using the [`node`](api.md#optionsnode) option or [`execaNode()`](api.md#execanodescriptpath-arguments-options), the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) are inherited. For example, the subprocess will use [`--allow-fs-read`](https://nodejs.org/api/cli.html#--allow-fs-read) if the current process does.\n\nThe [`nodeOptions`](api.md#optionsnodeoptions) option can be used to set different CLI flags.\n\n```js\nawait execaNode({nodeOptions: ['--allow-fs-write']})`file.js argument`;\n```\n\n## Node.js version\n\nThe same applies to the Node.js version, which is inherited too.\n\n[`get-node`](https://github.com/ehmicky/get-node) and the [`nodePath`](api.md#optionsnodepath) option can be used to run a specific Node.js version. Alternatively, [`nvexeca`](https://github.com/ehmicky/nvexeca) or [`nve`](https://github.com/ehmicky/nve) can be used.\n\n```js\nimport {execaNode} from 'execa';\nimport getNode from 'get-node';\n\nconst {path: nodePath} = await getNode('16.2.0');\nawait execaNode({nodePath})`file.js argument`;\n```\n\n<hr>\n\n[**Next**: 🌐 Environment](environment.md)\\\n[**Previous**: 📜 Scripts](scripts.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/output.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 📢 Output\n\n## Stdout and stderr\n\nThe [`stdout`](api.md#optionsstdout) and [`stderr`](api.md#optionsstderr) options redirect the subprocess output. They default to `'pipe'`, which returns the output using [`result.stdout`](api.md#resultstdout) and [`result.stderr`](api.md#resultstderr).\n\n```js\nimport {execa} from 'execa';\n\nconst {stdout, stderr} = await execa`npm run build`;\nconsole.log(stdout);\nconsole.log(stderr);\n```\n\n## Ignore output\n\n```js\nconst {stdout, stderr} = await execa({stdout: 'ignore'})`npm run build`;\nconsole.log(stdout); // undefined\nconsole.log(stderr); // string with errors\n```\n\n## File output\n\n```js\nawait execa({stdout: {file: 'output.txt'}})`npm run build`;\n// Or:\nawait execa({stdout: new URL('file:///path/to/output.txt')})`npm run build`;\n```\n\n```js\n// Redirect interleaved stdout and stderr to same file\nconst output = {file: 'output.txt'};\nawait execa({stdout: output, stderr: output})`npm run build`;\n```\n\n```js\n// Append instead of overwriting\nawait execa({stdout: {file: 'output.txt', append: true}})`npm run build`;\n```\n\n## Terminal output\n\nThe parent process' output can be re-used in the subprocess by passing `'inherit'`. This is especially useful to print to the terminal in command line applications.\n\n```js\nawait execa({stdout: 'inherit', stderr: 'inherit'})`npm run build`;\n```\n\nTo redirect from/to a different [file descriptor](https://en.wikipedia.org/wiki/File_descriptor), pass its [number](https://en.wikipedia.org/wiki/Standard_streams) or [`process.stdout`](https://nodejs.org/api/process.html#processstdout)/[`process.stderr`](https://nodejs.org/api/process.html#processstderr).\n\n```js\n// Print both stdout/stderr to the parent stdout\nawait execa({stdout: process.stdout, stderr: process.stdout})`npm run build`;\n// Or:\nawait execa({stdout: 1, stderr: 1})`npm run build`;\n```\n\n## Any output type\n\nIf the subprocess uses Node.js, [IPC](ipc.md) can be used to return [almost any type](ipc.md#message-type) from the subprocess. The [`result.ipcOutput`](api.md#resultipcoutput) array contains all the messages sent by the subprocess.\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst {ipcOutput} = await execaNode`build.js`;\nconsole.log(ipcOutput[0]); // {kind: 'start', timestamp: date}\nconsole.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}\n```\n\n```js\n// build.js\nimport {sendMessage} from 'execa';\n\nawait sendMessage({kind: 'start', timestamp: new Date()});\nawait runBuild();\nawait sendMessage({kind: 'stop', timestamp: new Date()});\n```\n\n## Multiple targets\n\nThe output can be redirected to multiple targets by setting the [`stdout`](api.md#optionsstdout) or [`stderr`](api.md#optionsstderr) option to an array of values.\n\nThe following example redirects `stdout` to both the [terminal](#terminal-output) and an `output.txt` [file](#file-output), while also retrieving its value [programmatically](#stdout-and-stderr).\n\n```js\nconst {stdout} = await execa({stdout: ['inherit', {file: 'output.txt'}, 'pipe']})`npm run build`;\nconsole.log(stdout);\n```\n\n__Loss of TTY control:__ Please note that when a file descriptor is configured with a combination of 'inherit' and other values, this file descriptor will never refer to a TTY in the subprocess, even if in the current process it does.\n\n## Interleaved output\n\nIf the [`all`](api.md#optionsall) option is `true`, [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) are combined:\n- [`result.all`](api.md#resultall): [`result.stdout`](api.md#resultstdout) + [`result.stderr`](api.md#resultstderr)\n- [`subprocess.all`](api.md#subprocessall): [`subprocess.stdout`](api.md#subprocessstdout) + [`subprocess.stderr`](api.md#subprocessstderr)\n\n`stdout` and `stderr` are guaranteed to interleave. However, for performance reasons, the subprocess might buffer and merge multiple simultaneous writes to `stdout` or `stderr`. This can prevent proper interleaving.\n\nFor example, this prints `1 3 2` instead of `1 2 3` because both `console.log()` are merged into a single write.\n\n```js\nconst {all} = await execa({all: true})`node example.js`;\n```\n\n```js\n// example.js\nconsole.log('1'); // writes to stdout\nconsole.error('2'); // writes to stderr\nconsole.log('3'); // writes to stdout\n```\n\nThis can be worked around by using `setTimeout()`.\n\n```js\nimport {setTimeout} from 'timers/promises';\n\nconsole.log('1');\nconsole.error('2');\nawait setTimeout(0);\nconsole.log('3');\n```\n\n## Stdout/stderr-specific options\n\nSome options are related to the subprocess output: [`verbose`](api.md#optionsverbose), [`lines`](api.md#optionslines), [`stripFinalNewline`](api.md#optionsstripfinalnewline), [`buffer`](api.md#optionsbuffer), [`maxBuffer`](api.md#optionsmaxbuffer). By default, those options apply to all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) ([`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)), and [others](#additional-file-descriptors)) and [IPC messages](ipc.md). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), [`ipc`](ipc.md), [`fd3`](#additional-file-descriptors), etc.\n\n```js\n// Same value for stdout and stderr\nawait execa({verbose: 'full'})`npm run build`;\n\n// Different values for stdout and stderr\nawait execa({verbose: {stdout: 'none', stderr: 'full'}})`npm run build`;\n```\n\n## Additional file descriptors\n\nThe [`stdio`](api.md#optionsstdio) option is an array combining [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) and any other file descriptor. It is useful when using additional [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) beyond the [standard ones](https://en.wikipedia.org/wiki/Standard_streams), either for [input](input.md#additional-file-descriptors) or output.\n\n[`result.stdio`](api.md#resultstdio) can be used to retrieve some output from any file descriptor, as opposed to only [`stdout`](api.md#optionsstdout) and [`stderr`](api.md#optionsstderr).\n\n```js\n// Retrieve output from file descriptor number 3\nconst {stdio} = await execa({\n\tstdio: ['pipe', 'pipe', 'pipe', 'pipe'],\n})`npm run build`;\nconsole.log(stdio[3]);\n```\n\n## Shortcut\n\nThe [`stdio`](api.md#optionsstdio) option can also be a single value [`'pipe'`](#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore'`](#ignore-output) or [`'inherit'`](#terminal-output). This is a shortcut for setting that same value with the [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout) and [`stderr`](api.md#optionsstderr) options.\n\n```js\nawait execa({stdio: 'ignore'})`npm run build`;\n// Same as:\nawait execa({stdin: 'ignore', stdout: 'ignore', stderr: 'ignore'})`npm run build`;\n```\n\n## Big output\n\nTo prevent high memory consumption, a maximum output size can be set using the [`maxBuffer`](api.md#optionsmaxbuffer) option. It defaults to 100MB.\n\nWhen this threshold is hit, the subprocess fails and [`error.isMaxBuffer`](api.md#errorismaxbuffer) becomes `true`. The truncated output is still available using [`error.stdout`](api.md#resultstdout), [`error.stderr`](api.md#resultstderr) and [`error.ipcOutput`](api.md#resultipcoutput).\n\nThis is measured:\n- By default: in [characters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length).\n- If the [`encoding`](binary.md#encoding) option is `'buffer'`: in bytes.\n- If the [`lines`](lines.md#simple-splitting) option is `true`: in lines.\n- If a [transform in object mode](transform.md#object-mode) is used: in objects.\n- With [`error.ipcOutput`](ipc.md#retrieve-all-messages): in messages.\n\n```js\ntry {\n\tawait execa({maxBuffer: 1_000_000})`npm run build`;\n} catch (error) {\n\tif (error.isMaxBuffer) {\n\t\tconsole.error('Error: output larger than 1MB.');\n\t\tconsole.error(error.stdout);\n\t\tconsole.error(error.stderr);\n\t}\n\n\tthrow error;\n}\n```\n\n## Low memory\n\nWhen the [`buffer`](api.md#optionsbuffer) option is `false`, [`result.stdout`](api.md#resultstdout), [`result.stderr`](api.md#resultstderr), [`result.all`](api.md#resultall), [`result.stdio[*]`](api.md#resultstdio) and [`result.ipcOutput`](api.md#resultipcoutput) properties are empty.\n\nThis prevents high memory consumption when the output is big. However, the output must be either ignored, [redirected](#file-output), [streamed](streams.md) or [listened to](ipc.md#listening-to-messages). If streamed, this should be done right away to avoid missing any data.\n\n<hr>\n\n[**Next**: 📃 Text lines](lines.md)\\\n[**Previous**: 🎹 Input](input.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/pipe.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🔀 Piping multiple subprocesses\n\n## Array syntax\n\nA subprocess' [output](output.md) can be [piped](https://en.wikipedia.org/wiki/Pipeline_(Unix)) to another subprocess' [input](input.md). The syntax is the same as [`execa(file, arguments?, options?)`](execution.md#array-syntax).\n\n```js\nimport {execa} from 'execa';\n\n// Similar to `npm run build | head -n 2` in shells\nconst {stdout} = await execa('npm', ['run', 'build'])\n\t.pipe('head', ['-n', '2']);\n```\n\n## Template string syntax\n\n```js\nconst {stdout} = await execa`npm run build`\n\t.pipe`head -n 2`;\n```\n\n## Advanced syntax\n\n```js\nconst subprocess = execa`head -n 2`;\nconst {stdout} = await execa`npm run build`\n\t.pipe(subprocess);\n```\n\n## Options\n\n[Options](api.md#options-1) can be passed to either the source or the destination subprocess. Some [pipe-specific options](api.md#pipeoptions) can also be set by the destination subprocess.\n\n```js\nconst {stdout} = await execa('npm', ['run', 'build'], subprocessOptions)\n\t.pipe('head', ['-n', '2'], subprocessOrPipeOptions);\n```\n\n```js\nconst {stdout} = await execa(subprocessOptions)`npm run build`\n\t.pipe(subprocessOrPipeOptions)`head -n 2`;\n```\n\n```js\nconst subprocess = execa(subprocessOptions)`head -n 2`;\nconst {stdout} = await execa(subprocessOptions)`npm run build`\n\t.pipe(subprocess, pipeOptions);\n```\n\n## Result\n\nWhen both subprocesses succeed, the [`result`](api.md#result) of the destination subprocess is returned. The [`result`](api.md#result) of the source subprocess is available in a [`result.pipedFrom`](api.md#resultpipedfrom) array.\n\n```js\nconst destinationResult = await execa`npm run build`\n\t.pipe`head -n 2`;\nconsole.log(destinationResult.stdout); // First 2 lines of `npm run build`\n\nconst sourceResult = destinationResult.pipedFrom[0];\nconsole.log(sourceResult.stdout); // Full output of `npm run build`\n```\n\n## Errors\n\nWhen either subprocess fails, `subprocess.pipe()` is rejected with that subprocess' error. If the destination subprocess fails, [`error.pipedFrom`](api.md#resultpipedfrom) includes the source subprocess' result, which is useful for debugging.\n\n```js\ntry {\n\tawait execa`npm run build`\n\t\t.pipe`head -n 2`;\n} catch (error) {\n\tif (error.pipedFrom.length === 0) {\n\t\t// `npm run build` failure\n\t\tconsole.error(error);\n\t} else {\n\t\t// `head -n 2` failure\n\t\tconsole.error(error);\n\t\t// `npm run build` output\n\t\tconsole.error(error.pipedFrom[0].stdout);\n\t}\n\n\tthrow error;\n}\n```\n\n## Series of subprocesses\n\n```js\nawait execa`npm run build`\n\t.pipe`sort`\n\t.pipe`head -n 2`;\n```\n\n## 1 source, multiple destinations\n\n```js\nconst subprocess = execa`npm run build`;\nconst [sortedResult, truncatedResult] = await Promise.all([\n\tsubprocess.pipe`sort`,\n\tsubprocess.pipe`head -n 2`,\n]);\n```\n\n## Multiple sources, 1 destination\n\n```js\nconst destination = execa`./log-remotely.js`;\nawait Promise.all([\n\texeca`npm run build`.pipe(destination),\n\texeca`npm run test`.pipe(destination),\n]);\n```\n\n## Source file descriptor\n\nBy default, the source's [`stdout`](api.md#subprocessstdout) is used, but this can be changed using the [`from`](api.md#pipeoptionsfrom) piping option.\n\n```js\nawait execa`npm run build`\n\t.pipe({from: 'stderr'})`head -n 2`;\n```\n\n## Destination file descriptor\n\nBy default, the destination's [`stdin`](api.md#subprocessstdin) is used, but this can be changed using the [`to`](api.md#pipeoptionsto) piping option.\n\n```js\nawait execa`npm run build`\n\t.pipe({to: 'fd3'})`./log-remotely.js`;\n```\n\n## Unpipe\n\nPiping can be stopped using the [`unpipeSignal`](api.md#pipeoptionsunpipesignal) piping option.\n\nThe [`subprocess.pipe()`](api.md#subprocesspipefile-arguments-options) method will be rejected with a cancelation error. However, each subprocess will keep running.\n\n```js\nconst abortController = new AbortController();\n\nprocess.on('SIGUSR1', () => {\n\tabortController.abort();\n});\n\n// If the process receives SIGUSR1, `npm run build` stopped being logged remotely.\n// However, it keeps running successfully.\ntry {\n\tawait execa`npm run build`\n\t\t.pipe({unpipeSignal: abortController.signal})`./log-remotely.js`;\n} catch (error) {\n\tif (!abortController.signal.aborted) {\n\t\tthrow error;\n\t}\n}\n```\n\n<hr>\n\n[**Next**: ⏳️ Streams](streams.md)\\\n[**Previous**: 🧙 Transforms](transform.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/scripts.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 📜 Scripts\n\n## Script files\n\n[Scripts](https://en.wikipedia.org/wiki/Shell_script) are Node.js files executing a series of commands. While those used to be written with a shell language like [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)), libraries like Execa provide with a better, modern experience.\n\nScripts use [`$`](api.md#file-arguments-options) instead of [`execa`](api.md#execafile-arguments-options). The only difference is that `$` includes script-friendly default options: [`stdin: 'inherit'`](input.md#terminal-input) and [`preferLocal: true`](environment.md#local-binaries).\n\n[More info about the difference between Execa, Bash and zx.](bash.md)\n\n```js\nimport {$} from 'execa';\n\nconst {stdout: name} = await $`cat package.json`.pipe`grep name`;\nconsole.log(name);\n\nconst branch = await $`git branch --show-current`;\nawait $`dep deploy --branch=${branch}`;\n\nawait Promise.all([\n\t$`sleep 1`,\n\t$`sleep 2`,\n\t$`sleep 3`,\n]);\n\nconst directoryName = 'foo bar';\nawait $`mkdir /tmp/${directoryName}`;\n```\n\n## Template string syntax\n\nJust like [`execa`](api.md#execacommand), [`$`](api.md#command) can use either the [template string syntax](execution.md#template-string-syntax) or the [array syntax](execution.md#array-syntax).\n\nConversely, the template string syntax can be used outside of script files: `$` is not required to use that syntax. For example, `execa` [can use it too](execution.md#template-string-syntax).\n\n```js\nimport {execa, $} from 'execa';\n\nconst branch = await execa`git branch --show-current`;\nawait $('dep', ['deploy', `--branch=${branch}`]);\n```\n\n<hr>\n\n[**Next**: 🐢 Node.js files](node.md)\\\n[**Previous**: 💻 Shell](shell.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/shell.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 💻 Shell\n\n## Avoiding shells\n\nIn general, [shells](https://en.wikipedia.org/wiki/Shell_(computing)) should be avoided because they are:\n- Not cross-platform, encouraging shell-specific syntax.\n- Slower, because of the additional shell interpretation.\n- Unsafe, potentially allowing [command injection](https://en.wikipedia.org/wiki/Code_injection#Shell_injection) (see the [escaping section](escaping.md#shells)).\n\nIn almost all cases, plain JavaScript is a better alternative to shells. The [following page](bash.md) shows how to convert Bash into JavaScript.\n\n## Specific shell\n\n```js\nimport {execa} from 'execa';\n\nawait execa({shell: '/bin/bash'})`npm run \"$TASK\" && npm run test`;\n```\n\n## OS-specific shell\n\nWhen the [`shell`](api.md#optionsshell) option is `true`, `sh` is used on Unix and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) is used on Windows.\n\n`sh` and `cmd.exe` syntaxes are very different. Therefore, this is usually not useful.\n\n```js\nawait execa({shell: true})`npm run build`;\n```\n\n<hr>\n\n[**Next**: 📜 Scripts](scripts.md)\\\n[**Previous**: 💬 Escaping/quoting](escaping.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/small.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🐭 Small packages\n\n## `nano-spawn`\n\nExeca aims to be the best way to run commands on Node.js. It is [very widely used](https://github.com/sindresorhus/execa/network/dependents), [battle-tested](https://github.com/sindresorhus/execa/graphs/contributors) and has a bunch of [features](../readme.md#features).\n\nHowever, this means it has a relatively big package size: [![Install size](https://packagephobia.com/badge?p=execa)](https://packagephobia.com/result?p=execa). This should not be a problem in a server-side context, such as a script, a server, or an app. But you might be in an environment requiring small packages, such as a library or a serverless function.\n\nIf so, you can use [nano-spawn](https://github.com/sindresorhus/nano-spawn). It is similar, is maintained by the [same people](https://github.com/sindresorhus/nano-spawn#maintainers), has no dependencies, and a smaller package size: ![npm package minzipped size](https://img.shields.io/bundlejs/size/nano-spawn) [![Install size](https://packagephobia.com/badge?p=nano-spawn)](https://packagephobia.com/result?p=nano-spawn).\n\nOn the other hand, please note `nano-spawn` lacks many features from Execa: [scripts](scripts.md), [template string syntax](execution.md#template-string-syntax), [synchronous execution](execution.md#synchronous-execution), [file input/output](output.md#file-output), [binary input/output](binary.md), [advanced piping](pipe.md), [verbose mode](debugging.md#verbose-mode), [graceful](termination.md#graceful-termination) or [forceful termination](termination.md#forceful-termination), [IPC](ipc.md), [shebangs on Windows](windows.md), [and much more](https://github.com/sindresorhus/nano-spawn/issues/14).\n\n```js\nimport spawn from 'nano-spawn';\n\nconst result = await spawn('npm', ['run', 'build']);\n```\n\n### `node:child_process`\n\nBoth Execa and nano-spawn are built on top of the [`node:child_process`](https://nodejs.org/api/child_process.html) core module.\n\nIf you'd prefer avoiding adding any dependency, you may use `node:child_process` directly. However, you might miss some basic [features](https://github.com/sindresorhus/nano-spawn#features) that both Execa and nano-spawn provide: [proper error handling](https://github.com/sindresorhus/nano-spawn#subprocesserror), [full Windows support](https://github.com/sindresorhus/nano-spawn#windows-support), [local binaries](https://github.com/sindresorhus/nano-spawn#optionspreferlocal), [piping](https://github.com/sindresorhus/nano-spawn#subprocesspipefile-arguments-options), [lines iteration](https://github.com/sindresorhus/nano-spawn#subprocesssymbolasynciterator), [interleaved output](https://github.com/sindresorhus/nano-spawn#resultoutput), [and more](https://github.com/sindresorhus/nano-spawn#features).\n\n```js\nimport {execFile} from 'node:child_process';\nimport {promisify} from 'node:util';\n\nconst pExecFile = promisify(execFile);\n\nconst result = await pExecFile('npm', ['run', 'build']);\n```\n\n<hr>\n\n[**Next**: 🤓 TypeScript](typescript.md)\\\n[**Previous**: 🔍 Differences with Bash and zx](bash.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/streams.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# ⏳️ Streams\n\n## Node.js streams\n\n### Input\n\n```js\nimport {createReadStream} from 'node:fs';\nimport {once} from 'node:events';\nimport {execa} from 'execa';\n\nconst readable = createReadStream('input.txt');\nawait once(readable, 'open');\nawait execa({stdin: readable})`npm run scaffold`;\n```\n\n### Output\n\n```js\nimport {createWriteStream} from 'node:fs';\nimport {once} from 'node:events';\nimport {execa} from 'execa';\n\nconst writable = createWriteStream('output.txt');\nawait once(writable, 'open');\nawait execa({stdout: writable})`npm run build`;\n```\n\n### File descriptors\n\nWhen passing a Node.js stream to the [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout) or [`stderr`](api.md#optionsstderr) option, that stream must have an underlying file or socket, such as the streams created by the [`fs`](https://nodejs.org/api/fs.html#filehandlecreatereadstreamoptions), [`net`](https://nodejs.org/api/net.html#new-netsocketoptions) or [`http`](https://nodejs.org/api/http.html#class-httpincomingmessage) core modules. Otherwise the following error is thrown.\n\n```\nTypeError [ERR_INVALID_ARG_VALUE]: The argument 'stdio' is invalid.\n```\n\nThis limitation can be worked around by either:\n- Using the [`input`](api.md#optionsinput) option instead of the [`stdin`](api.md#optionsstdin) option.\n- Passing a [web stream](#web-streams).\n- Passing [`[nodeStream, 'pipe']`](output.md#multiple-targets) instead of `nodeStream`.\n\n## Web streams\n\n[Web streams](https://nodejs.org/api/webstreams.html) ([`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) or [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream)) can be used instead of [Node.js streams](https://nodejs.org/api/stream.html).\n\n```js\nconst response = await fetch('https://example.com');\nawait execa({stdin: response.body})`npm run build`;\n```\n\n## Iterables as input\n\n```js\nconst getReplInput = async function * () {\n\tfor await (const replLine of getReplLines()) {\n\t\tyield replLine;\n\t}\n};\n\nawait execa({stdin: getReplInput()})`npm run scaffold`;\n```\n\n## Manual streaming\n\n[`subprocess.stdin`](api.md#subprocessstdin) is a Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) stream and [`subprocess.stdout`](api.md#subprocessstdout)/[`subprocess.stderr`](api.md#subprocessstderr)/[`subprocess.all`](api.md#subprocessall) are Node.js [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) streams.\n\nThey can be used to stream input/output manually. This is intended for advanced situations. In most cases, the following simpler solutions can be used instead:\n- [`result.stdout`](output.md#stdout-and-stderr), [`result.stderr`](output.md#stdout-and-stderr) or [`result.stdio`](output.md#additional-file-descriptors).\n- The [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) or [`stdio`](api.md#optionsstdio) options.\n- [`subprocess.iterable()`](lines.md#progressive-splitting).\n- [`subprocess.pipe()`](pipe.md).\n\n## Converting a subprocess to a stream\n\n### Convert\n\nThe [`subprocess.readable()`](api.md#subprocessreadablereadableoptions), [`subprocess.writable()`](api.md#subprocesswritablewritableoptions) and [`subprocess.duplex()`](api.md#subprocessduplexduplexoptions) methods convert the subprocess to a Node.js [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable), [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) and [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) stream.\n\nThis is useful when using a library or API that expects Node.js streams as arguments. In every other situation, the simpler solutions described [above](#manual-streaming) can be used instead.\n\n```js\nconst readable = execa`npm run scaffold`.readable();\n\nconst writable = execa`npm run scaffold`.writable();\n\nconst duplex = execa`npm run scaffold`.duplex();\n```\n\n### Different file descriptor\n\nBy default, [`subprocess.readable()`](api.md#subprocessreadablereadableoptions), [`subprocess.writable()`](api.md#subprocesswritablewritableoptions) and [`subprocess.duplex()`](api.md#subprocessduplexduplexoptions) methods use [`stdin`](api.md#subprocessstdin) and [`stdout`](api.md#subprocessstdout). This can be changed using the [`from`](api.md#readableoptionsfrom) and [`to`](api.md#writableoptionsto) options.\n\n```js\nconst readable = execa`npm run scaffold`.readable({from: 'stderr'});\n\nconst writable = execa`npm run scaffold`.writable({to: 'fd3'});\n\nconst duplex = execa`npm run scaffold`.duplex({from: 'stderr', to: 'fd3'});\n```\n\n### Error handling\n\nWhen using [`subprocess.readable()`](api.md#subprocessreadablereadableoptions), [`subprocess.writable()`](api.md#subprocesswritablewritableoptions) or [`subprocess.duplex()`](api.md#subprocessduplexduplexoptions), the stream waits for the subprocess to end, and emits an [`error`](https://nodejs.org/api/stream.html#event-error) event if the subprocess [fails](errors.md). This differs from [`subprocess.stdin`](api.md#subprocessstdin), [`subprocess.stdout`](api.md#subprocessstdout) and [`subprocess.stderr`](api.md#subprocessstderr)'s behavior.\n\nThis means you do not need to `await` the subprocess' [promise](execution.md#result). On the other hand, you (or the library using the stream) do need to both consume the stream, and handle its `error` event. This can be done by using [`await finished(stream)`](https://nodejs.org/api/stream.html#streamfinishedstream-options), [`await pipeline(..., stream, ...)`](https://nodejs.org/api/stream.html#streampipelinesource-transforms-destination-options) or [`await text(stream)`](https://nodejs.org/api/webstreams.html#streamconsumerstextstream) which throw an exception when the stream errors.\n\n<hr>\n\n[**Next**: 📞 Inter-process communication](ipc.md)\\\n[**Previous**: 🔀 Piping multiple subprocesses](pipe.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/termination.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🏁 Termination\n\n## Alternatives\n\nTerminating a subprocess ends it abruptly. This prevents rolling back the subprocess' operations and leaves them incomplete.\n\nIdeally subprocesses should end on their own. If that's not possible, [graceful termination](#graceful-termination) should be preferred.\n\n## Canceling\n\nThe [`cancelSignal`](api.md#optionscancelsignal) option can be used to cancel a subprocess. When it is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), a [`SIGTERM` signal](#default-signal) is sent to the subprocess.\n\n```js\nimport {execaNode} from 'execa';\n\nconst controller = new AbortController();\nconst cancelSignal = controller.signal;\n\nsetTimeout(() => {\n\tcontroller.abort();\n}, 5000);\n\ntry {\n\tawait execaNode({cancelSignal})`build.js`;\n} catch (error) {\n\tif (error.isCanceled) {\n\t\tconsole.error('Canceled by cancelSignal.');\n\t}\n\n\tthrow error;\n}\n```\n\n## Graceful termination\n\n### Share a `cancelSignal`\n\nWhen the [`gracefulCancel`](api.md#optionsgracefulcancel) option is `true`, the [`cancelSignal`](api.md#optionscancelsignal) option does not send any [`SIGTERM`](#sigterm). Instead, the subprocess calls [`getCancelSignal()`](api.md#getcancelsignal) to retrieve and handle the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). This allows the subprocess to properly clean up and abort operations.\n\nThis option only works with Node.js files.\n\nThis is cross-platform. If you do not need to support Windows, [signal handlers](#handling-signals) can also be used.\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst controller = new AbortController();\nconst cancelSignal = controller.signal;\n\nsetTimeout(() => {\n\tcontroller.abort();\n}, 5000);\n\ntry {\n\tawait execaNode({cancelSignal, gracefulCancel: true})`build.js`;\n} catch (error) {\n\tif (error.isGracefullyCanceled) {\n\t\tconsole.error('Cancelled gracefully.');\n\t}\n\n\tthrow error;\n}\n```\n\n```js\n// build.js\nimport {getCancelSignal} from 'execa';\n\nconst cancelSignal = await getCancelSignal();\n```\n\n### Abort operations\n\nThe [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) returned by [`getCancelSignal()`](api.md#getcancelsignal) can be passed to most long-running Node.js methods: [`setTimeout()`](https://nodejs.org/api/timers.html#timerspromisessettimeoutdelay-value-options), [`setInterval()`](https://nodejs.org/api/timers.html#timerspromisessetintervaldelay-value-options), [events](https://nodejs.org/api/events.html#eventsonemitter-eventname-options), [streams](https://nodejs.org/api/stream.html#new-streamreadableoptions), [REPL](https://nodejs.org/api/readline.html#rlquestionquery-options), HTTP/TCP [requests](https://nodejs.org/api/http.html#httprequesturl-options-callback) or [servers](https://nodejs.org/api/net.html#serverlistenoptions-callback), [reading](https://nodejs.org/api/fs.html#fspromisesreadfilepath-options) / [writing](https://nodejs.org/api/fs.html#fspromiseswritefilefile-data-options) / [watching](https://nodejs.org/api/fs.html#fspromiseswatchfilename-options) files, or spawning another subprocess.\n\nWhen aborted, those methods throw the `Error` instance which was passed to [`abortController.abort(error)`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort). Since those methods keep the subprocess alive, aborting them makes the subprocess end on its own.\n\n```js\nimport {getCancelSignal} from 'execa';\nimport {watch} from 'node:fs/promises';\n\nconst cancelSignal = await getCancelSignal();\n\ntry {\n\tfor await (const fileChange of watch('./src', {signal: cancelSignal})) {\n\t\tonFileChange(fileChange);\n\t}\n} catch (error) {\n\tif (error.isGracefullyCanceled) {\n\t\tconsole.log(error.cause === cancelSignal.reason); // true\n\t}\n}\n```\n\n### Cleanup logic\n\nFor other kinds of operations, the [`abort`](https://nodejs.org/api/globals.html#event-abort) event should be listened to. Although [`cancelSignal.addEventListener('abort')`](https://nodejs.org/api/events.html#eventtargetaddeventlistenertype-listener-options) can be used, [`events.addAbortListener(cancelSignal)`](https://nodejs.org/api/events.html#eventsaddabortlistenersignal-listener) is preferred since it works even if the `cancelSignal` is already aborted.\n\n### Graceful exit\n\nWe recommend explicitly [stopping](#abort-operations) each pending operation when the subprocess is aborted. This allows it to end on its own.\n\n```js\nimport {getCancelSignal} from 'execa';\nimport {addAbortListener} from 'node:events';\n\nconst cancelSignal = await getCancelSignal();\naddAbortListener(cancelSignal, async () => {\n\tawait cleanup();\n\tprocess.exitCode = 1;\n});\n```\n\nHowever, if any operation is still ongoing, the subprocess will keep running. It can be forcefully ended using [`process.exit(exitCode)`](https://nodejs.org/api/process.html#processexitcode) instead of [`process.exitCode`](https://nodejs.org/api/process.html#processexitcode_1).\n\nIf the subprocess is still alive after 5 seconds, it is forcefully terminated with [`SIGKILL`](#sigkill). This can be [configured or disabled](#forceful-termination) using the [`forceKillAfterDelay`](api.md#optionsforcekillafterdelay) option.\n\n## Timeout\n\n### Execution timeout\n\nIf the subprocess lasts longer than the [`timeout`](api.md#optionstimeout) option, a [`SIGTERM` signal](#default-signal) is sent to it.\n\n```js\ntry {\n\tawait execa({timeout: 5000})`npm run build`;\n} catch (error) {\n\tif (error.timedOut) {\n\t\tconsole.error('Timed out.');\n\t}\n\n\tthrow error;\n}\n```\n\n### Inactivity timeout\n\nTo terminate a subprocess when it becomes inactive, the [`cancelSignal`](#canceling) option can be combined with [transforms](transform.md) and some [debouncing logic](https://github.com/sindresorhus/debounce-fn). The following example terminates the subprocess if it has not printed to [`stdout`](api.md#resultstdout)/[`stderr`](api.md#resultstderr) in the last minute.\n\n```js\nimport {execa} from 'execa';\nimport debounceFn from 'debounce-fn';\n\n// 1 minute\nconst wait = 60_000;\n\nconst getInactivityOptions = () => {\n\tconst controller = new AbortController();\n\tconst cancelSignal = controller.signal;\n\n\t// Delay and debounce `cancelSignal` each time `controller.abort()` is called\n\tconst scheduleAbort = debounceFn(controller.abort.bind(controller), {wait});\n\n\tconst onOutput = {\n\t\t* transform(data) {\n\t\t\t// When anything is printed, debounce `controller.abort()`\n\t\t\tscheduleAbort();\n\n\t\t\t// Keep the output as is\n\t\t\tyield data;\n\t\t},\n\t\t// Debounce even if the output does not include any newline\n\t\tbinary: true,\n\t};\n\n\t// Start debouncing\n\tscheduleAbort();\n\n\treturn {\n\t\tcancelSignal,\n\t\tstdout: onOutput,\n\t\tstderr: onOutput,\n\t};\n};\n\nconst options = getInactivityOptions();\n\nawait execa(options)`npm run build`;\n```\n\n## Current process exit\n\nIf the current process exits, the subprocess is automatically [terminated](#default-signal) unless either:\n- The [`cleanup`](api.md#optionscleanup) option is `false`.\n- The subprocess is run in the background using the [`detached`](api.md#optionsdetached) option.\n- The current process was terminated abruptly, for example, with [`SIGKILL`](#sigkill) as opposed to [`SIGTERM`](#sigterm) or a successful exit.\n\n## Signal termination\n\n[`subprocess.kill()`](api.md#subprocesskillsignal-error) sends a [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) to the subprocess. This is an inter-process message handled by the OS. Most (but [not all](https://github.com/ehmicky/human-signals#action)) signals terminate the subprocess.\n\n[More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)\n\n### SIGTERM\n\n[`SIGTERM`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGTERM) is the default signal. It terminates the subprocess. On Unix, it can [be handled](#handling-signals) to run some cleanup logic.\n\n```js\nconst subprocess = execa`npm run build`;\nsubprocess.kill();\n// Is the same as:\nsubprocess.kill('SIGTERM');\n```\n\n### SIGINT\n\n[`SIGINT`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGINT) terminates the process. Its [handler](#handling-signals) is triggered on `CTRL-C`.\n\n```js\nsubprocess.kill('SIGINT');\n```\n\n### SIGKILL\n\n[`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL) forcefully terminates the subprocess. It [cannot be handled](#handling-signals).\n\n```js\nsubprocess.kill('SIGKILL');\n```\n\n### SIGQUIT\n\n[`SIGQUIT`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGQUIT) terminates the process. On Unix, it creates a [core dump](https://en.wikipedia.org/wiki/Core_dump).\n\n```js\nsubprocess.kill('SIGQUIT');\n```\n\n### Other signals\n\nOther signals can be passed as argument. However, most other signals do not fully [work on Windows](https://github.com/ehmicky/cross-platform-node-guide/blob/main/docs/6_networking_ipc/signals.md#cross-platform-signals).\n\n### Default signal\n\nThe [`killSignal`](api.md#optionskillsignal) option sets the default signal used by [`subprocess.kill()`](api.md#subprocesskillsignal-error) and the following options: [`cancelSignal`](#canceling), [`timeout`](#timeout), [`maxBuffer`](output.md#big-output) and [`cleanup`](#current-process-exit). It is [`SIGTERM`](#sigterm) by default.\n\n```js\nconst subprocess = execa({killSignal: 'SIGKILL'})`npm run build`;\nsubprocess.kill(); // Forceful termination\n```\n\n### Handling signals\n\nOn Unix, most signals (not [`SIGKILL`](#sigkill)) can be intercepted to perform a graceful exit.\n\n```js\nprocess.on('SIGTERM', () => {\n\tcleanup();\n\tprocess.exit(1);\n})\n```\n\nUnfortunately this [usually does not work](https://github.com/ehmicky/cross-platform-node-guide/blob/main/docs/6_networking_ipc/signals.md#cross-platform-signals) on Windows. The only signal that is somewhat cross-platform is [`SIGINT`](#sigint): on Windows, its handler is triggered when the user types `CTRL-C` in the terminal. However `subprocess.kill('SIGINT')` is only handled on Unix.\n\nExeca provides the [`gracefulCancel`](#graceful-termination) option as a cross-platform alternative to signal handlers.\n\n### Signal name and description\n\nWhen a subprocess was terminated by a signal, [`error.isTerminated`](api.md#erroristerminated) is `true`.\n\nAlso, [`error.signal`](api.md#errorsignal) and [`error.signalDescription`](api.md#errorsignaldescription) indicate the signal's name and [human-friendly description](https://github.com/ehmicky/human-signals). On Windows, those are only set if the current process terminated the subprocess, as opposed to [another process](#inter-process-termination).\n\n```js\ntry {\n\tawait execa`npm run build`;\n} catch (error) {\n\tif (error.isTerminated) {\n\t\tconsole.error(error.signal); // SIGFPE\n\t\tconsole.error(error.signalDescription); // 'Floating point arithmetic error'\n\t}\n\n\tthrow error;\n}\n```\n\n## Forceful termination\n\nIf the subprocess is terminated but does not exit, [`SIGKILL`](#sigkill) is automatically sent to forcefully terminate it.\n\nThe grace period is set by the [`forceKillAfterDelay`](api.md#optionsforcekillafterdelay) option, which is 5 seconds by default. This feature can be disabled with `false`.\n\nThe [`error.isForcefullyTerminated`](api.md#errorisforcefullyterminated) boolean property can be used to check whether a subprocess was forcefully terminated by the `forceKillAfterDelay` option.\n\nThis works when the subprocess is terminated by either:\n- Calling [`subprocess.kill()`](api.md#subprocesskillsignal-error) with no arguments.\n- The [`cancelSignal`](#canceling), [`timeout`](#timeout), [`maxBuffer`](output.md#big-output) or [`cleanup`](#current-process-exit) option.\n\nThis does not work when the subprocess is terminated by either:\n- Calling [`subprocess.kill()`](api.md#subprocesskillsignal-error) with a specific signal.\n- Calling [`process.kill(subprocess.pid)`](api.md#subprocesspid).\n- Sending a termination signal [from another process](#inter-process-termination).\n\nAlso, this does not work on Windows, because Windows [doesn't support signals](https://nodejs.org/api/process.html#process_signal_events): `SIGKILL` and `SIGTERM` both terminate the subprocess immediately. Other packages (such as [`taskkill`](https://github.com/sindresorhus/taskkill)) can be used to achieve fail-safe termination on Windows.\n\n```js\n// No forceful termination\nconst subprocess = execa({forceKillAfterDelay: false})`npm run build`;\nsubprocess.kill();\n```\n\n## Inter-process termination\n\n[`subprocess.kill()`](api.md#subprocesskillsignal-error) only works when the current process terminates the subprocess. To terminate the subprocess from a different process, its [`subprocess.pid`](api.md#subprocesspid) can be used instead.\n\n```js\nconst subprocess = execa`npm run build`;\nconsole.log('PID:', subprocess.pid); // PID: 6513\nawait subprocess;\n```\n\nFor example, from a terminal:\n\n```sh\n$ kill -SIGTERM 6513\n```\n\nOr from a different Node.js process:\n\n```js\nimport process from 'node:process';\n\nprocess.kill(subprocessPid);\n```\n\n## Error message and stack trace\n\nWhen terminating a subprocess, it is possible to include an error message and stack trace by using [`subprocess.kill(error)`](api.md#subprocesskillerror). The `error` argument will be available at [`error.cause`](api.md#errorcause).\n\n```js\ntry {\n\tconst subprocess = execa`npm run build`;\n\tsetTimeout(() => {\n\t\tsubprocess.kill(new Error('Timed out after 5 seconds.'));\n\t}, 5000);\n\tawait subprocess;\n} catch (error) {\n\tif (error.isTerminated) {\n\t\tconsole.error(error.cause); // new Error('Timed out after 5 seconds.')\n\t\tconsole.error(error.cause.stack); // Stack trace from `error.cause`\n\t\tconsole.error(error.originalMessage); // 'Timed out after 5 seconds.'\n\t}\n\n\tthrow error;\n}\n```\n\n<hr>\n\n[**Next**: 🎹 Input](input.md)\\\n[**Previous**: ❌ Errors](errors.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/transform.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🧙 Transforms\n\n## Summary\n\nTransforms map or filter the input or output of a subprocess. They are defined by passing a [generator function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) or a [transform options object](api.md#transform-options) to the [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) or [`stdio`](api.md#optionsstdio) option. It can be [`async`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function*).\n\n```js\nimport {execa} from 'execa';\n\nconst transform = function * (line) {\n\tconst prefix = line.includes('error') ? 'ERROR' : 'INFO';\n\tyield `${prefix}: ${line}`;\n};\n\nconst {stdout} = await execa({stdout: transform})`echo HELLO`;\nconsole.log(stdout); // INFO: HELLO\n```\n\n## Difference with iteration\n\nTransforms operate one `line` at a time, just like [`subprocess.iterable()`](lines.md#progressive-splitting). However, unlike iteration, transforms:\n- Modify the subprocess' [output](api.md#resultstdout) and [streams](api.md#subprocessstdout).\n- Can apply to the subprocess' input.\n- Are defined using a [generator function](#summary), [`Duplex`](#duplextransform-streams) stream, Node.js [`Transform`](#duplextransform-streams) stream or web [`TransformStream`](#duplextransform-streams).\n\n## Filtering\n\n`yield` can be called 0, 1 or multiple times. Not calling `yield` enables filtering a specific line.\n\n```js\nconst transform = function * (line) {\n\tif (!line.includes('secret')) {\n\t\tyield line;\n\t}\n};\n\nconst {stdout} = await execa({stdout: transform})`echo ${'This is a secret'}`;\nconsole.log(stdout); // ''\n```\n\n## Object mode\n\nBy default, [`stdout`](api.md#optionsstdout) and [`stderr`](api.md#optionsstderr)'s transforms must return a string or an `Uint8Array`. However, if the [`objectMode`](api.md#transformoptionsobjectmode) transform option is `true`, any type can be returned instead, except `null` or `undefined`. The subprocess' [`result.stdout`](api.md#resultstdout)/[`result.stderr`](api.md#resultstderr) will be an array of values.\n\n```js\nconst transform = function * (line) {\n\tyield JSON.parse(line);\n};\n\nconst {stdout} = await execa({stdout: {transform, objectMode: true}})`node jsonlines-output.js`;\nfor (const data of stdout) {\n\tconsole.log(stdout); // {...object}\n}\n```\n\n[`stdin`](api.md#optionsstdin) can also use `objectMode: true`.\n\n```js\nconst transform = function * (line) {\n\tyield JSON.stringify(line);\n};\n\nconst input = [{event: 'example'}, {event: 'otherExample'}];\nawait execa({stdin: [input, {transform, objectMode: true}]})`node jsonlines-input.js`;\n```\n\n## Sharing state\n\nState can be shared between calls of the [`transform`](api.md#transformoptionstransform) and [`final`](api.md#transformoptionsfinal) functions.\n\n```js\nlet count = 0;\n\n// Prefix line number\nconst transform = function * (line) {\n\tyield `[${count++}] ${line}`;\n};\n```\n\n## Finalizing\n\nTo create additional lines after the last one, a [`final`](api.md#transformoptionsfinal) generator function can be used.\n\n```js\nlet count = 0;\n\nconst transform = function * (line) {\n\tcount += 1;\n\tyield line;\n};\n\nconst final = function * () {\n\tyield `Number of lines: ${count}`;\n};\n\nconst {stdout} = await execa({stdout: {transform, final}})`npm run build`;\nconsole.log(stdout); // Ends with: 'Number of lines: 54'\n```\n\n## Duplex/Transform streams\n\nA [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) stream, Node.js [`Transform`](https://nodejs.org/api/stream.html#class-streamtransform) stream or web [`TransformStream`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) can be used instead of a generator function.\n\nLike generator functions, web `TransformStream` can be passed either directly or as a [`{transform}` plain object](api.md#transform-options). But `Duplex` and `Transform` must always be passed as a `{transform}` plain object.\n\nThe [`objectMode`](#object-mode) transform option can be used, but not the [`binary`](api.md#transformoptionsbinary) nor [`preserveNewlines`](api.md#transformoptionspreservenewlines) options.\n\n```js\nimport {createGzip} from 'node:zlib';\nimport {execa} from 'execa';\n\nconst {stdout} = await execa({\n\tstdout: {transform: createGzip()},\n\tencoding: 'buffer',\n})`npm run build`;\nconsole.log(stdout); // `stdout` is compressed with gzip\n```\n\n```js\nconst {stdout} = await execa({\n\tstdout: new CompressionStream('gzip'),\n\tencoding: 'buffer',\n})`npm run build`;\nconsole.log(stdout); // `stdout` is compressed with gzip\n```\n\n## Combining\n\nThe [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr) and [`stdio`](api.md#optionsstdio) options can accept [an array of values](output.md#multiple-targets). While this is not specific to transforms, this can be useful with them too. For example, the following transform impacts the value printed by `'inherit'`.\n\n```js\nawait execa({stdout: [transform, 'inherit']})`npm run build`;\n```\n\nThis also allows using multiple transforms.\n\n```js\nawait execa({stdout: [transform, otherTransform]})`npm run build`;\n```\n\nOr saving to archives.\n\n```js\nawait execa({stdout: [new CompressionStream('gzip'), {file: './output.gz'}]})`npm run build`;\n```\n\n<hr>\n\n[**Next**: 🔀 Piping multiple subprocesses](pipe.md)\\\n[**Previous**: 🤖 Binary data](binary.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/typescript.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 🤓 TypeScript\n\n## Available types\n\nThe following types can be imported: [`ResultPromise`](api.md#return-value), [`Subprocess`](api.md#subprocess), [`Result`](api.md#result), [`ExecaError`](api.md#execaerror), [`Options`](api.md#options-1), [`StdinOption`](api.md#optionsstdin), [`StdoutStderrOption`](api.md#optionsstdout), [`TemplateExpression`](api.md#execacommand), [`Message`](api.md#subprocesssendmessagemessage-sendmessageoptions), [`VerboseObject`](api.md#verbose-object), [`ExecaMethod`](api.md#execaoptions), [`ExecaNodeMethod`](api.md#execanodeoptions) and [`ExecaScriptMethod`](api.md#options).\n\n```ts\nimport {\n\texeca as execa_,\n\tExecaError,\n\ttype ResultPromise,\n\ttype Result,\n\ttype Options,\n\ttype StdinOption,\n\ttype StdoutStderrOption,\n\ttype TemplateExpression,\n\ttype Message,\n\ttype VerboseObject,\n\ttype ExecaMethod,\n} from 'execa';\n\nconst execa: ExecaMethod = execa_({preferLocal: true});\n\nconst options: Options = {\n\tstdin: 'inherit' satisfies StdinOption,\n\tstdout: 'pipe' satisfies StdoutStderrOption,\n\tstderr: 'pipe' satisfies StdoutStderrOption,\n\ttimeout: 1000,\n\tipc: true,\n\tverbose(verboseLine: string, verboseObject: VerboseObject) {\n\t\treturn verboseObject.type === 'duration' ? verboseLine : undefined;\n\t},\n};\nconst task: TemplateExpression = 'build';\nconst message: Message = 'hello world';\n\ntry {\n\tconst subprocess: ResultPromise = execa(options)`npm run ${task}`;\n\tawait subprocess.sendMessage?.(message);\n\tconst result: Result = await subprocess;\n\tconsole.log(result.stdout);\n} catch (error) {\n\tif (error instanceof ExecaError) {\n\t\tconsole.error(error);\n\t}\n}\n```\n\n## Synchronous execution\n\nTheir [synchronous](#synchronous-execution) counterparts are [`SyncResult`](api.md#result), [`ExecaSyncError`](api.md#execasyncerror), [`SyncOptions`](api.md#options-1), [`StdinSyncOption`](api.md#optionsstdin), [`StdoutStderrSyncOption`](api.md#optionsstdout), [`TemplateExpression`](api.md#execacommand), [`SyncVerboseObject`](api.md#verbose-object), [`ExecaSyncMethod`](api.md#execasyncoptions) and [`ExecaScriptSyncMethod`](api.md#syncoptions).\n\n```ts\nimport {\n\texecaSync as execaSync_,\n\tExecaSyncError,\n\ttype SyncResult,\n\ttype SyncOptions,\n\ttype StdinSyncOption,\n\ttype StdoutStderrSyncOption,\n\ttype TemplateExpression,\n\ttype SyncVerboseObject,\n\ttype ExecaSyncMethod,\n} from 'execa';\n\nconst execaSync: ExecaSyncMethod = execaSync_({preferLocal: true});\n\nconst options: SyncOptions = {\n\tstdin: 'inherit' satisfies StdinSyncOption,\n\tstdout: 'pipe' satisfies StdoutStderrSyncOption,\n\tstderr: 'pipe' satisfies StdoutStderrSyncOption,\n\ttimeout: 1000,\n\tverbose(verboseLine: string, verboseObject: SyncVerboseObject) {\n\t\treturn verboseObject.type === 'duration' ? verboseLine : undefined;\n\t},\n};\nconst task: TemplateExpression = 'build';\n\ntry {\n\tconst result: SyncResult = execaSync(options)`npm run ${task}`;\n\tconsole.log(result.stdout);\n} catch (error) {\n\tif (error instanceof ExecaSyncError) {\n\t\tconsole.error(error);\n\t}\n}\n```\n\n## Type inference\n\nThe above examples demonstrate those types. However, types are automatically inferred. Therefore, explicit types are only needed when defining functions that take those values as parameters.\n\n```ts\nimport {\n\texeca as execa_,\n\tExecaError,\n\ttype Result,\n\ttype VerboseObject,\n} from 'execa';\n\nconst execa = execa_({preferLocal: true});\n\nconst printResultStdout = (result: Result) => {\n\tconsole.log('Stdout', result.stdout);\n};\n\nconst options = {\n\tstdin: 'inherit',\n\tstdout: 'pipe',\n\tstderr: 'pipe',\n\ttimeout: 1000,\n\tipc: true,\n\tverbose(verboseLine: string, verboseObject: VerboseObject) {\n\t\treturn verboseObject.type === 'duration' ? verboseLine : undefined;\n\t},\n} as const;\nconst task = 'build';\nconst message = 'hello world';\n\ntry {\n\tconst subprocess = execa(options)`npm run ${task}`;\n\tawait subprocess.sendMessage(message);\n\tconst result = await subprocess;\n\tprintResultStdout(result);\n} catch (error) {\n\tif (error instanceof ExecaError) {\n\t\tconsole.error(error);\n\t}\n}\n```\n\n## Troubleshooting\n\n### Supported version\n\nThe minimum supported TypeScript version is [`5.1.6`](https://github.com/microsoft/TypeScript/releases/tag/v5.1.6).\n\n### ES modules\n\nThis package uses pure ES modules. Therefore the TypeScript's `--module` compiler option must be set to [`nodenext`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext) or [`preserve`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#preserve). [More info.](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)\n\nOtherwise, transpilation will work, but running the transpiled file will throw the following runtime error:\n\n```\nError [ERR_REQUIRE_ESM]: require() of ES Module ... not supported.\n```\n\nOr:\n\n```\nReferenceError: exports is not defined in ES module scope\n```\n\n### Strict unions\n\nSeveral options are typed as unions of strings: [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout), [`stderr`](api.md#optionsstderr), [`encoding`](api.md#optionsencoding), [`serialization`](api.md#optionsserialization), [`verbose`](api.md#optionsverbose), [`killSignal`](api.md#optionskillsignal), [`from`](api.md#pipeoptionsfrom) and [`to`](api.md#pipeoptionsto). For example, the `serialization` option's type is `'advanced' | 'json'`, not `string`. Therefore the following example fails:\n\n```ts\nimport {execa} from 'execa';\n\n// Type error: \"No overload matches this call\"\nconst spawnSubprocess = (serialization: string) => execa({serialization})`npm run build`;\n\n// Without `as const`, `options.serialization` is typed as `string`, not `'json'`\nconst options = {serialization: 'json'};\n// Type error: \"No overload matches this call\"\nawait execa(options)`npm run build`;\n```\n\nBut this works:\n\n```ts\nimport {execa, type Options} from 'execa';\n\nconst spawnSubprocess = (serialization: Options['serialization']) => execa({serialization})`npm run build`;\n\nconst options = {serialization: 'json'} as const;\nawait execa(options)`npm run build`;\n```\n\n<hr>\n\n[**Next**: 📔 API reference](api.md)\\\n[**Previous**: 🐭 Small packages](small.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "docs/windows.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"../media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"../media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n# 📎 Windows\n\nAlthough each OS implements subprocesses very differently, Execa makes them cross-platform, except in a few instances.\n\n## Shebang\n\nOn Unix, executable files can use [shebangs](https://en.wikipedia.org/wiki/Shebang_(Unix)).\n\n```js\nimport {execa} from 'execa';\n\n// If script.js starts with #!/usr/bin/env node\nawait execa`./script.js`;\n\n// Then, the above is a shortcut for:\nawait execa`node ./script.js`;\n```\n\nAlthough Windows does not natively support shebangs, Execa adds support for them.\n\n## Signals\n\nOnly few [signals](termination.md#other-signals) work on Windows with Node.js: [`SIGTERM`](termination.md#sigterm), [`SIGKILL`](termination.md#sigkill), [`SIGINT`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGINT) and [`SIGQUIT`](termination.md#sigquit). Also, sending signals from other processes is [not supported](termination.md#signal-name-and-description). Finally, the [`forceKillAfterDelay`](api.md#optionsforcekillafterdelay) option [is a noop](termination.md#forceful-termination) on Windows.\n\n## Asynchronous I/O\n\nThe default value for the [`stdin`](api.md#optionsstdin), [`stdout`](api.md#optionsstdout) and [`stderr`](api.md#optionsstderr) options is [`'pipe'`](output.md#stdout-and-stderr). This returns the output as [`result.stdout`](api.md#resultstdout) and [`result.stderr`](api.md#resultstderr) and allows for [manual streaming](streams.md#manual-streaming).\n\nInstead of `'pipe'`, `'overlapped'` can be used instead to use [asynchronous I/O](https://learn.microsoft.com/en-us/windows/win32/fileio/synchronous-and-asynchronous-i-o) under-the-hood on Windows, instead of the default behavior which is synchronous. On other platforms, asynchronous I/O is always used, so `'overlapped'` behaves the same way as `'pipe'`.\n\n## Escaping\n\nWindows requires files and arguments to be quoted when they contain spaces, tabs, backslashes or double quotes. Unlike Unix, this is needed even when no [shell](shell.md) is used.\n\nWhen not using any shell, Execa performs that quoting automatically. This ensures files and arguments are split correctly.\n\n```js\nawait execa`npm run ${'task with space'}`;\n```\n\nWhen using a [shell](shell.md), the user must manually perform shell-specific quoting, on both Unix and Windows. When the [`shell`](api.md#optionsshell) option is `true`, [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) is used on Windows and `sh` on Unix. Unfortunately, both shells use different quoting rules. With `cmd.exe`, this mostly involves double quoting arguments and prepending double quotes with a backslash.\n\n```js\nif (isWindows) {\n\tawait execa({shell: true})`npm run ${'\"task with space\"'}`;\n} else {\n\tawait execa({shell: true})`npm run ${'\\'task with space\\''}`;\n}\n```\n\nWhen using other Windows shells (such as PowerShell or WSL), Execa performs `cmd.exe`-specific automatic quoting by default. This is a problem since Powershell uses different quoting rules. This can be disabled using the [`windowsVerbatimArguments: true`](api.md#optionswindowsverbatimarguments) option.\n\n```js\nif (isWindows) {\n\tawait execa({windowsVerbatimArguments: true})`wsl ...`;\n}\n```\n\n## Console window\n\nIf the [`windowsHide`](api.md#optionswindowshide) option is `false`, the subprocess is run in a new console window. This is necessary to make [`SIGINT` work](https://github.com/nodejs/node/issues/29837) on Windows, and to prevent subprocesses not being cleaned up in [some specific situations](https://github.com/sindresorhus/execa/issues/433).\n\n## UID and GID\n\nBy default, subprocesses are run using the current [user](https://en.wikipedia.org/wiki/User_identifier) and [group](https://en.wikipedia.org/wiki/Group_identifier). The [`uid`](api.md#optionsuid) and [`gid`](api.md#optionsgid) options can be used to set a different user or group.\n\nHowever, since Windows uses a different permission model, those options throw.\n\n<hr>\n\n[**Next**: 🔍 Differences with Bash and zx](bash.md)\\\n[**Previous**: 🐛 Debugging](debugging.md)\\\n[**Top**: Table of contents](../readme.md#documentation)\n"
  },
  {
    "path": "index.d.ts",
    "content": "export type {\n\tStdinOption,\n\tStdinSyncOption,\n\tStdoutStderrOption,\n\tStdoutStderrSyncOption,\n} from './types/stdio/type.js';\nexport type {Options, SyncOptions} from './types/arguments/options.js';\nexport type {TemplateExpression} from './types/methods/template.js';\n\nexport type {Result, SyncResult} from './types/return/result.js';\nexport type {ResultPromise, Subprocess} from './types/subprocess/subprocess.js';\nexport {ExecaError, ExecaSyncError} from './types/return/final-error.js';\n\nexport {execa, type ExecaMethod} from './types/methods/main-async.js';\nexport {execaSync, type ExecaSyncMethod} from './types/methods/main-sync.js';\nexport {execaCommand, execaCommandSync, parseCommandString} from './types/methods/command.js';\nexport {$, type ExecaScriptMethod, type ExecaScriptSyncMethod} from './types/methods/script.js';\nexport {execaNode, type ExecaNodeMethod} from './types/methods/node.js';\n\nexport {\n\tsendMessage,\n\tgetOneMessage,\n\tgetEachMessage,\n\tgetCancelSignal,\n\ttype Message,\n} from './types/ipc.js';\nexport type {VerboseObject, SyncVerboseObject} from './types/verbose.js';\n"
  },
  {
    "path": "index.js",
    "content": "import {createExeca} from './lib/methods/create.js';\nimport {mapCommandAsync, mapCommandSync} from './lib/methods/command.js';\nimport {mapNode} from './lib/methods/node.js';\nimport {mapScriptAsync, setScriptSync, deepScriptOptions} from './lib/methods/script.js';\nimport {getIpcExport} from './lib/ipc/methods.js';\n\nexport {parseCommandString} from './lib/methods/command.js';\nexport {ExecaError, ExecaSyncError} from './lib/return/final-error.js';\n\nexport const execa = createExeca(() => ({}));\nexport const execaSync = createExeca(() => ({isSync: true}));\nexport const execaCommand = createExeca(mapCommandAsync);\nexport const execaCommandSync = createExeca(mapCommandSync);\nexport const execaNode = createExeca(mapNode);\nexport const $ = createExeca(mapScriptAsync, {}, deepScriptOptions, setScriptSync);\n\nconst {\n\tsendMessage,\n\tgetOneMessage,\n\tgetEachMessage,\n\tgetCancelSignal,\n} = getIpcExport();\nexport {\n\tsendMessage,\n\tgetOneMessage,\n\tgetEachMessage,\n\tgetCancelSignal,\n};\n"
  },
  {
    "path": "lib/arguments/command.js",
    "content": "import {logCommand} from '../verbose/start.js';\nimport {getVerboseInfo} from '../verbose/info.js';\nimport {getStartTime} from '../return/duration.js';\nimport {joinCommand} from './escape.js';\nimport {normalizeFdSpecificOption} from './specific.js';\n\n// Compute `result.command`, `result.escapedCommand` and `verbose`-related information\nexport const handleCommand = (filePath, rawArguments, rawOptions) => {\n\tconst startTime = getStartTime();\n\tconst {command, escapedCommand} = joinCommand(filePath, rawArguments);\n\tconst verbose = normalizeFdSpecificOption(rawOptions, 'verbose');\n\tconst verboseInfo = getVerboseInfo(verbose, escapedCommand, {...rawOptions});\n\tlogCommand(escapedCommand, verboseInfo);\n\treturn {\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstartTime,\n\t\tverboseInfo,\n\t};\n};\n"
  },
  {
    "path": "lib/arguments/cwd.js",
    "content": "import {statSync} from 'node:fs';\nimport path from 'node:path';\nimport process from 'node:process';\nimport {safeNormalizeFileUrl} from './file-url.js';\n\n// Normalize `cwd` option\nexport const normalizeCwd = (cwd = getDefaultCwd()) => {\n\tconst cwdString = safeNormalizeFileUrl(cwd, 'The \"cwd\" option');\n\treturn path.resolve(cwdString);\n};\n\nconst getDefaultCwd = () => {\n\ttry {\n\t\treturn process.cwd();\n\t} catch (error) {\n\t\terror.message = `The current directory does not exist.\\n${error.message}`;\n\t\tthrow error;\n\t}\n};\n\n// When `cwd` option has an invalid value, provide with a better error message\nexport const fixCwdError = (originalMessage, cwd) => {\n\tif (cwd === getDefaultCwd()) {\n\t\treturn originalMessage;\n\t}\n\n\tlet cwdStat;\n\ttry {\n\t\tcwdStat = statSync(cwd);\n\t} catch (error) {\n\t\treturn `The \"cwd\" option is invalid: ${cwd}.\\n${error.message}\\n${originalMessage}`;\n\t}\n\n\tif (!cwdStat.isDirectory()) {\n\t\treturn `The \"cwd\" option is not a directory: ${cwd}.\\n${originalMessage}`;\n\t}\n\n\treturn originalMessage;\n};\n"
  },
  {
    "path": "lib/arguments/encoding-option.js",
    "content": "// Validate `encoding` option\nexport const validateEncoding = ({encoding}) => {\n\tif (ENCODINGS.has(encoding)) {\n\t\treturn;\n\t}\n\n\tconst correctEncoding = getCorrectEncoding(encoding);\n\tif (correctEncoding !== undefined) {\n\t\tthrow new TypeError(`Invalid option \\`encoding: ${serializeEncoding(encoding)}\\`.\nPlease rename it to ${serializeEncoding(correctEncoding)}.`);\n\t}\n\n\tconst correctEncodings = [...ENCODINGS].map(correctEncoding => serializeEncoding(correctEncoding)).join(', ');\n\tthrow new TypeError(`Invalid option \\`encoding: ${serializeEncoding(encoding)}\\`.\nPlease rename it to one of: ${correctEncodings}.`);\n};\n\nconst TEXT_ENCODINGS = new Set(['utf8', 'utf16le']);\nexport const BINARY_ENCODINGS = new Set(['buffer', 'hex', 'base64', 'base64url', 'latin1', 'ascii']);\nconst ENCODINGS = new Set([...TEXT_ENCODINGS, ...BINARY_ENCODINGS]);\n\nconst getCorrectEncoding = encoding => {\n\tif (encoding === null) {\n\t\treturn 'buffer';\n\t}\n\n\tif (typeof encoding !== 'string') {\n\t\treturn;\n\t}\n\n\tconst lowerEncoding = encoding.toLowerCase();\n\tif (lowerEncoding in ENCODING_ALIASES) {\n\t\treturn ENCODING_ALIASES[lowerEncoding];\n\t}\n\n\tif (ENCODINGS.has(lowerEncoding)) {\n\t\treturn lowerEncoding;\n\t}\n};\n\nconst ENCODING_ALIASES = {\n\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t'utf-8': 'utf8',\n\t'utf-16le': 'utf16le',\n\t'ucs-2': 'utf16le',\n\tucs2: 'utf16le',\n\tbinary: 'latin1',\n};\n\nconst serializeEncoding = encoding => typeof encoding === 'string' ? `\"${encoding}\"` : String(encoding);\n"
  },
  {
    "path": "lib/arguments/escape.js",
    "content": "import {platform} from 'node:process';\nimport {stripVTControlCharacters} from 'node:util';\n\n// Compute `result.command` and `result.escapedCommand`\nexport const joinCommand = (filePath, rawArguments) => {\n\tconst fileAndArguments = [filePath, ...rawArguments];\n\tconst command = fileAndArguments.join(' ');\n\tconst escapedCommand = fileAndArguments\n\t\t.map(fileAndArgument => quoteString(escapeControlCharacters(fileAndArgument)))\n\t\t.join(' ');\n\treturn {command, escapedCommand};\n};\n\n// Remove ANSI sequences and escape control characters and newlines\nexport const escapeLines = lines => stripVTControlCharacters(lines)\n\t.split('\\n')\n\t.map(line => escapeControlCharacters(line))\n\t.join('\\n');\n\nconst escapeControlCharacters = line => line.replaceAll(SPECIAL_CHAR_REGEXP, character => escapeControlCharacter(character));\n\nconst escapeControlCharacter = character => {\n\tconst commonEscape = COMMON_ESCAPES[character];\n\tif (commonEscape !== undefined) {\n\t\treturn commonEscape;\n\t}\n\n\tconst codepoint = character.codePointAt(0);\n\tconst codepointHex = codepoint.toString(16);\n\treturn codepoint <= ASTRAL_START\n\t\t? `\\\\u${codepointHex.padStart(4, '0')}`\n\t\t: `\\\\U${codepointHex}`;\n};\n\n// Characters that would create issues when printed are escaped using the \\u or \\U notation.\n// Those include control characters and newlines.\n// The \\u and \\U notation is Bash specific, but there is no way to do this in a shell-agnostic way.\n// Some shells do not even have a way to print those characters in an escaped fashion.\n// Therefore, we prioritize printing those safely, instead of allowing those to be copy-pasted.\n// List of Unicode character categories: https://www.fileformat.info/info/unicode/category/index.htm\nconst getSpecialCharRegExp = () => {\n\ttry {\n\t\t// This throws when using Node.js without ICU support.\n\t\t// When using a RegExp literal, this would throw at parsing-time, instead of runtime.\n\t\t// eslint-disable-next-line prefer-regex-literals\n\t\treturn new RegExp('\\\\p{Separator}|\\\\p{Other}', 'gu');\n\t} catch {\n\t\t// Similar to the above RegExp, but works even when Node.js has been built without ICU support.\n\t\t// Unlike the above RegExp, it only covers whitespaces and C0/C1 control characters.\n\t\t// It does not cover some edge cases, such as Unicode reserved characters.\n\t\t// See https://github.com/sindresorhus/execa/issues/1143\n\t\t// eslint-disable-next-line no-control-regex\n\t\treturn /[\\s\\u0000-\\u001F\\u007F-\\u009F\\u00AD]/g;\n\t}\n};\n\nconst SPECIAL_CHAR_REGEXP = getSpecialCharRegExp();\n\n// Accepted by $'...' in Bash.\n// Exclude \\a \\e \\v which are accepted in Bash but not in JavaScript (except \\v) and JSON.\nconst COMMON_ESCAPES = {\n\t' ': ' ',\n\t'\\b': '\\\\b',\n\t'\\f': '\\\\f',\n\t'\\n': '\\\\n',\n\t'\\r': '\\\\r',\n\t'\\t': '\\\\t',\n};\n\n// Up until that codepoint, \\u notation can be used instead of \\U\nconst ASTRAL_START = 65_535;\n\n// Some characters are shell-specific, i.e. need to be escaped when the command is copy-pasted then run.\n// Escaping is shell-specific. We cannot know which shell is used: `process.platform` detection is not enough.\n// For example, Windows users could be using `cmd.exe`, Powershell or Bash for Windows which all use different escaping.\n// We use '...' on Unix, which is POSIX shell compliant and escape all characters but ' so this is fairly safe.\n// On Windows, we assume cmd.exe is used and escape with \"...\", which also works with Powershell.\nconst quoteString = escapedArgument => {\n\tif (NO_ESCAPE_REGEXP.test(escapedArgument)) {\n\t\treturn escapedArgument;\n\t}\n\n\treturn platform === 'win32'\n\t\t? `\"${escapedArgument.replaceAll('\"', '\"\"')}\"`\n\t\t: `'${escapedArgument.replaceAll('\\'', '\\'\\\\\\'\\'')}'`;\n};\n\nconst NO_ESCAPE_REGEXP = /^[\\w./-]+$/;\n"
  },
  {
    "path": "lib/arguments/fd-options.js",
    "content": "import {parseFd} from './specific.js';\n\n// Retrieve stream targeted by the `to` option\nexport const getToStream = (destination, to = 'stdin') => {\n\tconst isWritable = true;\n\tconst {options, fileDescriptors} = SUBPROCESS_OPTIONS.get(destination);\n\tconst fdNumber = getFdNumber(fileDescriptors, to, isWritable);\n\tconst destinationStream = destination.stdio[fdNumber];\n\n\tif (destinationStream === null) {\n\t\tthrow new TypeError(getInvalidStdioOptionMessage(fdNumber, to, options, isWritable));\n\t}\n\n\treturn destinationStream;\n};\n\n// Retrieve stream targeted by the `from` option\nexport const getFromStream = (source, from = 'stdout') => {\n\tconst isWritable = false;\n\tconst {options, fileDescriptors} = SUBPROCESS_OPTIONS.get(source);\n\tconst fdNumber = getFdNumber(fileDescriptors, from, isWritable);\n\tconst sourceStream = fdNumber === 'all' ? source.all : source.stdio[fdNumber];\n\n\tif (sourceStream === null || sourceStream === undefined) {\n\t\tthrow new TypeError(getInvalidStdioOptionMessage(fdNumber, from, options, isWritable));\n\t}\n\n\treturn sourceStream;\n};\n\n// Keeps track of the options passed to each Execa call\nexport const SUBPROCESS_OPTIONS = new WeakMap();\n\nconst getFdNumber = (fileDescriptors, fdName, isWritable) => {\n\tconst fdNumber = parseFdNumber(fdName, isWritable);\n\tvalidateFdNumber(fdNumber, fdName, isWritable, fileDescriptors);\n\treturn fdNumber;\n};\n\nconst parseFdNumber = (fdName, isWritable) => {\n\tconst fdNumber = parseFd(fdName);\n\tif (fdNumber !== undefined) {\n\t\treturn fdNumber;\n\t}\n\n\tconst {validOptions, defaultValue} = isWritable\n\t\t? {validOptions: '\"stdin\"', defaultValue: 'stdin'}\n\t\t: {validOptions: '\"stdout\", \"stderr\", \"all\"', defaultValue: 'stdout'};\n\tthrow new TypeError(`\"${getOptionName(isWritable)}\" must not be \"${fdName}\".\nIt must be ${validOptions} or \"fd3\", \"fd4\" (and so on).\nIt is optional and defaults to \"${defaultValue}\".`);\n};\n\nconst validateFdNumber = (fdNumber, fdName, isWritable, fileDescriptors) => {\n\tconst fileDescriptor = fileDescriptors[getUsedDescriptor(fdNumber)];\n\tif (fileDescriptor === undefined) {\n\t\tthrow new TypeError(`\"${getOptionName(isWritable)}\" must not be ${fdName}. That file descriptor does not exist.\nPlease set the \"stdio\" option to ensure that file descriptor exists.`);\n\t}\n\n\tif (fileDescriptor.direction === 'input' && !isWritable) {\n\t\tthrow new TypeError(`\"${getOptionName(isWritable)}\" must not be ${fdName}. It must be a readable stream, not writable.`);\n\t}\n\n\tif (fileDescriptor.direction !== 'input' && isWritable) {\n\t\tthrow new TypeError(`\"${getOptionName(isWritable)}\" must not be ${fdName}. It must be a writable stream, not readable.`);\n\t}\n};\n\nconst getInvalidStdioOptionMessage = (fdNumber, fdName, options, isWritable) => {\n\tif (fdNumber === 'all' && !options.all) {\n\t\treturn 'The \"all\" option must be true to use \"from: \\'all\\'\".';\n\t}\n\n\tconst {optionName, optionValue} = getInvalidStdioOption(fdNumber, options);\n\treturn `The \"${optionName}: ${serializeOptionValue(optionValue)}\" option is incompatible with using \"${getOptionName(isWritable)}: ${serializeOptionValue(fdName)}\".\nPlease set this option with \"pipe\" instead.`;\n};\n\nconst getInvalidStdioOption = (fdNumber, {stdin, stdout, stderr, stdio}) => {\n\tconst usedDescriptor = getUsedDescriptor(fdNumber);\n\n\tif (usedDescriptor === 0 && stdin !== undefined) {\n\t\treturn {optionName: 'stdin', optionValue: stdin};\n\t}\n\n\tif (usedDescriptor === 1 && stdout !== undefined) {\n\t\treturn {optionName: 'stdout', optionValue: stdout};\n\t}\n\n\tif (usedDescriptor === 2 && stderr !== undefined) {\n\t\treturn {optionName: 'stderr', optionValue: stderr};\n\t}\n\n\treturn {optionName: `stdio[${usedDescriptor}]`, optionValue: stdio[usedDescriptor]};\n};\n\nconst getUsedDescriptor = fdNumber => fdNumber === 'all' ? 1 : fdNumber;\n\nconst getOptionName = isWritable => isWritable ? 'to' : 'from';\n\nexport const serializeOptionValue = value => {\n\tif (typeof value === 'string') {\n\t\treturn `'${value}'`;\n\t}\n\n\treturn typeof value === 'number' ? `${value}` : 'Stream';\n};\n"
  },
  {
    "path": "lib/arguments/file-url.js",
    "content": "import {fileURLToPath} from 'node:url';\n\n// Allow some arguments/options to be either a file path string or a file URL\nexport const safeNormalizeFileUrl = (file, name) => {\n\tconst fileString = normalizeFileUrl(normalizeDenoExecPath(file));\n\n\tif (typeof fileString !== 'string') {\n\t\tthrow new TypeError(`${name} must be a string or a file URL: ${fileString}.`);\n\t}\n\n\treturn fileString;\n};\n\n// In Deno node:process execPath is a special object, not just a string:\n// https://github.com/denoland/deno/blob/f460188e583f00144000aa0d8ade08218d47c3c1/ext/node/polyfills/process.ts#L344\nconst normalizeDenoExecPath = file => isDenoExecPath(file)\n\t? file.toString()\n\t: file;\n\nexport const isDenoExecPath = file => typeof file !== 'string'\n\t&& file\n\t&& Object.getPrototypeOf(file) === String.prototype;\n\n// Same but also allows other values, e.g. `boolean` for the `shell` option\nexport const normalizeFileUrl = file => file instanceof URL ? fileURLToPath(file) : file;\n"
  },
  {
    "path": "lib/arguments/options.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\nimport crossSpawn from 'cross-spawn';\nimport {npmRunPathEnv} from 'npm-run-path';\nimport {normalizeForceKillAfterDelay} from '../terminate/kill.js';\nimport {normalizeKillSignal} from '../terminate/signal.js';\nimport {validateCancelSignal} from '../terminate/cancel.js';\nimport {validateGracefulCancel} from '../terminate/graceful.js';\nimport {validateTimeout} from '../terminate/timeout.js';\nimport {handleNodeOption} from '../methods/node.js';\nimport {validateIpcInputOption} from '../ipc/ipc-input.js';\nimport {validateEncoding, BINARY_ENCODINGS} from './encoding-option.js';\nimport {normalizeCwd} from './cwd.js';\nimport {normalizeFileUrl} from './file-url.js';\nimport {normalizeFdSpecificOptions} from './specific.js';\n\n// Normalize the options object, and sometimes also the file paths and arguments.\n// Applies default values, validate allowed options, normalize them.\nexport const normalizeOptions = (filePath, rawArguments, rawOptions) => {\n\t// Prevent prototype pollution by copying only own properties to a null-prototype object\n\tconst sanitizedOptions = {__proto__: null, ...rawOptions};\n\tsanitizedOptions.cwd = normalizeCwd(sanitizedOptions.cwd);\n\tconst [processedFile, processedArguments, processedOptions] = handleNodeOption(filePath, rawArguments, sanitizedOptions);\n\n\tconst {command: file, args: commandArguments, options: initialOptions} = crossSpawn._parse(processedFile, processedArguments, processedOptions);\n\n\tconst fdOptions = normalizeFdSpecificOptions(initialOptions);\n\tconst options = addDefaultOptions(fdOptions);\n\tvalidateTimeout(options);\n\tvalidateEncoding(options);\n\tvalidateIpcInputOption(options);\n\tvalidateCancelSignal(options);\n\tvalidateGracefulCancel(options);\n\toptions.shell = normalizeFileUrl(options.shell);\n\toptions.env = getEnv(options);\n\toptions.killSignal = normalizeKillSignal(options.killSignal);\n\toptions.forceKillAfterDelay = normalizeForceKillAfterDelay(options.forceKillAfterDelay);\n\toptions.lines = options.lines.map((lines, fdNumber) => lines && !BINARY_ENCODINGS.has(options.encoding) && options.buffer[fdNumber]);\n\n\tif (process.platform === 'win32' && path.basename(file, '.exe') === 'cmd') {\n\t\t// #116\n\t\tcommandArguments.unshift('/q');\n\t}\n\n\treturn {file, commandArguments, options};\n};\n\n// Use null prototype to prevent prototype pollution from leaking through\nconst addDefaultOptions = ({\n\textendEnv = true,\n\tpreferLocal = false,\n\tcwd,\n\tlocalDir: localDirectory = cwd,\n\tencoding = 'utf8',\n\treject = true,\n\tcleanup = true,\n\tall = false,\n\twindowsHide = true,\n\tkillSignal = 'SIGTERM',\n\tforceKillAfterDelay = true,\n\tgracefulCancel = false,\n\tipcInput,\n\tipc = ipcInput !== undefined || gracefulCancel,\n\tserialization = 'advanced',\n\t...options\n}) => ({\n\t__proto__: null,\n\t...options,\n\textendEnv,\n\tpreferLocal,\n\tcwd,\n\tlocalDirectory,\n\tencoding,\n\treject,\n\tcleanup,\n\tall,\n\twindowsHide,\n\tkillSignal,\n\tforceKillAfterDelay,\n\tgracefulCancel,\n\tipcInput,\n\tipc,\n\tserialization,\n});\n\nconst getEnv = ({env: envOption, extendEnv, preferLocal, node, localDirectory, nodePath}) => {\n\tconst env = extendEnv ? {...process.env, ...envOption} : envOption;\n\n\tif (preferLocal || node) {\n\t\treturn npmRunPathEnv({\n\t\t\tenv,\n\t\t\tcwd: localDirectory,\n\t\t\texecPath: nodePath,\n\t\t\tpreferLocal,\n\t\t\taddExecPath: node,\n\t\t});\n\t}\n\n\treturn env;\n};\n"
  },
  {
    "path": "lib/arguments/shell.js",
    "content": "// When the `shell` option is set, any command argument is concatenated as a single string by Node.js:\n// https://github.com/nodejs/node/blob/e38ce27f3ca0a65f68a31cedd984cddb927d4002/lib/child_process.js#L614-L624\n// However, since Node 24, it also prints a deprecation warning.\n// To avoid this warning, we perform that same operation before calling `node:child_process`.\n// Shells only understand strings, which is why Node.js performs that concatenation.\n// However, we rely on users splitting command arguments as an array.\n// For example, this allows us to easily detect which arguments are passed.\n// So we do want users to pass array of arguments even with `shell: true`, but we also want to avoid any warning.\nexport const concatenateShell = (file, commandArguments, options) => options.shell && commandArguments.length > 0\n\t? [[file, ...commandArguments].join(' '), [], options]\n\t: [file, commandArguments, options];\n"
  },
  {
    "path": "lib/arguments/specific.js",
    "content": "import {debuglog} from 'node:util';\nimport isPlainObject from 'is-plain-obj';\nimport {STANDARD_STREAMS_ALIASES} from '../utils/standard-stream.js';\n\n// Some options can have different values for `stdout`/`stderr`/`fd3`.\n// This normalizes those to array of values.\n// For example, `{verbose: {stdout: 'none', stderr: 'full'}}` becomes `{verbose: ['none', 'none', 'full']}`\nexport const normalizeFdSpecificOptions = options => {\n\tconst optionsCopy = {...options};\n\n\tfor (const optionName of FD_SPECIFIC_OPTIONS) {\n\t\toptionsCopy[optionName] = normalizeFdSpecificOption(options, optionName);\n\t}\n\n\treturn optionsCopy;\n};\n\nexport const normalizeFdSpecificOption = (options, optionName) => {\n\tconst optionBaseArray = Array.from({length: getStdioLength(options) + 1});\n\tconst optionArray = normalizeFdSpecificValue(options[optionName], optionBaseArray, optionName);\n\treturn addDefaultValue(optionArray, optionName);\n};\n\nconst getStdioLength = ({stdio}) => Array.isArray(stdio)\n\t? Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length)\n\t: STANDARD_STREAMS_ALIASES.length;\n\nconst normalizeFdSpecificValue = (optionValue, optionArray, optionName) => isPlainObject(optionValue)\n\t? normalizeOptionObject(optionValue, optionArray, optionName)\n\t: optionArray.fill(optionValue);\n\nconst normalizeOptionObject = (optionValue, optionArray, optionName) => {\n\tfor (const fdName of Object.keys(optionValue).sort(compareFdName)) {\n\t\tfor (const fdNumber of parseFdName(fdName, optionName, optionArray)) {\n\t\t\toptionArray[fdNumber] = optionValue[fdName];\n\t\t}\n\t}\n\n\treturn optionArray;\n};\n\n// Ensure priority order when setting both `stdout`/`stderr`, `fd1`/`fd2`, and `all`\nconst compareFdName = (fdNameA, fdNameB) => getFdNameOrder(fdNameA) < getFdNameOrder(fdNameB) ? 1 : -1;\n\nconst getFdNameOrder = fdName => {\n\tif (fdName === 'stdout' || fdName === 'stderr') {\n\t\treturn 0;\n\t}\n\n\treturn fdName === 'all' ? 2 : 1;\n};\n\nconst parseFdName = (fdName, optionName, optionArray) => {\n\tif (fdName === 'ipc') {\n\t\treturn [optionArray.length - 1];\n\t}\n\n\tconst fdNumber = parseFd(fdName);\n\tif (fdNumber === undefined || fdNumber === 0) {\n\t\tthrow new TypeError(`\"${optionName}.${fdName}\" is invalid.\nIt must be \"${optionName}.stdout\", \"${optionName}.stderr\", \"${optionName}.all\", \"${optionName}.ipc\", or \"${optionName}.fd3\", \"${optionName}.fd4\" (and so on).`);\n\t}\n\n\tif (fdNumber >= optionArray.length) {\n\t\tthrow new TypeError(`\"${optionName}.${fdName}\" is invalid: that file descriptor does not exist.\nPlease set the \"stdio\" option to ensure that file descriptor exists.`);\n\t}\n\n\treturn fdNumber === 'all' ? [1, 2] : [fdNumber];\n};\n\n// Use the same syntax for fd-specific options and the `from`/`to` options\nexport const parseFd = fdName => {\n\tif (fdName === 'all') {\n\t\treturn fdName;\n\t}\n\n\tif (STANDARD_STREAMS_ALIASES.includes(fdName)) {\n\t\treturn STANDARD_STREAMS_ALIASES.indexOf(fdName);\n\t}\n\n\tconst regexpResult = FD_REGEXP.exec(fdName);\n\tif (regexpResult !== null) {\n\t\treturn Number(regexpResult[1]);\n\t}\n};\n\nconst FD_REGEXP = /^fd(\\d+)$/;\n\nconst addDefaultValue = (optionArray, optionName) => optionArray.map(optionValue => optionValue === undefined\n\t? DEFAULT_OPTIONS[optionName]\n\t: optionValue);\n\n// Default value for the `verbose` option\nconst verboseDefault = debuglog('execa').enabled ? 'full' : 'none';\n\nconst DEFAULT_OPTIONS = {\n\tlines: false,\n\tbuffer: true,\n\tmaxBuffer: 1000 * 1000 * 100,\n\tverbose: verboseDefault,\n\tstripFinalNewline: true,\n};\n\n// List of options which can have different values for `stdout`/`stderr`\nexport const FD_SPECIFIC_OPTIONS = ['lines', 'buffer', 'maxBuffer', 'verbose', 'stripFinalNewline'];\n\n// Retrieve fd-specific option\nexport const getFdSpecificValue = (optionArray, fdNumber) => fdNumber === 'ipc'\n\t? optionArray.at(-1)\n\t: optionArray[fdNumber];\n"
  },
  {
    "path": "lib/convert/add.js",
    "content": "import {initializeConcurrentStreams} from './concurrent.js';\nimport {createReadable} from './readable.js';\nimport {createWritable} from './writable.js';\nimport {createDuplex} from './duplex.js';\nimport {createIterable} from './iterable.js';\n\n// Add methods to convert the subprocess to a stream or iterable\nexport const addConvertedStreams = (subprocess, {encoding}) => {\n\tconst concurrentStreams = initializeConcurrentStreams();\n\tsubprocess.readable = createReadable.bind(undefined, {subprocess, concurrentStreams, encoding});\n\tsubprocess.writable = createWritable.bind(undefined, {subprocess, concurrentStreams});\n\tsubprocess.duplex = createDuplex.bind(undefined, {subprocess, concurrentStreams, encoding});\n\tsubprocess.iterable = createIterable.bind(undefined, subprocess, encoding);\n\tsubprocess[Symbol.asyncIterator] = createIterable.bind(undefined, subprocess, encoding, {});\n};\n"
  },
  {
    "path": "lib/convert/concurrent.js",
    "content": "import {createDeferred} from '../utils/deferred.js';\n\n// When using multiple `.readable()`/`.writable()`/`.duplex()`, `final` and `destroy` should wait for other streams\nexport const initializeConcurrentStreams = () => ({\n\treadableDestroy: new WeakMap(),\n\twritableFinal: new WeakMap(),\n\twritableDestroy: new WeakMap(),\n});\n\n// Each file descriptor + `waitName` has its own array of promises.\n// Each promise is a single `.readable()`/`.writable()`/`.duplex()` call.\nexport const addConcurrentStream = (concurrentStreams, stream, waitName) => {\n\tconst weakMap = concurrentStreams[waitName];\n\tif (!weakMap.has(stream)) {\n\t\tweakMap.set(stream, []);\n\t}\n\n\tconst promises = weakMap.get(stream);\n\tconst promise = createDeferred();\n\tpromises.push(promise);\n\tconst resolve = promise.resolve.bind(promise);\n\treturn {resolve, promises};\n};\n\n// Wait for other streams, but stop waiting when subprocess ends\nexport const waitForConcurrentStreams = async ({resolve, promises}, subprocess) => {\n\tresolve();\n\tconst [isSubprocessExit] = await Promise.race([\n\t\tPromise.allSettled([true, subprocess]),\n\t\tPromise.all([false, ...promises]),\n\t]);\n\treturn !isSubprocessExit;\n};\n"
  },
  {
    "path": "lib/convert/duplex.js",
    "content": "import {Duplex} from 'node:stream';\nimport {callbackify} from 'node:util';\nimport {BINARY_ENCODINGS} from '../arguments/encoding-option.js';\nimport {\n\tgetSubprocessStdout,\n\tgetReadableOptions,\n\tgetReadableMethods,\n\tonStdoutFinished,\n\tonReadableDestroy,\n} from './readable.js';\nimport {\n\tgetSubprocessStdin,\n\tgetWritableMethods,\n\tonStdinFinished,\n\tonWritableDestroy,\n} from './writable.js';\n\n// Create a `Duplex` stream combining both `subprocess.readable()` and `subprocess.writable()`\nexport const createDuplex = ({subprocess, concurrentStreams, encoding}, {from, to, binary: binaryOption = true, preserveNewlines = true} = {}) => {\n\tconst binary = binaryOption || BINARY_ENCODINGS.has(encoding);\n\tconst {subprocessStdout, waitReadableDestroy} = getSubprocessStdout(subprocess, from, concurrentStreams);\n\tconst {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams);\n\tconst {readableEncoding, readableObjectMode, readableHighWaterMark} = getReadableOptions(subprocessStdout, binary);\n\tconst {read, onStdoutDataDone} = getReadableMethods({\n\t\tsubprocessStdout,\n\t\tsubprocess,\n\t\tbinary,\n\t\tencoding,\n\t\tpreserveNewlines,\n\t});\n\tconst duplex = new Duplex({\n\t\tread,\n\t\t...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal),\n\t\tdestroy: callbackify(onDuplexDestroy.bind(undefined, {\n\t\t\tsubprocessStdout,\n\t\t\tsubprocessStdin,\n\t\t\tsubprocess,\n\t\t\twaitReadableDestroy,\n\t\t\twaitWritableFinal,\n\t\t\twaitWritableDestroy,\n\t\t})),\n\t\treadableHighWaterMark,\n\t\twritableHighWaterMark: subprocessStdin.writableHighWaterMark,\n\t\treadableObjectMode,\n\t\twritableObjectMode: subprocessStdin.writableObjectMode,\n\t\tencoding: readableEncoding,\n\t});\n\tonStdoutFinished({\n\t\tsubprocessStdout,\n\t\tonStdoutDataDone,\n\t\treadable: duplex,\n\t\tsubprocess,\n\t\tsubprocessStdin,\n\t});\n\tonStdinFinished(subprocessStdin, duplex, subprocessStdout);\n\treturn duplex;\n};\n\nconst onDuplexDestroy = async ({subprocessStdout, subprocessStdin, subprocess, waitReadableDestroy, waitWritableFinal, waitWritableDestroy}, error) => {\n\tawait Promise.all([\n\t\tonReadableDestroy({subprocessStdout, subprocess, waitReadableDestroy}, error),\n\t\tonWritableDestroy({\n\t\t\tsubprocessStdin,\n\t\t\tsubprocess,\n\t\t\twaitWritableFinal,\n\t\t\twaitWritableDestroy,\n\t\t}, error),\n\t]);\n};\n"
  },
  {
    "path": "lib/convert/iterable.js",
    "content": "import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';\nimport {getFromStream} from '../arguments/fd-options.js';\nimport {iterateOnSubprocessStream} from '../io/iterate.js';\n\n// Convert the subprocess to an async iterable\nexport const createIterable = (subprocess, encoding, {\n\tfrom,\n\tbinary: binaryOption = false,\n\tpreserveNewlines = false,\n} = {}) => {\n\tconst binary = binaryOption || BINARY_ENCODINGS.has(encoding);\n\tconst subprocessStdout = getFromStream(subprocess, from);\n\tconst onStdoutData = iterateOnSubprocessStream({\n\t\tsubprocessStdout,\n\t\tsubprocess,\n\t\tbinary,\n\t\tshouldEncode: true,\n\t\tencoding,\n\t\tpreserveNewlines,\n\t});\n\treturn iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);\n};\n\nconst iterateOnStdoutData = async function * (onStdoutData, subprocessStdout, subprocess) {\n\ttry {\n\t\tyield * onStdoutData;\n\t} finally {\n\t\tif (subprocessStdout.readable) {\n\t\t\tsubprocessStdout.destroy();\n\t\t}\n\n\t\tawait subprocess;\n\t}\n};\n"
  },
  {
    "path": "lib/convert/readable.js",
    "content": "import {Readable} from 'node:stream';\nimport {callbackify} from 'node:util';\nimport {BINARY_ENCODINGS} from '../arguments/encoding-option.js';\nimport {getFromStream} from '../arguments/fd-options.js';\nimport {iterateOnSubprocessStream, DEFAULT_OBJECT_HIGH_WATER_MARK} from '../io/iterate.js';\nimport {createDeferred} from '../utils/deferred.js';\nimport {addConcurrentStream, waitForConcurrentStreams} from './concurrent.js';\nimport {\n\tsafeWaitForSubprocessStdin,\n\twaitForSubprocessStdout,\n\twaitForSubprocess,\n\tdestroyOtherStream,\n} from './shared.js';\n\n// Create a `Readable` stream that forwards from `stdout` and awaits the subprocess\nexport const createReadable = ({subprocess, concurrentStreams, encoding}, {from, binary: binaryOption = true, preserveNewlines = true} = {}) => {\n\tconst binary = binaryOption || BINARY_ENCODINGS.has(encoding);\n\tconst {subprocessStdout, waitReadableDestroy} = getSubprocessStdout(subprocess, from, concurrentStreams);\n\tconst {readableEncoding, readableObjectMode, readableHighWaterMark} = getReadableOptions(subprocessStdout, binary);\n\tconst {read, onStdoutDataDone} = getReadableMethods({\n\t\tsubprocessStdout,\n\t\tsubprocess,\n\t\tbinary,\n\t\tencoding,\n\t\tpreserveNewlines,\n\t});\n\tconst readable = new Readable({\n\t\tread,\n\t\tdestroy: callbackify(onReadableDestroy.bind(undefined, {subprocessStdout, subprocess, waitReadableDestroy})),\n\t\thighWaterMark: readableHighWaterMark,\n\t\tobjectMode: readableObjectMode,\n\t\tencoding: readableEncoding,\n\t});\n\tonStdoutFinished({\n\t\tsubprocessStdout,\n\t\tonStdoutDataDone,\n\t\treadable,\n\t\tsubprocess,\n\t});\n\treturn readable;\n};\n\n// Retrieve `stdout` (or other stream depending on `from`)\nexport const getSubprocessStdout = (subprocess, from, concurrentStreams) => {\n\tconst subprocessStdout = getFromStream(subprocess, from);\n\tconst waitReadableDestroy = addConcurrentStream(concurrentStreams, subprocessStdout, 'readableDestroy');\n\treturn {subprocessStdout, waitReadableDestroy};\n};\n\nexport const getReadableOptions = ({readableEncoding, readableObjectMode, readableHighWaterMark}, binary) => binary\n\t? {readableEncoding, readableObjectMode, readableHighWaterMark}\n\t: {readableEncoding, readableObjectMode: true, readableHighWaterMark: DEFAULT_OBJECT_HIGH_WATER_MARK};\n\nexport const getReadableMethods = ({subprocessStdout, subprocess, binary, encoding, preserveNewlines}) => {\n\tconst onStdoutDataDone = createDeferred();\n\tconst onStdoutData = iterateOnSubprocessStream({\n\t\tsubprocessStdout,\n\t\tsubprocess,\n\t\tbinary,\n\t\tshouldEncode: !binary,\n\t\tencoding,\n\t\tpreserveNewlines,\n\t});\n\n\treturn {\n\t\tread() {\n\t\t\tonRead(this, onStdoutData, onStdoutDataDone);\n\t\t},\n\t\tonStdoutDataDone,\n\t};\n};\n\n// Forwards data from `stdout` to `readable`\nconst onRead = async (readable, onStdoutData, onStdoutDataDone) => {\n\ttry {\n\t\tconst {value, done} = await onStdoutData.next();\n\t\tif (done) {\n\t\t\tonStdoutDataDone.resolve();\n\t\t} else {\n\t\t\treadable.push(value);\n\t\t}\n\t} catch {}\n};\n\n// When `subprocess.stdout` ends/aborts/errors, do the same on `readable`.\n// Await the subprocess, for the same reason as above.\nexport const onStdoutFinished = async ({subprocessStdout, onStdoutDataDone, readable, subprocess, subprocessStdin}) => {\n\ttry {\n\t\tawait waitForSubprocessStdout(subprocessStdout);\n\t\tawait subprocess;\n\t\tawait safeWaitForSubprocessStdin(subprocessStdin);\n\t\tawait onStdoutDataDone;\n\n\t\tif (readable.readable) {\n\t\t\treadable.push(null);\n\t\t}\n\t} catch (error) {\n\t\tawait safeWaitForSubprocessStdin(subprocessStdin);\n\t\tdestroyOtherReadable(readable, error);\n\t}\n};\n\n// When `readable` aborts/errors, do the same on `subprocess.stdout`\nexport const onReadableDestroy = async ({subprocessStdout, subprocess, waitReadableDestroy}, error) => {\n\tif (await waitForConcurrentStreams(waitReadableDestroy, subprocess)) {\n\t\tdestroyOtherReadable(subprocessStdout, error);\n\t\tawait waitForSubprocess(subprocess, error);\n\t}\n};\n\nconst destroyOtherReadable = (stream, error) => {\n\tdestroyOtherStream(stream, stream.readable, error);\n};\n"
  },
  {
    "path": "lib/convert/shared.js",
    "content": "import {finished} from 'node:stream/promises';\nimport {isStreamAbort} from '../resolve/wait-stream.js';\n\nexport const safeWaitForSubprocessStdin = async subprocessStdin => {\n\tif (subprocessStdin === undefined) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait waitForSubprocessStdin(subprocessStdin);\n\t} catch {}\n};\n\nexport const safeWaitForSubprocessStdout = async subprocessStdout => {\n\tif (subprocessStdout === undefined) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait waitForSubprocessStdout(subprocessStdout);\n\t} catch {}\n};\n\nexport const waitForSubprocessStdin = async subprocessStdin => {\n\tawait finished(subprocessStdin, {cleanup: true, readable: false, writable: true});\n};\n\nexport const waitForSubprocessStdout = async subprocessStdout => {\n\tawait finished(subprocessStdout, {cleanup: true, readable: true, writable: false});\n};\n\n// When `readable` or `writable` aborts/errors, awaits the subprocess, for the reason mentioned above\nexport const waitForSubprocess = async (subprocess, error) => {\n\tawait subprocess;\n\tif (error) {\n\t\tthrow error;\n\t}\n};\n\nexport const destroyOtherStream = (stream, isOpen, error) => {\n\tif (error && !isStreamAbort(error)) {\n\t\tstream.destroy(error);\n\t} else if (isOpen) {\n\t\tstream.destroy();\n\t}\n};\n"
  },
  {
    "path": "lib/convert/writable.js",
    "content": "import {Writable} from 'node:stream';\nimport {callbackify} from 'node:util';\nimport {getToStream} from '../arguments/fd-options.js';\nimport {addConcurrentStream, waitForConcurrentStreams} from './concurrent.js';\nimport {\n\tsafeWaitForSubprocessStdout,\n\twaitForSubprocessStdin,\n\twaitForSubprocess,\n\tdestroyOtherStream,\n} from './shared.js';\n\n// Create a `Writable` stream that forwards to `stdin` and awaits the subprocess\nexport const createWritable = ({subprocess, concurrentStreams}, {to} = {}) => {\n\tconst {subprocessStdin, waitWritableFinal, waitWritableDestroy} = getSubprocessStdin(subprocess, to, concurrentStreams);\n\tconst writable = new Writable({\n\t\t...getWritableMethods(subprocessStdin, subprocess, waitWritableFinal),\n\t\tdestroy: callbackify(onWritableDestroy.bind(undefined, {\n\t\t\tsubprocessStdin,\n\t\t\tsubprocess,\n\t\t\twaitWritableFinal,\n\t\t\twaitWritableDestroy,\n\t\t})),\n\t\thighWaterMark: subprocessStdin.writableHighWaterMark,\n\t\tobjectMode: subprocessStdin.writableObjectMode,\n\t});\n\tonStdinFinished(subprocessStdin, writable);\n\treturn writable;\n};\n\n// Retrieve `stdin` (or other stream depending on `to`)\nexport const getSubprocessStdin = (subprocess, to, concurrentStreams) => {\n\tconst subprocessStdin = getToStream(subprocess, to);\n\tconst waitWritableFinal = addConcurrentStream(concurrentStreams, subprocessStdin, 'writableFinal');\n\tconst waitWritableDestroy = addConcurrentStream(concurrentStreams, subprocessStdin, 'writableDestroy');\n\treturn {subprocessStdin, waitWritableFinal, waitWritableDestroy};\n};\n\nexport const getWritableMethods = (subprocessStdin, subprocess, waitWritableFinal) => ({\n\twrite: onWrite.bind(undefined, subprocessStdin),\n\tfinal: callbackify(onWritableFinal.bind(undefined, subprocessStdin, subprocess, waitWritableFinal)),\n});\n\n// Forwards data from `writable` to `stdin`\nconst onWrite = (subprocessStdin, chunk, encoding, done) => {\n\tif (subprocessStdin.write(chunk, encoding)) {\n\t\tdone();\n\t} else {\n\t\tsubprocessStdin.once('drain', done);\n\t}\n};\n\n// Ensures that the writable `final` and readable `end` events awaits the subprocess.\n// Like this, any subprocess failure is propagated as a stream `error` event, instead of being lost.\n// The user does not need to `await` the subprocess anymore, but now needs to await the stream completion or error.\n// When multiple writables are targeting the same stream, they wait for each other, unless the subprocess ends first.\nconst onWritableFinal = async (subprocessStdin, subprocess, waitWritableFinal) => {\n\tif (await waitForConcurrentStreams(waitWritableFinal, subprocess)) {\n\t\tif (subprocessStdin.writable) {\n\t\t\tsubprocessStdin.end();\n\t\t}\n\n\t\tawait subprocess;\n\t}\n};\n\n// When `subprocess.stdin` ends/aborts/errors, do the same on `writable`.\nexport const onStdinFinished = async (subprocessStdin, writable, subprocessStdout) => {\n\ttry {\n\t\tawait waitForSubprocessStdin(subprocessStdin);\n\t\tif (writable.writable) {\n\t\t\twritable.end();\n\t\t}\n\t} catch (error) {\n\t\tawait safeWaitForSubprocessStdout(subprocessStdout);\n\t\tdestroyOtherWritable(writable, error);\n\t}\n};\n\n// When `writable` aborts/errors, do the same on `subprocess.stdin`\nexport const onWritableDestroy = async ({subprocessStdin, subprocess, waitWritableFinal, waitWritableDestroy}, error) => {\n\tawait waitForConcurrentStreams(waitWritableFinal, subprocess);\n\tif (await waitForConcurrentStreams(waitWritableDestroy, subprocess)) {\n\t\tdestroyOtherWritable(subprocessStdin, error);\n\t\tawait waitForSubprocess(subprocess, error);\n\t}\n};\n\nconst destroyOtherWritable = (stream, error) => {\n\tdestroyOtherStream(stream, stream.writable, error);\n};\n"
  },
  {
    "path": "lib/io/contents.js",
    "content": "import {setImmediate} from 'node:timers/promises';\nimport getStream, {getStreamAsArrayBuffer, getStreamAsArray} from 'get-stream';\nimport {isArrayBuffer} from '../utils/uint-array.js';\nimport {shouldLogOutput, logLines} from '../verbose/output.js';\nimport {iterateForResult} from './iterate.js';\nimport {handleMaxBuffer} from './max-buffer.js';\nimport {getStripFinalNewline} from './strip-newline.js';\n\n// Retrieve `result.stdout|stderr|all|stdio[*]`\nexport const getStreamOutput = async ({stream, onStreamEnd, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, verboseInfo, streamInfo}) => {\n\tconst logPromise = logOutputAsync({\n\t\tstream,\n\t\tonStreamEnd,\n\t\tfdNumber,\n\t\tencoding,\n\t\tallMixed,\n\t\tverboseInfo,\n\t\tstreamInfo,\n\t});\n\n\tif (!buffer) {\n\t\tawait Promise.all([resumeStream(stream), logPromise]);\n\t\treturn;\n\t}\n\n\tconst stripFinalNewlineValue = getStripFinalNewline(stripFinalNewline, fdNumber);\n\tconst iterable = iterateForResult({\n\t\tstream,\n\t\tonStreamEnd,\n\t\tlines,\n\t\tencoding,\n\t\tstripFinalNewline: stripFinalNewlineValue,\n\t\tallMixed,\n\t});\n\tconst [output] = await Promise.all([\n\t\tgetStreamContents({\n\t\t\tstream,\n\t\t\titerable,\n\t\t\tfdNumber,\n\t\t\tencoding,\n\t\t\tmaxBuffer,\n\t\t\tlines,\n\t\t}),\n\t\tlogPromise,\n\t]);\n\treturn output;\n};\n\nconst logOutputAsync = async ({stream, onStreamEnd, fdNumber, encoding, allMixed, verboseInfo, streamInfo: {fileDescriptors}}) => {\n\tif (!shouldLogOutput({\n\t\tstdioItems: fileDescriptors[fdNumber]?.stdioItems,\n\t\tencoding,\n\t\tverboseInfo,\n\t\tfdNumber,\n\t})) {\n\t\treturn;\n\t}\n\n\tconst linesIterable = iterateForResult({\n\t\tstream,\n\t\tonStreamEnd,\n\t\tlines: true,\n\t\tencoding,\n\t\tstripFinalNewline: true,\n\t\tallMixed,\n\t});\n\tawait logLines(linesIterable, stream, fdNumber, verboseInfo);\n};\n\n// When using `buffer: false`, users need to read `subprocess.stdout|stderr|all` right away\n// See https://github.com/sindresorhus/execa/issues/730 and https://github.com/sindresorhus/execa/pull/729#discussion_r1465496310\nconst resumeStream = async stream => {\n\tawait setImmediate();\n\tif (stream.readableFlowing === null) {\n\t\tstream.resume();\n\t}\n};\n\nconst getStreamContents = async ({stream, stream: {readableObjectMode}, iterable, fdNumber, encoding, maxBuffer, lines}) => {\n\ttry {\n\t\tif (readableObjectMode || lines) {\n\t\t\treturn await getStreamAsArray(iterable, {maxBuffer});\n\t\t}\n\n\t\tif (encoding === 'buffer') {\n\t\t\treturn new Uint8Array(await getStreamAsArrayBuffer(iterable, {maxBuffer}));\n\t\t}\n\n\t\treturn await getStream(iterable, {maxBuffer});\n\t} catch (error) {\n\t\treturn handleBufferedData(handleMaxBuffer({\n\t\t\terror,\n\t\t\tstream,\n\t\t\treadableObjectMode,\n\t\t\tlines,\n\t\t\tencoding,\n\t\t\tfdNumber,\n\t\t}));\n\t}\n};\n\n// On failure, `result.stdout|stderr|all` should contain the currently buffered stream\n// They are automatically closed and flushed by Node.js when the subprocess exits\n// When `buffer` is `false`, `streamPromise` is `undefined` and there is no buffered data to retrieve\nexport const getBufferedData = async streamPromise => {\n\ttry {\n\t\treturn await streamPromise;\n\t} catch (error) {\n\t\treturn handleBufferedData(error);\n\t}\n};\n\n// Ensure we are returning Uint8Arrays when using `encoding: 'buffer'`\nconst handleBufferedData = ({bufferedData}) => isArrayBuffer(bufferedData)\n\t? new Uint8Array(bufferedData)\n\t: bufferedData;\n"
  },
  {
    "path": "lib/io/input-sync.js",
    "content": "import {runGeneratorsSync} from '../transform/generator.js';\nimport {joinToUint8Array, isUint8Array} from '../utils/uint-array.js';\nimport {TYPE_TO_MESSAGE} from '../stdio/type.js';\n\n// Apply `stdin`/`input`/`inputFile` options, before spawning, in sync mode, by converting it to the `input` option\nexport const addInputOptionsSync = (fileDescriptors, options) => {\n\tfor (const fdNumber of getInputFdNumbers(fileDescriptors)) {\n\t\taddInputOptionSync(fileDescriptors, fdNumber, options);\n\t}\n};\n\nconst getInputFdNumbers = fileDescriptors => new Set(Object.entries(fileDescriptors)\n\t.filter(([, {direction}]) => direction === 'input')\n\t.map(([fdNumber]) => Number(fdNumber)));\n\nconst addInputOptionSync = (fileDescriptors, fdNumber, options) => {\n\tconst {stdioItems} = fileDescriptors[fdNumber];\n\tconst allStdioItems = stdioItems.filter(({contents}) => contents !== undefined);\n\tif (allStdioItems.length === 0) {\n\t\treturn;\n\t}\n\n\tif (fdNumber !== 0) {\n\t\tconst [{type, optionName}] = allStdioItems;\n\t\tthrow new TypeError(`Only the \\`stdin\\` option, not \\`${optionName}\\`, can be ${TYPE_TO_MESSAGE[type]} with synchronous methods.`);\n\t}\n\n\tconst allContents = allStdioItems.map(({contents}) => contents);\n\tconst transformedContents = allContents.map(contents => applySingleInputGeneratorsSync(contents, stdioItems));\n\toptions.input = joinToUint8Array(transformedContents);\n};\n\nconst applySingleInputGeneratorsSync = (contents, stdioItems) => {\n\tconst newContents = runGeneratorsSync(contents, stdioItems, 'utf8', true);\n\tvalidateSerializable(newContents);\n\treturn joinToUint8Array(newContents);\n};\n\nconst validateSerializable = newContents => {\n\tconst invalidItem = newContents.find(item => typeof item !== 'string' && !isUint8Array(item));\n\tif (invalidItem !== undefined) {\n\t\tthrow new TypeError(`The \\`stdin\\` option is invalid: when passing objects as input, a transform must be used to serialize them to strings or Uint8Arrays: ${invalidItem}.`);\n\t}\n};\n"
  },
  {
    "path": "lib/io/iterate.js",
    "content": "import {on} from 'node:events';\nimport {getDefaultHighWaterMark} from 'node:stream';\nimport {getEncodingTransformGenerator} from '../transform/encoding-transform.js';\nimport {getSplitLinesGenerator} from '../transform/split.js';\nimport {transformChunkSync, finalChunksSync} from '../transform/run-sync.js';\n\n// Iterate over lines of `subprocess.stdout`, used by `subprocess.readable|duplex|iterable()`\nexport const iterateOnSubprocessStream = ({subprocessStdout, subprocess, binary, shouldEncode, encoding, preserveNewlines}) => {\n\tconst controller = new AbortController();\n\tstopReadingOnExit(subprocess, controller);\n\treturn iterateOnStream({\n\t\tstream: subprocessStdout,\n\t\tcontroller,\n\t\tbinary,\n\t\tshouldEncode: !subprocessStdout.readableObjectMode && shouldEncode,\n\t\tencoding,\n\t\tshouldSplit: !subprocessStdout.readableObjectMode,\n\t\tpreserveNewlines,\n\t});\n};\n\nconst stopReadingOnExit = async (subprocess, controller) => {\n\ttry {\n\t\tawait subprocess;\n\t} catch {} finally {\n\t\tcontroller.abort();\n\t}\n};\n\n// Iterate over lines of `subprocess.stdout`, used by `result.stdout` and the `verbose: 'full'` option.\n// Applies the `lines` and `encoding` options.\nexport const iterateForResult = ({stream, onStreamEnd, lines, encoding, stripFinalNewline, allMixed}) => {\n\tconst controller = new AbortController();\n\tstopReadingOnStreamEnd(onStreamEnd, controller, stream);\n\tconst objectMode = stream.readableObjectMode && !allMixed;\n\treturn iterateOnStream({\n\t\tstream,\n\t\tcontroller,\n\t\tbinary: encoding === 'buffer',\n\t\tshouldEncode: !objectMode,\n\t\tencoding,\n\t\tshouldSplit: !objectMode && lines,\n\t\tpreserveNewlines: !stripFinalNewline,\n\t});\n};\n\nconst stopReadingOnStreamEnd = async (onStreamEnd, controller, stream) => {\n\ttry {\n\t\tawait onStreamEnd;\n\t} catch {\n\t\tstream.destroy();\n\t} finally {\n\t\tcontroller.abort();\n\t}\n};\n\nconst iterateOnStream = ({stream, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) => {\n\tconst onStdoutChunk = on(stream, 'data', {\n\t\tsignal: controller.signal,\n\t\thighWaterMark: HIGH_WATER_MARK,\n\t\t// Backward compatibility with older name for this option\n\t\t// See https://github.com/nodejs/node/pull/52080#discussion_r1525227861\n\t\t// @todo Remove after removing support for Node 21\n\t\thighWatermark: HIGH_WATER_MARK,\n\t});\n\treturn iterateOnData({\n\t\tonStdoutChunk,\n\t\tcontroller,\n\t\tbinary,\n\t\tshouldEncode,\n\t\tencoding,\n\t\tshouldSplit,\n\t\tpreserveNewlines,\n\t});\n};\n\nexport const DEFAULT_OBJECT_HIGH_WATER_MARK = getDefaultHighWaterMark(true);\n\n// The `highWaterMark` of `events.on()` is measured in number of events, not in bytes.\n// Not knowing the average amount of bytes per `data` event, we use the same heuristic as streams in objectMode, since they have the same issue.\n// Therefore, we use the value of `getDefaultHighWaterMark(true)`.\n// Note: this option does not exist on Node 18, but this is ok since the logic works without it. It just consumes more memory.\nconst HIGH_WATER_MARK = DEFAULT_OBJECT_HIGH_WATER_MARK;\n\nconst iterateOnData = async function * ({onStdoutChunk, controller, binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) {\n\tconst generators = getGenerators({\n\t\tbinary,\n\t\tshouldEncode,\n\t\tencoding,\n\t\tshouldSplit,\n\t\tpreserveNewlines,\n\t});\n\n\ttry {\n\t\tfor await (const [chunk] of onStdoutChunk) {\n\t\t\tyield * transformChunkSync(chunk, generators, 0);\n\t\t}\n\t} catch (error) {\n\t\tif (!controller.signal.aborted) {\n\t\t\tthrow error;\n\t\t}\n\t} finally {\n\t\tyield * finalChunksSync(generators);\n\t}\n};\n\nconst getGenerators = ({binary, shouldEncode, encoding, shouldSplit, preserveNewlines}) => [\n\tgetEncodingTransformGenerator(binary, encoding, !shouldEncode),\n\tgetSplitLinesGenerator(binary, preserveNewlines, !shouldSplit, {}),\n].filter(Boolean);\n"
  },
  {
    "path": "lib/io/max-buffer.js",
    "content": "import {MaxBufferError} from 'get-stream';\nimport {getStreamName} from '../utils/standard-stream.js';\nimport {getFdSpecificValue} from '../arguments/specific.js';\n\n// When the `maxBuffer` option is hit, a MaxBufferError is thrown.\n// The stream is aborted, then specific information is kept for the error message.\nexport const handleMaxBuffer = ({error, stream, readableObjectMode, lines, encoding, fdNumber}) => {\n\tif (!(error instanceof MaxBufferError)) {\n\t\tthrow error;\n\t}\n\n\tif (fdNumber === 'all') {\n\t\treturn error;\n\t}\n\n\tconst unit = getMaxBufferUnit(readableObjectMode, lines, encoding);\n\terror.maxBufferInfo = {fdNumber, unit};\n\tstream.destroy();\n\tthrow error;\n};\n\nconst getMaxBufferUnit = (readableObjectMode, lines, encoding) => {\n\tif (readableObjectMode) {\n\t\treturn 'objects';\n\t}\n\n\tif (lines) {\n\t\treturn 'lines';\n\t}\n\n\tif (encoding === 'buffer') {\n\t\treturn 'bytes';\n\t}\n\n\treturn 'characters';\n};\n\n// Check the `maxBuffer` option with `result.ipcOutput`\nexport const checkIpcMaxBuffer = (subprocess, ipcOutput, maxBuffer) => {\n\tif (ipcOutput.length !== maxBuffer) {\n\t\treturn;\n\t}\n\n\tconst error = new MaxBufferError();\n\terror.maxBufferInfo = {fdNumber: 'ipc'};\n\tthrow error;\n};\n\n// Error message when `maxBuffer` is hit\nexport const getMaxBufferMessage = (error, maxBuffer) => {\n\tconst {streamName, threshold, unit} = getMaxBufferInfo(error, maxBuffer);\n\treturn `Command's ${streamName} was larger than ${threshold} ${unit}`;\n};\n\nconst getMaxBufferInfo = (error, maxBuffer) => {\n\tif (error?.maxBufferInfo === undefined) {\n\t\treturn {streamName: 'output', threshold: maxBuffer[1], unit: 'bytes'};\n\t}\n\n\tconst {maxBufferInfo: {fdNumber, unit}} = error;\n\tdelete error.maxBufferInfo;\n\n\tconst threshold = getFdSpecificValue(maxBuffer, fdNumber);\n\tif (fdNumber === 'ipc') {\n\t\treturn {streamName: 'IPC output', threshold, unit: 'messages'};\n\t}\n\n\treturn {streamName: getStreamName(fdNumber), threshold, unit};\n};\n\n// The only way to apply `maxBuffer` with `spawnSync()` is to use the native `maxBuffer` option Node.js provides.\n// However, this has multiple limitations, and cannot behave the exact same way as the async behavior.\n// When the `maxBuffer` is hit, a `ENOBUFS` error is thrown.\nexport const isMaxBufferSync = (resultError, output, maxBuffer) => resultError?.code === 'ENOBUFS'\n\t&& output !== null\n\t&& output.some(result => result !== null && result.length > getMaxBufferSync(maxBuffer));\n\n// When `maxBuffer` is hit, ensure the result is truncated\nexport const truncateMaxBufferSync = (result, isMaxBuffer, maxBuffer) => {\n\tif (!isMaxBuffer) {\n\t\treturn result;\n\t}\n\n\tconst maxBufferValue = getMaxBufferSync(maxBuffer);\n\treturn result.length > maxBufferValue ? result.slice(0, maxBufferValue) : result;\n};\n\n// `spawnSync()` does not allow differentiating `maxBuffer` per file descriptor, so we always use `stdout`\nexport const getMaxBufferSync = ([, stdoutMaxBuffer]) => stdoutMaxBuffer;\n"
  },
  {
    "path": "lib/io/output-async.js",
    "content": "import mergeStreams from '@sindresorhus/merge-streams';\nimport {isStandardStream} from '../utils/standard-stream.js';\nimport {incrementMaxListeners} from '../utils/max-listeners.js';\nimport {TRANSFORM_TYPES} from '../stdio/type.js';\nimport {pipeStreams} from './pipeline.js';\n\n// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, after spawning, in async mode\n// When multiple input streams are used, we merge them to ensure the output stream ends only once each input stream has ended\nexport const pipeOutputAsync = (subprocess, fileDescriptors, controller) => {\n\tconst pipeGroups = new Map();\n\n\tfor (const [fdNumber, {stdioItems, direction}] of Object.entries(fileDescriptors)) {\n\t\tfor (const {stream} of stdioItems.filter(({type}) => TRANSFORM_TYPES.has(type))) {\n\t\t\tpipeTransform(subprocess, stream, direction, fdNumber);\n\t\t}\n\n\t\tfor (const {stream} of stdioItems.filter(({type}) => !TRANSFORM_TYPES.has(type))) {\n\t\t\tpipeStdioItem({\n\t\t\t\tsubprocess,\n\t\t\t\tstream,\n\t\t\t\tdirection,\n\t\t\t\tfdNumber,\n\t\t\t\tpipeGroups,\n\t\t\t\tcontroller,\n\t\t\t});\n\t\t}\n\t}\n\n\tfor (const [outputStream, inputStreams] of pipeGroups.entries()) {\n\t\tconst inputStream = inputStreams.length === 1 ? inputStreams[0] : mergeStreams(inputStreams);\n\t\tpipeStreams(inputStream, outputStream);\n\t}\n};\n\n// When using transforms, `subprocess.stdin|stdout|stderr|stdio` is directly mutated\nconst pipeTransform = (subprocess, stream, direction, fdNumber) => {\n\tif (direction === 'output') {\n\t\tpipeStreams(subprocess.stdio[fdNumber], stream);\n\t} else {\n\t\tpipeStreams(stream, subprocess.stdio[fdNumber]);\n\t}\n\n\tconst streamProperty = SUBPROCESS_STREAM_PROPERTIES[fdNumber];\n\tif (streamProperty !== undefined) {\n\t\tsubprocess[streamProperty] = stream;\n\t}\n\n\tsubprocess.stdio[fdNumber] = stream;\n};\n\nconst SUBPROCESS_STREAM_PROPERTIES = ['stdin', 'stdout', 'stderr'];\n\n// Most `std*` option values involve piping `subprocess.std*` to a stream.\n// The stream is either passed by the user or created internally.\nconst pipeStdioItem = ({subprocess, stream, direction, fdNumber, pipeGroups, controller}) => {\n\tif (stream === undefined) {\n\t\treturn;\n\t}\n\n\tsetStandardStreamMaxListeners(stream, controller);\n\n\tconst [inputStream, outputStream] = direction === 'output'\n\t\t? [stream, subprocess.stdio[fdNumber]]\n\t\t: [subprocess.stdio[fdNumber], stream];\n\tconst outputStreams = pipeGroups.get(inputStream) ?? [];\n\tpipeGroups.set(inputStream, [...outputStreams, outputStream]);\n};\n\n// Multiple subprocesses might be piping from/to `process.std*` at the same time.\n// This is not necessarily an error and should not print a `maxListeners` warning.\nconst setStandardStreamMaxListeners = (stream, {signal}) => {\n\tif (isStandardStream(stream)) {\n\t\tincrementMaxListeners(stream, MAX_LISTENERS_INCREMENT, signal);\n\t}\n};\n\n// `source.pipe(destination)` adds at most 1 listener for each event.\n// If `stdin` option is an array, the values might be combined with `merge-streams`.\n// That library also listens for `source` end, which adds 1 more listener.\nconst MAX_LISTENERS_INCREMENT = 2;\n"
  },
  {
    "path": "lib/io/output-sync.js",
    "content": "import {writeFileSync, appendFileSync} from 'node:fs';\nimport {shouldLogOutput, logLinesSync} from '../verbose/output.js';\nimport {runGeneratorsSync} from '../transform/generator.js';\nimport {splitLinesSync} from '../transform/split.js';\nimport {joinToString, joinToUint8Array, bufferToUint8Array} from '../utils/uint-array.js';\nimport {FILE_TYPES} from '../stdio/type.js';\nimport {truncateMaxBufferSync} from './max-buffer.js';\n\n// Apply `stdout`/`stderr` options, after spawning, in sync mode\nexport const transformOutputSync = ({fileDescriptors, syncResult: {output}, options, isMaxBuffer, verboseInfo}) => {\n\tif (output === null) {\n\t\treturn {output: Array.from({length: 3})};\n\t}\n\n\tconst state = {};\n\tconst outputFiles = new Set([]);\n\tconst transformedOutput = output.map((result, fdNumber) =>\n\t\ttransformOutputResultSync({\n\t\t\tresult,\n\t\t\tfileDescriptors,\n\t\t\tfdNumber,\n\t\t\tstate,\n\t\t\toutputFiles,\n\t\t\tisMaxBuffer,\n\t\t\tverboseInfo,\n\t\t}, options));\n\treturn {output: transformedOutput, ...state};\n};\n\nconst transformOutputResultSync = (\n\t{result, fileDescriptors, fdNumber, state, outputFiles, isMaxBuffer, verboseInfo},\n\t{buffer, encoding, lines, stripFinalNewline, maxBuffer},\n) => {\n\tif (result === null) {\n\t\treturn;\n\t}\n\n\tconst truncatedResult = truncateMaxBufferSync(result, isMaxBuffer, maxBuffer);\n\tconst uint8ArrayResult = bufferToUint8Array(truncatedResult);\n\tconst {stdioItems, objectMode} = fileDescriptors[fdNumber];\n\tconst chunks = runOutputGeneratorsSync([uint8ArrayResult], stdioItems, encoding, state);\n\tconst {serializedResult, finalResult = serializedResult} = serializeChunks({\n\t\tchunks,\n\t\tobjectMode,\n\t\tencoding,\n\t\tlines,\n\t\tstripFinalNewline,\n\t\tfdNumber,\n\t});\n\n\tlogOutputSync({\n\t\tserializedResult,\n\t\tfdNumber,\n\t\tstate,\n\t\tverboseInfo,\n\t\tencoding,\n\t\tstdioItems,\n\t\tobjectMode,\n\t});\n\n\tconst returnedResult = buffer[fdNumber] ? finalResult : undefined;\n\n\ttry {\n\t\tif (state.error === undefined) {\n\t\t\twriteToFiles(serializedResult, stdioItems, outputFiles);\n\t\t}\n\n\t\treturn returnedResult;\n\t} catch (error) {\n\t\tstate.error = error;\n\t\treturn returnedResult;\n\t}\n};\n\n// Applies transform generators to `stdout`/`stderr`\nconst runOutputGeneratorsSync = (chunks, stdioItems, encoding, state) => {\n\ttry {\n\t\treturn runGeneratorsSync(chunks, stdioItems, encoding, false);\n\t} catch (error) {\n\t\tstate.error = error;\n\t\treturn chunks;\n\t}\n};\n\n// The contents is converted to three stages:\n//  - serializedResult: used when the target is a file path/URL or a file descriptor (including 'inherit')\n//  - finalResult/returnedResult: returned as `result.std*`\nconst serializeChunks = ({chunks, objectMode, encoding, lines, stripFinalNewline, fdNumber}) => {\n\tif (objectMode) {\n\t\treturn {serializedResult: chunks};\n\t}\n\n\tif (encoding === 'buffer') {\n\t\treturn {serializedResult: joinToUint8Array(chunks)};\n\t}\n\n\tconst serializedResult = joinToString(chunks, encoding);\n\tif (lines[fdNumber]) {\n\t\treturn {serializedResult, finalResult: splitLinesSync(serializedResult, !stripFinalNewline[fdNumber], objectMode)};\n\t}\n\n\treturn {serializedResult};\n};\n\nconst logOutputSync = ({serializedResult, fdNumber, state, verboseInfo, encoding, stdioItems, objectMode}) => {\n\tif (!shouldLogOutput({\n\t\tstdioItems,\n\t\tencoding,\n\t\tverboseInfo,\n\t\tfdNumber,\n\t})) {\n\t\treturn;\n\t}\n\n\tconst linesArray = splitLinesSync(serializedResult, false, objectMode);\n\n\ttry {\n\t\tlogLinesSync(linesArray, fdNumber, verboseInfo);\n\t} catch (error) {\n\t\tstate.error ??= error;\n\t}\n};\n\n// When the `std*` target is a file path/URL or a file descriptor\nconst writeToFiles = (serializedResult, stdioItems, outputFiles) => {\n\tfor (const {path, append} of stdioItems.filter(({type}) => FILE_TYPES.has(type))) {\n\t\tconst pathString = typeof path === 'string' ? path : path.toString();\n\t\tif (append || outputFiles.has(pathString)) {\n\t\t\tappendFileSync(path, serializedResult);\n\t\t} else {\n\t\t\toutputFiles.add(pathString);\n\t\t\twriteFileSync(path, serializedResult);\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "lib/io/pipeline.js",
    "content": "import {finished} from 'node:stream/promises';\nimport {isStandardStream} from '../utils/standard-stream.js';\n\n// Similar to `Stream.pipeline(source, destination)`, but does not destroy standard streams\nexport const pipeStreams = (source, destination) => {\n\tsource.pipe(destination);\n\tonSourceFinish(source, destination);\n\tonDestinationFinish(source, destination);\n};\n\n// `source.pipe(destination)` makes `destination` end when `source` ends.\n// But it does not propagate aborts or errors. This function does it.\nconst onSourceFinish = async (source, destination) => {\n\tif (isStandardStream(source) || isStandardStream(destination)) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait finished(source, {cleanup: true, readable: true, writable: false});\n\t} catch {}\n\n\tendDestinationStream(destination);\n};\n\nexport const endDestinationStream = destination => {\n\tif (destination.writable) {\n\t\tdestination.end();\n\t}\n};\n\n// We do the same thing in the other direction as well.\nconst onDestinationFinish = async (source, destination) => {\n\tif (isStandardStream(source) || isStandardStream(destination)) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait finished(destination, {cleanup: true, readable: false, writable: true});\n\t} catch {}\n\n\tabortSourceStream(source);\n};\n\nexport const abortSourceStream = source => {\n\tif (source.readable) {\n\t\tsource.destroy();\n\t}\n};\n"
  },
  {
    "path": "lib/io/strip-newline.js",
    "content": "import stripFinalNewlineFunction from 'strip-final-newline';\n\n// Apply `stripFinalNewline` option, which applies to `result.stdout|stderr|all|stdio[*]`.\n// If the `lines` option is used, it is applied on each line, but using a different function.\nexport const stripNewline = (value, {stripFinalNewline}, fdNumber) => getStripFinalNewline(stripFinalNewline, fdNumber) && value !== undefined && !Array.isArray(value)\n\t? stripFinalNewlineFunction(value)\n\t: value;\n\n// Retrieve `stripFinalNewline` option value, including with `subprocess.all`\nexport const getStripFinalNewline = (stripFinalNewline, fdNumber) => fdNumber === 'all'\n\t? stripFinalNewline[1] || stripFinalNewline[2]\n\t: stripFinalNewline[fdNumber];\n"
  },
  {
    "path": "lib/ipc/array.js",
    "content": "// The `ipc` option adds an `ipc` item to the `stdio` option\nexport const normalizeIpcStdioArray = (stdioArray, ipc) => ipc && !stdioArray.includes('ipc')\n\t? [...stdioArray, 'ipc']\n\t: stdioArray;\n"
  },
  {
    "path": "lib/ipc/buffer-messages.js",
    "content": "import {checkIpcMaxBuffer} from '../io/max-buffer.js';\nimport {shouldLogIpc, logIpcOutput} from '../verbose/ipc.js';\nimport {getFdSpecificValue} from '../arguments/specific.js';\nimport {loopOnMessages} from './get-each.js';\n\n// Iterate through IPC messages sent by the subprocess\nexport const waitForIpcOutput = async ({\n\tsubprocess,\n\tbuffer: bufferArray,\n\tmaxBuffer: maxBufferArray,\n\tipc,\n\tipcOutput,\n\tverboseInfo,\n}) => {\n\tif (!ipc) {\n\t\treturn ipcOutput;\n\t}\n\n\tconst isVerbose = shouldLogIpc(verboseInfo);\n\tconst buffer = getFdSpecificValue(bufferArray, 'ipc');\n\tconst maxBuffer = getFdSpecificValue(maxBufferArray, 'ipc');\n\n\tfor await (const message of loopOnMessages({\n\t\tanyProcess: subprocess,\n\t\tchannel: subprocess.channel,\n\t\tisSubprocess: false,\n\t\tipc,\n\t\tshouldAwait: false,\n\t\treference: true,\n\t})) {\n\t\tif (buffer) {\n\t\t\tcheckIpcMaxBuffer(subprocess, ipcOutput, maxBuffer);\n\t\t\tipcOutput.push(message);\n\t\t}\n\n\t\tif (isVerbose) {\n\t\t\tlogIpcOutput(message, verboseInfo);\n\t\t}\n\t}\n\n\treturn ipcOutput;\n};\n\nexport const getBufferedIpcOutput = async (ipcOutputPromise, ipcOutput) => {\n\tawait Promise.allSettled([ipcOutputPromise]);\n\treturn ipcOutput;\n};\n"
  },
  {
    "path": "lib/ipc/forward.js",
    "content": "import {EventEmitter} from 'node:events';\nimport {onMessage, onDisconnect} from './incoming.js';\nimport {undoAddedReferences} from './reference.js';\n\n// Forward the `message` and `disconnect` events from the process and subprocess to a proxy emitter.\n// This prevents the `error` event from stopping IPC.\n// This also allows debouncing the `message` event.\nexport const getIpcEmitter = (anyProcess, channel, isSubprocess) => {\n\tif (IPC_EMITTERS.has(anyProcess)) {\n\t\treturn IPC_EMITTERS.get(anyProcess);\n\t}\n\n\t// Use an `EventEmitter`, like the `process` that is being proxied\n\t// eslint-disable-next-line unicorn/prefer-event-target\n\tconst ipcEmitter = new EventEmitter();\n\tipcEmitter.connected = true;\n\tIPC_EMITTERS.set(anyProcess, ipcEmitter);\n\tforwardEvents({\n\t\tipcEmitter,\n\t\tanyProcess,\n\t\tchannel,\n\t\tisSubprocess,\n\t});\n\treturn ipcEmitter;\n};\n\nconst IPC_EMITTERS = new WeakMap();\n\n// The `message` and `disconnect` events are buffered in the subprocess until the first listener is setup.\n// However, unbuffering happens after one tick, so this give enough time for the caller to setup the listener on the proxy emitter first.\n// See https://github.com/nodejs/node/blob/2aaeaa863c35befa2ebaa98fb7737ec84df4d8e9/lib/internal/child_process.js#L721\nconst forwardEvents = ({ipcEmitter, anyProcess, channel, isSubprocess}) => {\n\tconst boundOnMessage = onMessage.bind(undefined, {\n\t\tanyProcess,\n\t\tchannel,\n\t\tisSubprocess,\n\t\tipcEmitter,\n\t});\n\tanyProcess.on('message', boundOnMessage);\n\tanyProcess.once('disconnect', onDisconnect.bind(undefined, {\n\t\tanyProcess,\n\t\tchannel,\n\t\tisSubprocess,\n\t\tipcEmitter,\n\t\tboundOnMessage,\n\t}));\n\tundoAddedReferences(channel, isSubprocess);\n};\n\n// Check whether there might still be some `message` events to receive\nexport const isConnected = anyProcess => {\n\tconst ipcEmitter = IPC_EMITTERS.get(anyProcess);\n\treturn ipcEmitter === undefined\n\t\t? anyProcess.channel !== null\n\t\t: ipcEmitter.connected;\n};\n"
  },
  {
    "path": "lib/ipc/get-each.js",
    "content": "import {once, on} from 'node:events';\nimport {validateIpcMethod, disconnect, getStrictResponseError} from './validation.js';\nimport {getIpcEmitter, isConnected} from './forward.js';\nimport {addReference, removeReference} from './reference.js';\n\n// Like `[sub]process.on('message')` but promise-based\nexport const getEachMessage = ({anyProcess, channel, isSubprocess, ipc}, {reference = true} = {}) => loopOnMessages({\n\tanyProcess,\n\tchannel,\n\tisSubprocess,\n\tipc,\n\tshouldAwait: !isSubprocess,\n\treference,\n});\n\n// Same but used internally\nexport const loopOnMessages = ({anyProcess, channel, isSubprocess, ipc, shouldAwait, reference}) => {\n\tvalidateIpcMethod({\n\t\tmethodName: 'getEachMessage',\n\t\tisSubprocess,\n\t\tipc,\n\t\tisConnected: isConnected(anyProcess),\n\t});\n\n\taddReference(channel, reference);\n\tconst ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);\n\tconst controller = new AbortController();\n\tconst state = {};\n\tstopOnDisconnect(anyProcess, ipcEmitter, controller);\n\tabortOnStrictError({\n\t\tipcEmitter,\n\t\tisSubprocess,\n\t\tcontroller,\n\t\tstate,\n\t});\n\treturn iterateOnMessages({\n\t\tanyProcess,\n\t\tchannel,\n\t\tipcEmitter,\n\t\tisSubprocess,\n\t\tshouldAwait,\n\t\tcontroller,\n\t\tstate,\n\t\treference,\n\t});\n};\n\nconst stopOnDisconnect = async (anyProcess, ipcEmitter, controller) => {\n\ttry {\n\t\tawait once(ipcEmitter, 'disconnect', {signal: controller.signal});\n\t\tcontroller.abort();\n\t} catch {}\n};\n\nconst abortOnStrictError = async ({ipcEmitter, isSubprocess, controller, state}) => {\n\ttry {\n\t\tconst [error] = await once(ipcEmitter, 'strict:error', {signal: controller.signal});\n\t\tstate.error = getStrictResponseError(error, isSubprocess);\n\t\tcontroller.abort();\n\t} catch {}\n};\n\nconst iterateOnMessages = async function * ({anyProcess, channel, ipcEmitter, isSubprocess, shouldAwait, controller, state, reference}) {\n\ttry {\n\t\tfor await (const [message] of on(ipcEmitter, 'message', {signal: controller.signal})) {\n\t\t\tthrowIfStrictError(state);\n\t\t\tyield message;\n\t\t}\n\t} catch {\n\t\tthrowIfStrictError(state);\n\t} finally {\n\t\tcontroller.abort();\n\t\tremoveReference(channel, reference);\n\n\t\tif (!isSubprocess) {\n\t\t\tdisconnect(anyProcess);\n\t\t}\n\n\t\tif (shouldAwait) {\n\t\t\tawait anyProcess;\n\t\t}\n\t}\n};\n\nconst throwIfStrictError = ({error}) => {\n\tif (error) {\n\t\tthrow error;\n\t}\n};\n"
  },
  {
    "path": "lib/ipc/get-one.js",
    "content": "import {once, on} from 'node:events';\nimport {\n\tvalidateIpcMethod,\n\tthrowOnEarlyDisconnect,\n\tdisconnect,\n\tgetStrictResponseError,\n} from './validation.js';\nimport {getIpcEmitter, isConnected} from './forward.js';\nimport {addReference, removeReference} from './reference.js';\n\n// Like `[sub]process.once('message')` but promise-based\nexport const getOneMessage = ({anyProcess, channel, isSubprocess, ipc}, {reference = true, filter} = {}) => {\n\tvalidateIpcMethod({\n\t\tmethodName: 'getOneMessage',\n\t\tisSubprocess,\n\t\tipc,\n\t\tisConnected: isConnected(anyProcess),\n\t});\n\n\treturn getOneMessageAsync({\n\t\tanyProcess,\n\t\tchannel,\n\t\tisSubprocess,\n\t\tfilter,\n\t\treference,\n\t});\n};\n\nconst getOneMessageAsync = async ({anyProcess, channel, isSubprocess, filter, reference}) => {\n\taddReference(channel, reference);\n\tconst ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);\n\tconst controller = new AbortController();\n\ttry {\n\t\treturn await Promise.race([\n\t\t\tgetMessage(ipcEmitter, filter, controller),\n\t\t\tthrowOnDisconnect(ipcEmitter, isSubprocess, controller),\n\t\t\tthrowOnStrictError(ipcEmitter, isSubprocess, controller),\n\t\t]);\n\t} catch (error) {\n\t\tdisconnect(anyProcess);\n\t\tthrow error;\n\t} finally {\n\t\tcontroller.abort();\n\t\tremoveReference(channel, reference);\n\t}\n};\n\nconst getMessage = async (ipcEmitter, filter, {signal}) => {\n\tif (filter === undefined) {\n\t\tconst [message] = await once(ipcEmitter, 'message', {signal});\n\t\treturn message;\n\t}\n\n\tfor await (const [message] of on(ipcEmitter, 'message', {signal})) {\n\t\tif (filter(message)) {\n\t\t\treturn message;\n\t\t}\n\t}\n};\n\nconst throwOnDisconnect = async (ipcEmitter, isSubprocess, {signal}) => {\n\tawait once(ipcEmitter, 'disconnect', {signal});\n\tthrowOnEarlyDisconnect(isSubprocess);\n};\n\nconst throwOnStrictError = async (ipcEmitter, isSubprocess, {signal}) => {\n\tconst [error] = await once(ipcEmitter, 'strict:error', {signal});\n\tthrow getStrictResponseError(error, isSubprocess);\n};\n"
  },
  {
    "path": "lib/ipc/graceful.js",
    "content": "import {scheduler} from 'node:timers/promises';\nimport {sendOneMessage} from './send.js';\nimport {getIpcEmitter} from './forward.js';\nimport {validateConnection, getAbortDisconnectError, throwOnMissingParent} from './validation.js';\n\n// Send an IPC message so the subprocess performs a graceful termination\nexport const sendAbort = (subprocess, message) => {\n\tconst methodName = 'cancelSignal';\n\tvalidateConnection(methodName, false, subprocess.connected);\n\treturn sendOneMessage({\n\t\tanyProcess: subprocess,\n\t\tmethodName,\n\t\tisSubprocess: false,\n\t\twrappedMessage: {type: GRACEFUL_CANCEL_TYPE, message},\n\t\tmessage,\n\t});\n};\n\n// When the signal is being used, start listening for incoming messages.\n// Unbuffering messages takes one microtask to complete, so this must be async.\nexport const getCancelSignal = async ({anyProcess, channel, isSubprocess, ipc}) => {\n\tawait startIpc({\n\t\tanyProcess,\n\t\tchannel,\n\t\tisSubprocess,\n\t\tipc,\n\t});\n\treturn cancelController.signal;\n};\n\nconst startIpc = async ({anyProcess, channel, isSubprocess, ipc}) => {\n\tif (cancelListening) {\n\t\treturn;\n\t}\n\n\tcancelListening = true;\n\n\tif (!ipc) {\n\t\tthrowOnMissingParent();\n\t\treturn;\n\t}\n\n\tif (channel === null) {\n\t\tabortOnDisconnect();\n\t\treturn;\n\t}\n\n\tgetIpcEmitter(anyProcess, channel, isSubprocess);\n\tawait scheduler.yield();\n};\n\nlet cancelListening = false;\n\n// Reception of IPC message to perform a graceful termination\nexport const handleAbort = wrappedMessage => {\n\tif (wrappedMessage?.type !== GRACEFUL_CANCEL_TYPE) {\n\t\treturn false;\n\t}\n\n\tcancelController.abort(wrappedMessage.message);\n\treturn true;\n};\n\nconst GRACEFUL_CANCEL_TYPE = 'execa:ipc:cancel';\n\n// When the current process disconnects early, the subprocess `cancelSignal` is aborted.\n// Otherwise, the signal would never be able to be aborted later on.\nexport const abortOnDisconnect = () => {\n\tcancelController.abort(getAbortDisconnectError());\n};\n\nconst cancelController = new AbortController();\n"
  },
  {
    "path": "lib/ipc/incoming.js",
    "content": "import {once} from 'node:events';\nimport {scheduler} from 'node:timers/promises';\nimport {waitForOutgoingMessages} from './outgoing.js';\nimport {redoAddedReferences} from './reference.js';\nimport {handleStrictRequest, handleStrictResponse} from './strict.js';\nimport {handleAbort, abortOnDisconnect} from './graceful.js';\n\n// By default, Node.js buffers `message` events.\n//  - Buffering happens when there is a `message` event is emitted but there is no handler.\n//  - As soon as a `message` event handler is set, all buffered `message` events are emitted, emptying the buffer.\n//  - This happens both in the current process and the subprocess.\n//  - See https://github.com/nodejs/node/blob/501546e8f37059cd577041e23941b640d0d4d406/lib/internal/child_process.js#L719\n// This is helpful. Notably, this allows sending messages to a subprocess that's still initializing.\n// However, it has several problems.\n//  - This works with `events.on()` but not `events.once()` since all buffered messages are emitted at once.\n//    For example, users cannot call `await getOneMessage()`/`getEachMessage()` multiple times in a row.\n//  - When a user intentionally starts listening to `message` at a specific point in time, past `message` events are replayed, which might be unexpected.\n//  - Buffering is unlimited, which might lead to an out-of-memory crash.\n//  - This does not work well with multiple consumers.\n//    For example, Execa consumes events with both `result.ipcOutput` and manual IPC calls like `getOneMessage()`.\n//    Since `result.ipcOutput` reads all incoming messages, no buffering happens for manual IPC calls.\n//  - Forgetting to setup a `message` listener, or setting it up too late, is a programming mistake.\n//    The default behavior does not allow users to realize they made that mistake.\n// To solve those problems, instead of buffering messages, we debounce them.\n// The `message` event so it is emitted at most once per macrotask.\nexport const onMessage = async ({anyProcess, channel, isSubprocess, ipcEmitter}, wrappedMessage) => {\n\tif (handleStrictResponse(wrappedMessage) || handleAbort(wrappedMessage)) {\n\t\treturn;\n\t}\n\n\tif (!INCOMING_MESSAGES.has(anyProcess)) {\n\t\tINCOMING_MESSAGES.set(anyProcess, []);\n\t}\n\n\tconst incomingMessages = INCOMING_MESSAGES.get(anyProcess);\n\tincomingMessages.push(wrappedMessage);\n\n\tif (incomingMessages.length > 1) {\n\t\treturn;\n\t}\n\n\twhile (incomingMessages.length > 0) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait waitForOutgoingMessages(anyProcess, ipcEmitter, wrappedMessage);\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait scheduler.yield();\n\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst message = await handleStrictRequest({\n\t\t\twrappedMessage: incomingMessages[0],\n\t\t\tanyProcess,\n\t\t\tchannel,\n\t\t\tisSubprocess,\n\t\t\tipcEmitter,\n\t\t});\n\n\t\tincomingMessages.shift();\n\t\tipcEmitter.emit('message', message);\n\t\tipcEmitter.emit('message:done');\n\t}\n};\n\n// If the `message` event is currently debounced, the `disconnect` event must wait for it\nexport const onDisconnect = async ({anyProcess, channel, isSubprocess, ipcEmitter, boundOnMessage}) => {\n\tabortOnDisconnect();\n\n\tconst incomingMessages = INCOMING_MESSAGES.get(anyProcess);\n\twhile (incomingMessages?.length > 0) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait once(ipcEmitter, 'message:done');\n\t}\n\n\tanyProcess.removeListener('message', boundOnMessage);\n\tredoAddedReferences(channel, isSubprocess);\n\tipcEmitter.connected = false;\n\tipcEmitter.emit('disconnect');\n};\n\nconst INCOMING_MESSAGES = new WeakMap();\n"
  },
  {
    "path": "lib/ipc/ipc-input.js",
    "content": "import {serialize} from 'node:v8';\n\n// Validate the `ipcInput` option\nexport const validateIpcInputOption = ({ipcInput, ipc, serialization}) => {\n\tif (ipcInput === undefined) {\n\t\treturn;\n\t}\n\n\tif (!ipc) {\n\t\tthrow new Error('The `ipcInput` option cannot be set unless the `ipc` option is `true`.');\n\t}\n\n\tvalidateIpcInput[serialization](ipcInput);\n};\n\nconst validateAdvancedInput = ipcInput => {\n\ttry {\n\t\tserialize(ipcInput);\n\t} catch (error) {\n\t\tthrow new Error('The `ipcInput` option is not serializable with a structured clone.', {cause: error});\n\t}\n};\n\nconst validateJsonInput = ipcInput => {\n\ttry {\n\t\tJSON.stringify(ipcInput);\n\t} catch (error) {\n\t\tthrow new Error('The `ipcInput` option is not serializable with JSON.', {cause: error});\n\t}\n};\n\nconst validateIpcInput = {\n\tadvanced: validateAdvancedInput,\n\tjson: validateJsonInput,\n};\n\n// When the `ipcInput` option is set, it is sent as an initial IPC message to the subprocess\nexport const sendIpcInput = async (subprocess, ipcInput) => {\n\tif (ipcInput === undefined) {\n\t\treturn;\n\t}\n\n\tawait subprocess.sendMessage(ipcInput);\n};\n"
  },
  {
    "path": "lib/ipc/methods.js",
    "content": "import process from 'node:process';\nimport {sendMessage} from './send.js';\nimport {getOneMessage} from './get-one.js';\nimport {getEachMessage} from './get-each.js';\nimport {getCancelSignal} from './graceful.js';\n\n// Add promise-based IPC methods in current process\nexport const addIpcMethods = (subprocess, {ipc}) => {\n\tObject.assign(subprocess, getIpcMethods(subprocess, false, ipc));\n};\n\n// Get promise-based IPC in the subprocess\nexport const getIpcExport = () => {\n\tconst anyProcess = process;\n\tconst isSubprocess = true;\n\tconst ipc = process.channel !== undefined;\n\n\treturn {\n\t\t...getIpcMethods(anyProcess, isSubprocess, ipc),\n\t\tgetCancelSignal: getCancelSignal.bind(undefined, {\n\t\t\tanyProcess,\n\t\t\tchannel: anyProcess.channel,\n\t\t\tisSubprocess,\n\t\t\tipc,\n\t\t}),\n\t};\n};\n\n// Retrieve the `ipc` shared by both the current process and the subprocess\nconst getIpcMethods = (anyProcess, isSubprocess, ipc) => ({\n\tsendMessage: sendMessage.bind(undefined, {\n\t\tanyProcess,\n\t\tchannel: anyProcess.channel,\n\t\tisSubprocess,\n\t\tipc,\n\t}),\n\tgetOneMessage: getOneMessage.bind(undefined, {\n\t\tanyProcess,\n\t\tchannel: anyProcess.channel,\n\t\tisSubprocess,\n\t\tipc,\n\t}),\n\tgetEachMessage: getEachMessage.bind(undefined, {\n\t\tanyProcess,\n\t\tchannel: anyProcess.channel,\n\t\tisSubprocess,\n\t\tipc,\n\t}),\n});\n"
  },
  {
    "path": "lib/ipc/outgoing.js",
    "content": "import {createDeferred} from '../utils/deferred.js';\nimport {getFdSpecificValue} from '../arguments/specific.js';\nimport {SUBPROCESS_OPTIONS} from '../arguments/fd-options.js';\nimport {validateStrictDeadlock} from './strict.js';\n\n// When `sendMessage()` is ongoing, any `message` being received waits before being emitted.\n// This allows calling one or multiple `await sendMessage()` followed by `await getOneMessage()`/`await getEachMessage()`.\n// Without running into a race condition when the other process sends a response too fast, before the current process set up a listener.\nexport const startSendMessage = (anyProcess, wrappedMessage, strict) => {\n\tif (!OUTGOING_MESSAGES.has(anyProcess)) {\n\t\tOUTGOING_MESSAGES.set(anyProcess, new Set());\n\t}\n\n\tconst outgoingMessages = OUTGOING_MESSAGES.get(anyProcess);\n\tconst onMessageSent = createDeferred();\n\tconst id = strict ? wrappedMessage.id : undefined;\n\tconst outgoingMessage = {onMessageSent, id};\n\toutgoingMessages.add(outgoingMessage);\n\treturn {outgoingMessages, outgoingMessage};\n};\n\nexport const endSendMessage = ({outgoingMessages, outgoingMessage}) => {\n\toutgoingMessages.delete(outgoingMessage);\n\toutgoingMessage.onMessageSent.resolve();\n};\n\n// Await while `sendMessage()` is ongoing, unless there is already a `message` listener\nexport const waitForOutgoingMessages = async (anyProcess, ipcEmitter, wrappedMessage) => {\n\twhile (!hasMessageListeners(anyProcess, ipcEmitter) && OUTGOING_MESSAGES.get(anyProcess)?.size > 0) {\n\t\tconst outgoingMessages = [...OUTGOING_MESSAGES.get(anyProcess)];\n\t\tvalidateStrictDeadlock(outgoingMessages, wrappedMessage);\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait Promise.all(outgoingMessages.map(({onMessageSent}) => onMessageSent));\n\t}\n};\n\nconst OUTGOING_MESSAGES = new WeakMap();\n\n// Whether any `message` listener is setup\nexport const hasMessageListeners = (anyProcess, ipcEmitter) => ipcEmitter.listenerCount('message') > getMinListenerCount(anyProcess);\n\n// When `buffer` is `false`, we set up a `message` listener that should be ignored.\n// That listener is only meant to intercept `strict` acknowledgement responses.\nconst getMinListenerCount = anyProcess => SUBPROCESS_OPTIONS.has(anyProcess)\n\t&& !getFdSpecificValue(SUBPROCESS_OPTIONS.get(anyProcess).options.buffer, 'ipc')\n\t? 1\n\t: 0;\n"
  },
  {
    "path": "lib/ipc/reference.js",
    "content": "// By default, Node.js keeps the subprocess alive while it has a `message` or `disconnect` listener.\n// We replicate the same logic for the events that we proxy.\n// This ensures the subprocess is kept alive while `getOneMessage()` and `getEachMessage()` are ongoing.\n// This is not a problem with `sendMessage()` since Node.js handles that method automatically.\n// We do not use `anyProcess.channel.ref()` since this would prevent the automatic `.channel.refCounted()` Node.js is doing.\n// We keep a reference to `anyProcess.channel` since it might be `null` while `getOneMessage()` or `getEachMessage()` is still processing debounced messages.\n// See https://github.com/nodejs/node/blob/2aaeaa863c35befa2ebaa98fb7737ec84df4d8e9/lib/internal/child_process.js#L547\nexport const addReference = (channel, reference) => {\n\tif (reference) {\n\t\taddReferenceCount(channel);\n\t}\n};\n\nconst addReferenceCount = channel => {\n\tchannel.refCounted();\n};\n\nexport const removeReference = (channel, reference) => {\n\tif (reference) {\n\t\tremoveReferenceCount(channel);\n\t}\n};\n\nconst removeReferenceCount = channel => {\n\tchannel.unrefCounted();\n};\n\n// To proxy events, we setup some global listeners on the `message` and `disconnect` events.\n// Those should not keep the subprocess alive, so we remove the automatic counting that Node.js is doing.\n// See https://github.com/nodejs/node/blob/1b965270a9c273d4cf70e8808e9d28b9ada7844f/lib/child_process.js#L180\nexport const undoAddedReferences = (channel, isSubprocess) => {\n\tif (isSubprocess) {\n\t\tremoveReferenceCount(channel);\n\t\tremoveReferenceCount(channel);\n\t}\n};\n\n// Reverse it during `disconnect`\nexport const redoAddedReferences = (channel, isSubprocess) => {\n\tif (isSubprocess) {\n\t\taddReferenceCount(channel);\n\t\taddReferenceCount(channel);\n\t}\n};\n"
  },
  {
    "path": "lib/ipc/send.js",
    "content": "import {promisify} from 'node:util';\nimport {\n\tvalidateIpcMethod,\n\thandleEpipeError,\n\thandleSerializationError,\n\tdisconnect,\n} from './validation.js';\nimport {startSendMessage, endSendMessage} from './outgoing.js';\nimport {handleSendStrict, waitForStrictResponse} from './strict.js';\n\n// Like `[sub]process.send()` but promise-based.\n// We do not `await subprocess` during `.sendMessage()` nor `.getOneMessage()` since those methods are transient.\n// Users would still need to `await subprocess` after the method is done.\n// Also, this would prevent `unhandledRejection` event from being emitted, making it silent.\nexport const sendMessage = ({anyProcess, channel, isSubprocess, ipc}, message, {strict = false} = {}) => {\n\tconst methodName = 'sendMessage';\n\tvalidateIpcMethod({\n\t\tmethodName,\n\t\tisSubprocess,\n\t\tipc,\n\t\tisConnected: anyProcess.connected,\n\t});\n\n\treturn sendMessageAsync({\n\t\tanyProcess,\n\t\tchannel,\n\t\tmethodName,\n\t\tisSubprocess,\n\t\tmessage,\n\t\tstrict,\n\t});\n};\n\nconst sendMessageAsync = async ({anyProcess, channel, methodName, isSubprocess, message, strict}) => {\n\tconst wrappedMessage = handleSendStrict({\n\t\tanyProcess,\n\t\tchannel,\n\t\tisSubprocess,\n\t\tmessage,\n\t\tstrict,\n\t});\n\tconst outgoingMessagesState = startSendMessage(anyProcess, wrappedMessage, strict);\n\ttry {\n\t\tawait sendOneMessage({\n\t\t\tanyProcess,\n\t\t\tmethodName,\n\t\t\tisSubprocess,\n\t\t\twrappedMessage,\n\t\t\tmessage,\n\t\t});\n\t} catch (error) {\n\t\tdisconnect(anyProcess);\n\t\tthrow error;\n\t} finally {\n\t\tendSendMessage(outgoingMessagesState);\n\t}\n};\n\n// Used internally by `cancelSignal`\nexport const sendOneMessage = async ({anyProcess, methodName, isSubprocess, wrappedMessage, message}) => {\n\tconst sendMethod = getSendMethod(anyProcess);\n\n\ttry {\n\t\tawait Promise.all([\n\t\t\twaitForStrictResponse(wrappedMessage, anyProcess, isSubprocess),\n\t\t\tsendMethod(wrappedMessage),\n\t\t]);\n\t} catch (error) {\n\t\thandleEpipeError({error, methodName, isSubprocess});\n\t\thandleSerializationError({\n\t\t\terror,\n\t\t\tmethodName,\n\t\t\tisSubprocess,\n\t\t\tmessage,\n\t\t});\n\t\tthrow error;\n\t}\n};\n\n// [sub]process.send() promisified, memoized\nconst getSendMethod = anyProcess => {\n\tif (PROCESS_SEND_METHODS.has(anyProcess)) {\n\t\treturn PROCESS_SEND_METHODS.get(anyProcess);\n\t}\n\n\tconst sendMethod = promisify(anyProcess.send.bind(anyProcess));\n\tPROCESS_SEND_METHODS.set(anyProcess, sendMethod);\n\treturn sendMethod;\n};\n\nconst PROCESS_SEND_METHODS = new WeakMap();\n"
  },
  {
    "path": "lib/ipc/strict.js",
    "content": "import {once} from 'node:events';\nimport {createDeferred} from '../utils/deferred.js';\nimport {incrementMaxListeners} from '../utils/max-listeners.js';\nimport {sendMessage} from './send.js';\nimport {throwOnMissingStrict, throwOnStrictDisconnect, throwOnStrictDeadlockError} from './validation.js';\nimport {getIpcEmitter} from './forward.js';\nimport {hasMessageListeners} from './outgoing.js';\n\n// When using the `strict` option, wrap the message with metadata during `sendMessage()`\nexport const handleSendStrict = ({anyProcess, channel, isSubprocess, message, strict}) => {\n\tif (!strict) {\n\t\treturn message;\n\t}\n\n\tconst ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);\n\tconst hasListeners = hasMessageListeners(anyProcess, ipcEmitter);\n\treturn {\n\t\tid: count++,\n\t\ttype: REQUEST_TYPE,\n\t\tmessage,\n\t\thasListeners,\n\t};\n};\n\nlet count = 0n;\n\n// Handles when both processes are calling `sendMessage()` with `strict` at the same time.\n// If neither process is listening, this would create a deadlock. We detect it and throw.\nexport const validateStrictDeadlock = (outgoingMessages, wrappedMessage) => {\n\tif (wrappedMessage?.type !== REQUEST_TYPE || wrappedMessage.hasListeners) {\n\t\treturn;\n\t}\n\n\tfor (const {id} of outgoingMessages) {\n\t\tif (id !== undefined) {\n\t\t\tSTRICT_RESPONSES[id].resolve({isDeadlock: true, hasListeners: false});\n\t\t}\n\t}\n};\n\n// The other process then sends the acknowledgment back as a response\nexport const handleStrictRequest = async ({wrappedMessage, anyProcess, channel, isSubprocess, ipcEmitter}) => {\n\tif (wrappedMessage?.type !== REQUEST_TYPE || !anyProcess.connected) {\n\t\treturn wrappedMessage;\n\t}\n\n\tconst {id, message} = wrappedMessage;\n\tconst response = {id, type: RESPONSE_TYPE, message: hasMessageListeners(anyProcess, ipcEmitter)};\n\n\ttry {\n\t\tawait sendMessage({\n\t\t\tanyProcess,\n\t\t\tchannel,\n\t\t\tisSubprocess,\n\t\t\tipc: true,\n\t\t}, response);\n\t} catch (error) {\n\t\tipcEmitter.emit('strict:error', error);\n\t}\n\n\treturn message;\n};\n\n// Reception of the acknowledgment response\nexport const handleStrictResponse = wrappedMessage => {\n\tif (wrappedMessage?.type !== RESPONSE_TYPE) {\n\t\treturn false;\n\t}\n\n\tconst {id, message: hasListeners} = wrappedMessage;\n\tSTRICT_RESPONSES[id]?.resolve({isDeadlock: false, hasListeners});\n\treturn true;\n};\n\n// Wait for the other process to receive the message from `sendMessage()`\nexport const waitForStrictResponse = async (wrappedMessage, anyProcess, isSubprocess) => {\n\tif (wrappedMessage?.type !== REQUEST_TYPE) {\n\t\treturn;\n\t}\n\n\tconst deferred = createDeferred();\n\tSTRICT_RESPONSES[wrappedMessage.id] = deferred;\n\tconst controller = new AbortController();\n\n\ttry {\n\t\tconst {isDeadlock, hasListeners} = await Promise.race([\n\t\t\tdeferred,\n\t\t\tthrowOnDisconnect(anyProcess, isSubprocess, controller),\n\t\t]);\n\n\t\tif (isDeadlock) {\n\t\t\tthrowOnStrictDeadlockError(isSubprocess);\n\t\t}\n\n\t\tif (!hasListeners) {\n\t\t\tthrowOnMissingStrict(isSubprocess);\n\t\t}\n\t} finally {\n\t\tcontroller.abort();\n\t\tdelete STRICT_RESPONSES[wrappedMessage.id];\n\t}\n};\n\nconst STRICT_RESPONSES = {};\n\nconst throwOnDisconnect = async (anyProcess, isSubprocess, {signal}) => {\n\tincrementMaxListeners(anyProcess, 1, signal);\n\tawait once(anyProcess, 'disconnect', {signal});\n\tthrowOnStrictDisconnect(isSubprocess);\n};\n\nconst REQUEST_TYPE = 'execa:ipc:request';\nconst RESPONSE_TYPE = 'execa:ipc:response';\n"
  },
  {
    "path": "lib/ipc/validation.js",
    "content": "// Validate the IPC channel is connected before receiving/sending messages\nexport const validateIpcMethod = ({methodName, isSubprocess, ipc, isConnected}) => {\n\tvalidateIpcOption(methodName, isSubprocess, ipc);\n\tvalidateConnection(methodName, isSubprocess, isConnected);\n};\n\n// Better error message when forgetting to set `ipc: true` and using the IPC methods\nconst validateIpcOption = (methodName, isSubprocess, ipc) => {\n\tif (!ipc) {\n\t\tthrow new Error(`${getMethodName(methodName, isSubprocess)} can only be used if the \\`ipc\\` option is \\`true\\`.`);\n\t}\n};\n\n// Better error message when one process does not send/receive messages once the other process has disconnected.\n// This also makes it clear that any buffered messages are lost once either process has disconnected.\n// Also when aborting `cancelSignal` after disconnecting the IPC.\nexport const validateConnection = (methodName, isSubprocess, isConnected) => {\n\tif (!isConnected) {\n\t\tthrow new Error(`${getMethodName(methodName, isSubprocess)} cannot be used: the ${getOtherProcessName(isSubprocess)} has already exited or disconnected.`);\n\t}\n};\n\n// When `getOneMessage()` could not complete due to an early disconnection\nexport const throwOnEarlyDisconnect = isSubprocess => {\n\tthrow new Error(`${getMethodName('getOneMessage', isSubprocess)} could not complete: the ${getOtherProcessName(isSubprocess)} exited or disconnected.`);\n};\n\n// When both processes use `sendMessage()` with `strict` at the same time\nexport const throwOnStrictDeadlockError = isSubprocess => {\n\tthrow new Error(`${getMethodName('sendMessage', isSubprocess)} failed: the ${getOtherProcessName(isSubprocess)} is sending a message too, instead of listening to incoming messages.\nThis can be fixed by both sending a message and listening to incoming messages at the same time:\n\nconst [receivedMessage] = await Promise.all([\n\t${getMethodName('getOneMessage', isSubprocess)},\n\t${getMethodName('sendMessage', isSubprocess, 'message, {strict: true}')},\n]);`);\n};\n\n// When the other process used `strict` but the current process had I/O error calling `sendMessage()` for the response\nexport const getStrictResponseError = (error, isSubprocess) => new Error(`${getMethodName('sendMessage', isSubprocess)} failed when sending an acknowledgment response to the ${getOtherProcessName(isSubprocess)}.`, {cause: error});\n\n// When using `strict` but the other process was not listening for messages\nexport const throwOnMissingStrict = isSubprocess => {\n\tthrow new Error(`${getMethodName('sendMessage', isSubprocess)} failed: the ${getOtherProcessName(isSubprocess)} is not listening to incoming messages.`);\n};\n\n// When using `strict` but the other process disconnected before receiving the message\nexport const throwOnStrictDisconnect = isSubprocess => {\n\tthrow new Error(`${getMethodName('sendMessage', isSubprocess)} failed: the ${getOtherProcessName(isSubprocess)} exited without listening to incoming messages.`);\n};\n\n// When the current process disconnects while the subprocess is listening to `cancelSignal`\nexport const getAbortDisconnectError = () => new Error(`\\`cancelSignal\\` aborted: the ${getOtherProcessName(true)} disconnected.`);\n\n// When the subprocess uses `cancelSignal` but not the current process\nexport const throwOnMissingParent = () => {\n\tthrow new Error('`getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.');\n};\n\n// EPIPE can happen when sending a message to a subprocess that is closing but has not disconnected yet\nexport const handleEpipeError = ({error, methodName, isSubprocess}) => {\n\tif (error.code === 'EPIPE') {\n\t\tthrow new Error(`${getMethodName(methodName, isSubprocess)} cannot be used: the ${getOtherProcessName(isSubprocess)} is disconnecting.`, {cause: error});\n\t}\n};\n\n// Better error message when sending messages which cannot be serialized.\n// Works with both `serialization: 'advanced'` and `serialization: 'json'`.\nexport const handleSerializationError = ({error, methodName, isSubprocess, message}) => {\n\tif (isSerializationError(error)) {\n\t\tthrow new Error(`${getMethodName(methodName, isSubprocess)}'s argument type is invalid: the message cannot be serialized: ${String(message)}.`, {cause: error});\n\t}\n};\n\nconst isSerializationError = ({code, message}) => SERIALIZATION_ERROR_CODES.has(code)\n\t|| SERIALIZATION_ERROR_MESSAGES.some(serializationErrorMessage => message.includes(serializationErrorMessage));\n\n// `error.code` set by Node.js when it failed to serialize the message\nconst SERIALIZATION_ERROR_CODES = new Set([\n\t// Message is `undefined`\n\t'ERR_MISSING_ARGS',\n\t// Message is a function, a bigint, a symbol\n\t'ERR_INVALID_ARG_TYPE',\n]);\n\n// `error.message` set by Node.js when it failed to serialize the message\nconst SERIALIZATION_ERROR_MESSAGES = [\n\t// Message is a promise or a proxy, with `serialization: 'advanced'`\n\t'could not be cloned',\n\t// Message has cycles, with `serialization: 'json'`\n\t'circular structure',\n\t// Message has cycles inside toJSON(), with `serialization: 'json'`\n\t'call stack size exceeded',\n];\n\nconst getMethodName = (methodName, isSubprocess, parameters = '') => methodName === 'cancelSignal'\n\t? '`cancelSignal`\\'s `controller.abort()`'\n\t: `${getNamespaceName(isSubprocess)}${methodName}(${parameters})`;\n\nconst getNamespaceName = isSubprocess => isSubprocess ? '' : 'subprocess.';\n\nconst getOtherProcessName = isSubprocess => isSubprocess ? 'parent process' : 'subprocess';\n\n// When any error arises, we disconnect the IPC.\n// Otherwise, it is likely that one of the processes will stop sending/receiving messages.\n// This would leave the other process hanging.\nexport const disconnect = anyProcess => {\n\tif (anyProcess.connected) {\n\t\tanyProcess.disconnect();\n\t}\n};\n"
  },
  {
    "path": "lib/methods/bind.js",
    "content": "import isPlainObject from 'is-plain-obj';\nimport {FD_SPECIFIC_OPTIONS} from '../arguments/specific.js';\n\n// Deep merge specific options like `env`. Shallow merge the other ones.\n// Use spread (which only copies own properties) to safely read from boundOptions without prototype pollution\nexport const mergeOptions = (boundOptions, options) => {\n\tconst safeBoundOptions = {__proto__: null, ...boundOptions};\n\tconst mergedOptions = Object.fromEntries(\n\t\tObject.entries(options).map(([optionName, optionValue]) => [\n\t\t\toptionName,\n\t\t\tmergeOption(optionName, safeBoundOptions[optionName], optionValue),\n\t\t]),\n\t);\n\treturn {...safeBoundOptions, ...mergedOptions};\n};\n\nconst mergeOption = (optionName, boundOptionValue, optionValue) => {\n\tif (DEEP_OPTIONS.has(optionName) && isPlainObject(boundOptionValue) && isPlainObject(optionValue)) {\n\t\treturn {...boundOptionValue, ...optionValue};\n\t}\n\n\treturn optionValue;\n};\n\nconst DEEP_OPTIONS = new Set(['env', ...FD_SPECIFIC_OPTIONS]);\n"
  },
  {
    "path": "lib/methods/command.js",
    "content": "// Main logic for `execaCommand()`\nexport const mapCommandAsync = ({file, commandArguments}) => parseCommand(file, commandArguments);\n\n// Main logic for `execaCommandSync()`\nexport const mapCommandSync = ({file, commandArguments}) => ({...parseCommand(file, commandArguments), isSync: true});\n\n// Convert `execaCommand(command)` into `execa(file, ...commandArguments)`\nconst parseCommand = (command, unusedArguments) => {\n\tif (unusedArguments.length > 0) {\n\t\tthrow new TypeError(`The command and its arguments must be passed as a single string: ${command} ${unusedArguments}.`);\n\t}\n\n\tconst [file, ...commandArguments] = parseCommandString(command);\n\treturn {file, commandArguments};\n};\n\n// Convert `command` string into an array of file or arguments to pass to $`${...fileOrCommandArguments}`\nexport const parseCommandString = command => {\n\tif (typeof command !== 'string') {\n\t\tthrow new TypeError(`The command must be a string: ${String(command)}.`);\n\t}\n\n\tconst trimmedCommand = command.trim();\n\tif (trimmedCommand === '') {\n\t\treturn [];\n\t}\n\n\tconst tokens = [];\n\tfor (const token of trimmedCommand.split(SPACES_REGEXP)) {\n\t\t// Allow spaces to be escaped by a backslash if not meant as a delimiter\n\t\tconst previousToken = tokens.at(-1);\n\t\tif (previousToken && previousToken.endsWith('\\\\')) {\n\t\t\t// Merge previous token with current one\n\t\t\ttokens[tokens.length - 1] = `${previousToken.slice(0, -1)} ${token}`;\n\t\t} else {\n\t\t\ttokens.push(token);\n\t\t}\n\t}\n\n\treturn tokens;\n};\n\nconst SPACES_REGEXP = / +/g;\n"
  },
  {
    "path": "lib/methods/create.js",
    "content": "import isPlainObject from 'is-plain-obj';\nimport {normalizeParameters} from './parameters.js';\nimport {isTemplateString, parseTemplates} from './template.js';\nimport {execaCoreSync} from './main-sync.js';\nimport {execaCoreAsync} from './main-async.js';\nimport {mergeOptions} from './bind.js';\n\n// Wraps every exported methods to provide the following features:\n//  - template string syntax: execa`command argument`\n//  - options binding: boundExeca = execa(options)\n//  - optional argument/options: execa(file), execa(file, args), execa(file, options), execa(file, args, options)\n// `mapArguments()` and `setBoundExeca()` allows for method-specific logic.\nexport const createExeca = (mapArguments, boundOptions, deepOptions, setBoundExeca) => {\n\tconst createNested = (mapArguments, boundOptions, setBoundExeca) => createExeca(mapArguments, boundOptions, deepOptions, setBoundExeca);\n\tconst boundExeca = (...execaArguments) => callBoundExeca({\n\t\tmapArguments,\n\t\tdeepOptions,\n\t\tboundOptions,\n\t\tsetBoundExeca,\n\t\tcreateNested,\n\t}, ...execaArguments);\n\n\tif (setBoundExeca !== undefined) {\n\t\tsetBoundExeca(boundExeca, createNested, boundOptions);\n\t}\n\n\treturn boundExeca;\n};\n\nconst callBoundExeca = ({mapArguments, deepOptions = {}, boundOptions = {}, setBoundExeca, createNested}, firstArgument, ...nextArguments) => {\n\tif (isPlainObject(firstArgument)) {\n\t\treturn createNested(mapArguments, mergeOptions(boundOptions, firstArgument), setBoundExeca);\n\t}\n\n\tconst {file, commandArguments, options, isSync} = parseArguments({\n\t\tmapArguments,\n\t\tfirstArgument,\n\t\tnextArguments,\n\t\tdeepOptions,\n\t\tboundOptions,\n\t});\n\treturn isSync\n\t\t? execaCoreSync(file, commandArguments, options)\n\t\t: execaCoreAsync(file, commandArguments, options, createNested);\n};\n\nconst parseArguments = ({mapArguments, firstArgument, nextArguments, deepOptions, boundOptions}) => {\n\tconst callArguments = isTemplateString(firstArgument)\n\t\t? parseTemplates(firstArgument, nextArguments)\n\t\t: [firstArgument, ...nextArguments];\n\tconst [initialFile, initialArguments, initialOptions] = normalizeParameters(...callArguments);\n\tconst mergedOptions = mergeOptions(mergeOptions(deepOptions, boundOptions), initialOptions);\n\tconst {\n\t\tfile = initialFile,\n\t\tcommandArguments = initialArguments,\n\t\toptions = mergedOptions,\n\t\tisSync = false,\n\t} = mapArguments({file: initialFile, commandArguments: initialArguments, options: mergedOptions});\n\treturn {\n\t\tfile,\n\t\tcommandArguments,\n\t\toptions,\n\t\tisSync,\n\t};\n};\n"
  },
  {
    "path": "lib/methods/main-async.js",
    "content": "import {setMaxListeners} from 'node:events';\nimport {spawn} from 'node:child_process';\nimport {MaxBufferError} from 'get-stream';\nimport {handleCommand} from '../arguments/command.js';\nimport {normalizeOptions} from '../arguments/options.js';\nimport {SUBPROCESS_OPTIONS} from '../arguments/fd-options.js';\nimport {concatenateShell} from '../arguments/shell.js';\nimport {addIpcMethods} from '../ipc/methods.js';\nimport {makeError, makeSuccessResult} from '../return/result.js';\nimport {handleResult} from '../return/reject.js';\nimport {handleEarlyError} from '../return/early-error.js';\nimport {handleStdioAsync} from '../stdio/handle-async.js';\nimport {stripNewline} from '../io/strip-newline.js';\nimport {pipeOutputAsync} from '../io/output-async.js';\nimport {subprocessKill} from '../terminate/kill.js';\nimport {cleanupOnExit} from '../terminate/cleanup.js';\nimport {pipeToSubprocess} from '../pipe/setup.js';\nimport {makeAllStream} from '../resolve/all-async.js';\nimport {waitForSubprocessResult} from '../resolve/wait-subprocess.js';\nimport {addConvertedStreams} from '../convert/add.js';\nimport {createDeferred} from '../utils/deferred.js';\nimport {mergePromise} from './promise.js';\n\n// Main shared logic for all async methods: `execa()`, `$`, `execaNode()`\nexport const execaCoreAsync = (rawFile, rawArguments, rawOptions, createNested) => {\n\tconst {file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleAsyncArguments(rawFile, rawArguments, rawOptions);\n\tconst {subprocess, promise} = spawnSubprocessAsync({\n\t\tfile,\n\t\tcommandArguments,\n\t\toptions,\n\t\tstartTime,\n\t\tverboseInfo,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tfileDescriptors,\n\t});\n\tsubprocess.pipe = pipeToSubprocess.bind(undefined, {\n\t\tsource: subprocess,\n\t\tsourcePromise: promise,\n\t\tboundOptions: {},\n\t\tcreateNested,\n\t});\n\tmergePromise(subprocess, promise);\n\tSUBPROCESS_OPTIONS.set(subprocess, {options, fileDescriptors});\n\treturn subprocess;\n};\n\n// Compute arguments to pass to `child_process.spawn()`\nconst handleAsyncArguments = (rawFile, rawArguments, rawOptions) => {\n\tconst {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArguments, rawOptions);\n\tconst {file, commandArguments, options: normalizedOptions} = normalizeOptions(rawFile, rawArguments, rawOptions);\n\tconst options = handleAsyncOptions(normalizedOptions);\n\tconst fileDescriptors = handleStdioAsync(options, verboseInfo);\n\treturn {\n\t\tfile,\n\t\tcommandArguments,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstartTime,\n\t\tverboseInfo,\n\t\toptions,\n\t\tfileDescriptors,\n\t};\n};\n\n// Options normalization logic specific to async methods.\n// Prevent passing the `timeout` option directly to `child_process.spawn()`.\nconst handleAsyncOptions = ({timeout, signal, ...options}) => {\n\tif (signal !== undefined) {\n\t\tthrow new TypeError('The \"signal\" option has been renamed to \"cancelSignal\" instead.');\n\t}\n\n\treturn {...options, timeoutDuration: timeout};\n};\n\nconst spawnSubprocessAsync = ({file, commandArguments, options, startTime, verboseInfo, command, escapedCommand, fileDescriptors}) => {\n\tlet subprocess;\n\ttry {\n\t\tsubprocess = spawn(...concatenateShell(file, commandArguments, options));\n\t} catch (error) {\n\t\treturn handleEarlyError({\n\t\t\terror,\n\t\t\tcommand,\n\t\t\tescapedCommand,\n\t\t\tfileDescriptors,\n\t\t\toptions,\n\t\t\tstartTime,\n\t\t\tverboseInfo,\n\t\t});\n\t}\n\n\tconst controller = new AbortController();\n\tsetMaxListeners(Number.POSITIVE_INFINITY, controller.signal);\n\n\tconst originalStreams = [...subprocess.stdio];\n\tpipeOutputAsync(subprocess, fileDescriptors, controller);\n\tcleanupOnExit(subprocess, options, controller);\n\n\tconst context = {};\n\tconst onInternalError = createDeferred();\n\tsubprocess.kill = subprocessKill.bind(undefined, {\n\t\tkill: subprocess.kill.bind(subprocess),\n\t\toptions,\n\t\tonInternalError,\n\t\tcontext,\n\t\tcontroller,\n\t});\n\tsubprocess.all = makeAllStream(subprocess, options);\n\taddConvertedStreams(subprocess, options);\n\taddIpcMethods(subprocess, options);\n\n\tconst promise = handlePromise({\n\t\tsubprocess,\n\t\toptions,\n\t\tstartTime,\n\t\tverboseInfo,\n\t\tfileDescriptors,\n\t\toriginalStreams,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tcontext,\n\t\tonInternalError,\n\t\tcontroller,\n\t});\n\treturn {subprocess, promise};\n};\n\n// Asynchronous logic, as opposed to the previous logic which can be run synchronously, i.e. can be returned to user right away\nconst handlePromise = async ({subprocess, options, startTime, verboseInfo, fileDescriptors, originalStreams, command, escapedCommand, context, onInternalError, controller}) => {\n\tconst [\n\t\terrorInfo,\n\t\t[exitCode, signal],\n\t\tstdioResults,\n\t\tallResult,\n\t\tipcOutput,\n\t] = await waitForSubprocessResult({\n\t\tsubprocess,\n\t\toptions,\n\t\tcontext,\n\t\tverboseInfo,\n\t\tfileDescriptors,\n\t\toriginalStreams,\n\t\tonInternalError,\n\t\tcontroller,\n\t});\n\tcontroller.abort();\n\tonInternalError.resolve();\n\n\tconst stdio = stdioResults.map((stdioResult, fdNumber) => stripNewline(stdioResult, options, fdNumber));\n\tconst all = stripNewline(allResult, options, 'all');\n\tconst result = getAsyncResult({\n\t\terrorInfo,\n\t\texitCode,\n\t\tsignal,\n\t\tstdio,\n\t\tall,\n\t\tipcOutput,\n\t\tcontext,\n\t\toptions,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstartTime,\n\t});\n\treturn handleResult(result, verboseInfo, options);\n};\n\nconst getAsyncResult = ({errorInfo, exitCode, signal, stdio, all, ipcOutput, context, options, command, escapedCommand, startTime}) => 'error' in errorInfo\n\t? makeError({\n\t\terror: errorInfo.error,\n\t\tcommand,\n\t\tescapedCommand,\n\t\ttimedOut: context.terminationReason === 'timeout',\n\t\tisCanceled: context.terminationReason === 'cancel' || context.terminationReason === 'gracefulCancel',\n\t\tisGracefullyCanceled: context.terminationReason === 'gracefulCancel',\n\t\tisMaxBuffer: errorInfo.error instanceof MaxBufferError,\n\t\tisForcefullyTerminated: context.isForcefullyTerminated,\n\t\texitCode,\n\t\tsignal,\n\t\tstdio,\n\t\tall,\n\t\tipcOutput,\n\t\toptions,\n\t\tstartTime,\n\t\tisSync: false,\n\t})\n\t: makeSuccessResult({\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstdio,\n\t\tall,\n\t\tipcOutput,\n\t\toptions,\n\t\tstartTime,\n\t});\n"
  },
  {
    "path": "lib/methods/main-sync.js",
    "content": "import {spawnSync} from 'node:child_process';\nimport {handleCommand} from '../arguments/command.js';\nimport {normalizeOptions} from '../arguments/options.js';\nimport {concatenateShell} from '../arguments/shell.js';\nimport {makeError, makeEarlyError, makeSuccessResult} from '../return/result.js';\nimport {handleResult} from '../return/reject.js';\nimport {handleStdioSync} from '../stdio/handle-sync.js';\nimport {stripNewline} from '../io/strip-newline.js';\nimport {addInputOptionsSync} from '../io/input-sync.js';\nimport {transformOutputSync} from '../io/output-sync.js';\nimport {getMaxBufferSync} from '../io/max-buffer.js';\nimport {getAllSync} from '../resolve/all-sync.js';\nimport {getExitResultSync} from '../resolve/exit-sync.js';\n\n// Main shared logic for all sync methods: `execaSync()`, `$.sync()`\nexport const execaCoreSync = (rawFile, rawArguments, rawOptions) => {\n\tconst {file, commandArguments, command, escapedCommand, startTime, verboseInfo, options, fileDescriptors} = handleSyncArguments(rawFile, rawArguments, rawOptions);\n\tconst result = spawnSubprocessSync({\n\t\tfile,\n\t\tcommandArguments,\n\t\toptions,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tverboseInfo,\n\t\tfileDescriptors,\n\t\tstartTime,\n\t});\n\treturn handleResult(result, verboseInfo, options);\n};\n\n// Compute arguments to pass to `child_process.spawnSync()`\nconst handleSyncArguments = (rawFile, rawArguments, rawOptions) => {\n\tconst {command, escapedCommand, startTime, verboseInfo} = handleCommand(rawFile, rawArguments, rawOptions);\n\tconst syncOptions = normalizeSyncOptions(rawOptions);\n\tconst {file, commandArguments, options} = normalizeOptions(rawFile, rawArguments, syncOptions);\n\tvalidateSyncOptions(options);\n\tconst fileDescriptors = handleStdioSync(options, verboseInfo);\n\treturn {\n\t\tfile,\n\t\tcommandArguments,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstartTime,\n\t\tverboseInfo,\n\t\toptions,\n\t\tfileDescriptors,\n\t};\n};\n\n// Options normalization logic specific to sync methods\nconst normalizeSyncOptions = options => options.node && !options.ipc ? {...options, ipc: false} : options;\n\n// Options validation logic specific to sync methods\nconst validateSyncOptions = ({ipc, ipcInput, detached, cancelSignal}) => {\n\tif (ipcInput) {\n\t\tthrowInvalidSyncOption('ipcInput');\n\t}\n\n\tif (ipc) {\n\t\tthrowInvalidSyncOption('ipc: true');\n\t}\n\n\tif (detached) {\n\t\tthrowInvalidSyncOption('detached: true');\n\t}\n\n\tif (cancelSignal) {\n\t\tthrowInvalidSyncOption('cancelSignal');\n\t}\n};\n\nconst throwInvalidSyncOption = value => {\n\tthrow new TypeError(`The \"${value}\" option cannot be used with synchronous methods.`);\n};\n\nconst spawnSubprocessSync = ({file, commandArguments, options, command, escapedCommand, verboseInfo, fileDescriptors, startTime}) => {\n\tconst syncResult = runSubprocessSync({\n\t\tfile,\n\t\tcommandArguments,\n\t\toptions,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tfileDescriptors,\n\t\tstartTime,\n\t});\n\tif (syncResult.failed) {\n\t\treturn syncResult;\n\t}\n\n\tconst {resultError, exitCode, signal, timedOut, isMaxBuffer} = getExitResultSync(syncResult, options);\n\tconst {output, error = resultError} = transformOutputSync({\n\t\tfileDescriptors,\n\t\tsyncResult,\n\t\toptions,\n\t\tisMaxBuffer,\n\t\tverboseInfo,\n\t});\n\tconst stdio = output.map((stdioOutput, fdNumber) => stripNewline(stdioOutput, options, fdNumber));\n\tconst all = stripNewline(getAllSync(output, options), options, 'all');\n\treturn getSyncResult({\n\t\terror,\n\t\texitCode,\n\t\tsignal,\n\t\ttimedOut,\n\t\tisMaxBuffer,\n\t\tstdio,\n\t\tall,\n\t\toptions,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstartTime,\n\t});\n};\n\nconst runSubprocessSync = ({file, commandArguments, options, command, escapedCommand, fileDescriptors, startTime}) => {\n\ttry {\n\t\taddInputOptionsSync(fileDescriptors, options);\n\t\tconst normalizedOptions = normalizeSpawnSyncOptions(options);\n\t\treturn spawnSync(...concatenateShell(file, commandArguments, normalizedOptions));\n\t} catch (error) {\n\t\treturn makeEarlyError({\n\t\t\terror,\n\t\t\tcommand,\n\t\t\tescapedCommand,\n\t\t\tfileDescriptors,\n\t\t\toptions,\n\t\t\tstartTime,\n\t\t\tisSync: true,\n\t\t});\n\t}\n};\n\n// The `encoding` option is handled by Execa, not by `child_process.spawnSync()`\nconst normalizeSpawnSyncOptions = ({encoding, maxBuffer, ...options}) => ({...options, encoding: 'buffer', maxBuffer: getMaxBufferSync(maxBuffer)});\n\nconst getSyncResult = ({error, exitCode, signal, timedOut, isMaxBuffer, stdio, all, options, command, escapedCommand, startTime}) => error === undefined\n\t? makeSuccessResult({\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstdio,\n\t\tall,\n\t\tipcOutput: [],\n\t\toptions,\n\t\tstartTime,\n\t})\n\t: makeError({\n\t\terror,\n\t\tcommand,\n\t\tescapedCommand,\n\t\ttimedOut,\n\t\tisCanceled: false,\n\t\tisGracefullyCanceled: false,\n\t\tisMaxBuffer,\n\t\tisForcefullyTerminated: false,\n\t\texitCode,\n\t\tsignal,\n\t\tstdio,\n\t\tall,\n\t\tipcOutput: [],\n\t\toptions,\n\t\tstartTime,\n\t\tisSync: true,\n\t});\n"
  },
  {
    "path": "lib/methods/node.js",
    "content": "import {execPath, execArgv} from 'node:process';\nimport path from 'node:path';\nimport {safeNormalizeFileUrl} from '../arguments/file-url.js';\n\n// `execaNode()` is a shortcut for `execa(..., {node: true})`\nexport const mapNode = ({options}) => {\n\tif (options.node === false) {\n\t\tthrow new TypeError('The \"node\" option cannot be false with `execaNode()`.');\n\t}\n\n\treturn {options: {...options, node: true}};\n};\n\n// Applies the `node: true` option, and the related `nodePath`/`nodeOptions` options.\n// Modifies the file commands/arguments to ensure the same Node binary and flags are re-used.\n// Also adds `ipc: true` and `shell: false`.\nexport const handleNodeOption = (file, commandArguments, {\n\tnode: shouldHandleNode = false,\n\tnodePath = execPath,\n\tnodeOptions = execArgv.filter(nodeOption => !nodeOption.startsWith('--inspect')),\n\tcwd,\n\texecPath: formerNodePath,\n\t...options\n}) => {\n\tif (formerNodePath !== undefined) {\n\t\tthrow new TypeError('The \"execPath\" option has been removed. Please use the \"nodePath\" option instead.');\n\t}\n\n\tconst normalizedNodePath = safeNormalizeFileUrl(nodePath, 'The \"nodePath\" option');\n\tconst resolvedNodePath = path.resolve(cwd, normalizedNodePath);\n\t// Use spread (which only copies own properties) to safely get shell without reading polluted prototype\n\tconst newOptions = {\n\t\t__proto__: null,\n\t\tshell: false,\n\t\t...options,\n\t\tnodePath: resolvedNodePath,\n\t\tnode: shouldHandleNode,\n\t\tcwd,\n\t};\n\n\tif (!shouldHandleNode) {\n\t\treturn [file, commandArguments, newOptions];\n\t}\n\n\tif (path.basename(file, '.exe') === 'node') {\n\t\tthrow new TypeError('When the \"node\" option is true, the first argument does not need to be \"node\".');\n\t}\n\n\treturn [\n\t\tresolvedNodePath,\n\t\t[\n\t\t\t...nodeOptions,\n\t\t\tfile,\n\t\t\t...commandArguments,\n\t\t],\n\t\t{\n\t\t\t__proto__: null,\n\t\t\tipc: true,\n\t\t\t...newOptions,\n\t\t\tshell: false,\n\t\t},\n\t];\n};\n"
  },
  {
    "path": "lib/methods/parameters.js",
    "content": "import isPlainObject from 'is-plain-obj';\nimport {safeNormalizeFileUrl} from '../arguments/file-url.js';\n\n// The command `arguments` and `options` are both optional.\n// This also does basic validation on them and on the command file.\nexport const normalizeParameters = (rawFile, rawArguments = [], rawOptions = {}) => {\n\tconst filePath = safeNormalizeFileUrl(rawFile, 'First argument');\n\tconst [commandArguments, options] = isPlainObject(rawArguments)\n\t\t? [[], rawArguments]\n\t\t: [rawArguments, rawOptions];\n\n\tif (!Array.isArray(commandArguments)) {\n\t\tthrow new TypeError(`Second argument must be either an array of arguments or an options object: ${commandArguments}`);\n\t}\n\n\tif (commandArguments.some(commandArgument => typeof commandArgument === 'object' && commandArgument !== null)) {\n\t\tthrow new TypeError(`Second argument must be an array of strings: ${commandArguments}`);\n\t}\n\n\tconst normalizedArguments = commandArguments.map(String);\n\tconst nullByteArgument = normalizedArguments.find(normalizedArgument => normalizedArgument.includes('\\0'));\n\tif (nullByteArgument !== undefined) {\n\t\tthrow new TypeError(`Arguments cannot contain null bytes (\"\\\\0\"): ${nullByteArgument}`);\n\t}\n\n\tif (!isPlainObject(options)) {\n\t\tthrow new TypeError(`Last argument must be an options object: ${options}`);\n\t}\n\n\t// Prevent prototype pollution by copying only own properties to a null-prototype object\n\treturn [filePath, normalizedArguments, {__proto__: null, ...options}];\n};\n"
  },
  {
    "path": "lib/methods/promise.js",
    "content": "// The return value is a mixin of `subprocess` and `Promise`\nexport const mergePromise = (subprocess, promise) => {\n\tfor (const [property, descriptor] of descriptors) {\n\t\tconst value = descriptor.value.bind(promise);\n\t\tReflect.defineProperty(subprocess, property, {...descriptor, value});\n\t}\n};\n\n// eslint-disable-next-line unicorn/prefer-top-level-await\nconst nativePromisePrototype = (async () => {})().constructor.prototype;\n\nconst descriptors = ['then', 'catch', 'finally'].map(property => [\n\tproperty,\n\tReflect.getOwnPropertyDescriptor(nativePromisePrototype, property),\n]);\n"
  },
  {
    "path": "lib/methods/script.js",
    "content": "// Sets `$.sync` and `$.s`\nexport const setScriptSync = (boundExeca, createNested, boundOptions) => {\n\tboundExeca.sync = createNested(mapScriptSync, boundOptions);\n\tboundExeca.s = boundExeca.sync;\n};\n\n// Main logic for `$`\nexport const mapScriptAsync = ({options}) => getScriptOptions(options);\n\n// Main logic for `$.sync`\nconst mapScriptSync = ({options}) => ({...getScriptOptions(options), isSync: true});\n\n// `$` is like `execa` but with script-friendly options: `{stdin: 'inherit', preferLocal: true}`\nconst getScriptOptions = options => ({options: {...getScriptStdinOption(options), ...options}});\n\nconst getScriptStdinOption = ({input, inputFile, stdio}) => input === undefined && inputFile === undefined && stdio === undefined\n\t? {stdin: 'inherit'}\n\t: {};\n\n// When using $(...).pipe(...), most script-friendly options should apply to both commands.\n// However, some options (like `stdin: 'inherit'`) would create issues with piping, i.e. cannot be deep.\nexport const deepScriptOptions = {preferLocal: true};\n"
  },
  {
    "path": "lib/methods/template.js",
    "content": "import {ChildProcess} from 'node:child_process';\nimport isPlainObject from 'is-plain-obj';\nimport {isUint8Array, uint8ArrayToString} from '../utils/uint-array.js';\n\n// Check whether the template string syntax is being used\nexport const isTemplateString = templates => Array.isArray(templates) && Array.isArray(templates.raw);\n\n// Convert execa`file ...commandArguments` to execa(file, commandArguments)\nexport const parseTemplates = (templates, expressions) => {\n\tlet tokens = [];\n\n\tfor (const [index, template] of templates.entries()) {\n\t\ttokens = parseTemplate({\n\t\t\ttemplates,\n\t\t\texpressions,\n\t\t\ttokens,\n\t\t\tindex,\n\t\t\ttemplate,\n\t\t});\n\t}\n\n\tif (tokens.length === 0) {\n\t\tthrow new TypeError('Template script must not be empty');\n\t}\n\n\tconst [file, ...commandArguments] = tokens;\n\treturn [file, commandArguments, {}];\n};\n\nconst parseTemplate = ({templates, expressions, tokens, index, template}) => {\n\tif (template === undefined) {\n\t\tthrow new TypeError(`Invalid backslash sequence: ${templates.raw[index]}`);\n\t}\n\n\tconst {nextTokens, leadingWhitespaces, trailingWhitespaces} = splitByWhitespaces(template, templates.raw[index]);\n\tconst newTokens = concatTokens(tokens, nextTokens, leadingWhitespaces);\n\n\tif (index === expressions.length) {\n\t\treturn newTokens;\n\t}\n\n\tconst expression = expressions[index];\n\tconst expressionTokens = Array.isArray(expression)\n\t\t? expression.map(expression => parseExpression(expression))\n\t\t: [parseExpression(expression)];\n\treturn concatTokens(newTokens, expressionTokens, trailingWhitespaces);\n};\n\n// Like `string.split(/[ \\t\\r\\n]+/)` except newlines and tabs are:\n//  - ignored when input as a backslash sequence like: `echo foo\\n bar`\n//  - not ignored when input directly\n// The only way to distinguish those in JavaScript is to use a tagged template and compare:\n//  - the first array argument, which does not escape backslash sequences\n//  - its `raw` property, which escapes them\nconst splitByWhitespaces = (template, rawTemplate) => {\n\tif (rawTemplate.length === 0) {\n\t\treturn {nextTokens: [], leadingWhitespaces: false, trailingWhitespaces: false};\n\t}\n\n\tconst nextTokens = [];\n\tlet templateStart = 0;\n\tconst leadingWhitespaces = DELIMITERS.has(rawTemplate[0]);\n\n\tfor (\n\t\tlet templateIndex = 0, rawIndex = 0;\n\t\ttemplateIndex < template.length;\n\t\ttemplateIndex += 1, rawIndex += 1\n\t) {\n\t\tconst rawCharacter = rawTemplate[rawIndex];\n\t\tif (DELIMITERS.has(rawCharacter)) {\n\t\t\tif (templateStart !== templateIndex) {\n\t\t\t\tnextTokens.push(template.slice(templateStart, templateIndex));\n\t\t\t}\n\n\t\t\ttemplateStart = templateIndex + 1;\n\t\t} else if (rawCharacter === '\\\\') {\n\t\t\tconst nextRawCharacter = rawTemplate[rawIndex + 1];\n\t\t\tif (nextRawCharacter === '\\n') {\n\t\t\t\t// Handles escaped newlines in templates\n\t\t\t\ttemplateIndex -= 1;\n\t\t\t\trawIndex += 1;\n\t\t\t} else if (nextRawCharacter === 'u' && rawTemplate[rawIndex + 2] === '{') {\n\t\t\t\trawIndex = rawTemplate.indexOf('}', rawIndex + 3);\n\t\t\t} else {\n\t\t\t\trawIndex += ESCAPE_LENGTH[nextRawCharacter] ?? 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst trailingWhitespaces = templateStart === template.length;\n\tif (!trailingWhitespaces) {\n\t\tnextTokens.push(template.slice(templateStart));\n\t}\n\n\treturn {nextTokens, leadingWhitespaces, trailingWhitespaces};\n};\n\nconst DELIMITERS = new Set([' ', '\\t', '\\r', '\\n']);\n\n// Number of characters in backslash escape sequences: \\0 \\xXX or \\uXXXX\n// \\cX is allowed in RegExps but not in strings\n// Octal sequences are not allowed in strict mode\nconst ESCAPE_LENGTH = {x: 3, u: 5};\n\nconst concatTokens = (tokens, nextTokens, isSeparated) => isSeparated\n\t|| tokens.length === 0\n\t|| nextTokens.length === 0\n\t? [...tokens, ...nextTokens]\n\t: [\n\t\t...tokens.slice(0, -1),\n\t\t`${tokens.at(-1)}${nextTokens[0]}`,\n\t\t...nextTokens.slice(1),\n\t];\n\n// Handle `${expression}` inside the template string syntax\nconst parseExpression = expression => {\n\tconst typeOfExpression = typeof expression;\n\n\tif (typeOfExpression === 'string') {\n\t\treturn expression;\n\t}\n\n\tif (typeOfExpression === 'number') {\n\t\treturn String(expression);\n\t}\n\n\tif (isPlainObject(expression) && ('stdout' in expression || 'isMaxBuffer' in expression)) {\n\t\treturn getSubprocessResult(expression);\n\t}\n\n\tif (expression instanceof ChildProcess || Object.prototype.toString.call(expression) === '[object Promise]') {\n\t\t// eslint-disable-next-line no-template-curly-in-string\n\t\tthrow new TypeError('Unexpected subprocess in template expression. Please use ${await subprocess} instead of ${subprocess}.');\n\t}\n\n\tthrow new TypeError(`Unexpected \"${typeOfExpression}\" in template expression`);\n};\n\nconst getSubprocessResult = ({stdout}) => {\n\tif (typeof stdout === 'string') {\n\t\treturn stdout;\n\t}\n\n\tif (isUint8Array(stdout)) {\n\t\treturn uint8ArrayToString(stdout);\n\t}\n\n\tif (stdout === undefined) {\n\t\tthrow new TypeError('Missing result.stdout in template expression. This is probably due to the previous subprocess\\' \"stdout\" option.');\n\t}\n\n\tthrow new TypeError(`Unexpected \"${typeof stdout}\" stdout in template expression`);\n};\n"
  },
  {
    "path": "lib/pipe/abort.js",
    "content": "import {aborted} from 'node:util';\nimport {createNonCommandError} from './throw.js';\n\n// When passing an `unpipeSignal` option, abort piping when the signal is aborted.\n// However, do not terminate the subprocesses.\nexport const unpipeOnAbort = (unpipeSignal, unpipeContext) => unpipeSignal === undefined\n\t? []\n\t: [unpipeOnSignalAbort(unpipeSignal, unpipeContext)];\n\nconst unpipeOnSignalAbort = async (unpipeSignal, {sourceStream, mergedStream, fileDescriptors, sourceOptions, startTime}) => {\n\tawait aborted(unpipeSignal, sourceStream);\n\tawait mergedStream.remove(sourceStream);\n\tconst error = new Error('Pipe canceled by `unpipeSignal` option.');\n\tthrow createNonCommandError({\n\t\terror,\n\t\tfileDescriptors,\n\t\tsourceOptions,\n\t\tstartTime,\n\t});\n};\n"
  },
  {
    "path": "lib/pipe/pipe-arguments.js",
    "content": "import {normalizeParameters} from '../methods/parameters.js';\nimport {getStartTime} from '../return/duration.js';\nimport {SUBPROCESS_OPTIONS, getToStream, getFromStream} from '../arguments/fd-options.js';\nimport {isDenoExecPath} from '../arguments/file-url.js';\n\n// Normalize and validate arguments passed to `source.pipe(destination)`\nexport const normalizePipeArguments = ({source, sourcePromise, boundOptions, createNested}, ...pipeArguments) => {\n\tconst startTime = getStartTime();\n\tconst {\n\t\tdestination,\n\t\tdestinationStream,\n\t\tdestinationError,\n\t\tfrom,\n\t\tunpipeSignal,\n\t} = getDestinationStream(boundOptions, createNested, pipeArguments);\n\tconst {sourceStream, sourceError} = getSourceStream(source, from);\n\tconst {options: sourceOptions, fileDescriptors} = SUBPROCESS_OPTIONS.get(source);\n\treturn {\n\t\tsourcePromise,\n\t\tsourceStream,\n\t\tsourceOptions,\n\t\tsourceError,\n\t\tdestination,\n\t\tdestinationStream,\n\t\tdestinationError,\n\t\tunpipeSignal,\n\t\tfileDescriptors,\n\t\tstartTime,\n\t};\n};\n\nconst getDestinationStream = (boundOptions, createNested, pipeArguments) => {\n\ttry {\n\t\tconst {\n\t\t\tdestination,\n\t\t\tpipeOptions: {from, to, unpipeSignal} = {},\n\t\t} = getDestination(boundOptions, createNested, ...pipeArguments);\n\t\tconst destinationStream = getToStream(destination, to);\n\t\treturn {\n\t\t\tdestination,\n\t\t\tdestinationStream,\n\t\t\tfrom,\n\t\t\tunpipeSignal,\n\t\t};\n\t} catch (error) {\n\t\treturn {destinationError: error};\n\t}\n};\n\n// Piping subprocesses can use three syntaxes:\n//  - source.pipe('command', commandArguments, pipeOptionsOrDestinationOptions)\n//  - source.pipe`command commandArgument` or source.pipe(pipeOptionsOrDestinationOptions)`command commandArgument`\n//  - source.pipe(execa(...), pipeOptions)\nconst getDestination = (boundOptions, createNested, firstArgument, ...pipeArguments) => {\n\tif (Array.isArray(firstArgument)) {\n\t\tconst destination = createNested(mapDestinationArguments, boundOptions)(firstArgument, ...pipeArguments);\n\t\treturn {destination, pipeOptions: boundOptions};\n\t}\n\n\tif (typeof firstArgument === 'string' || firstArgument instanceof URL || isDenoExecPath(firstArgument)) {\n\t\tif (Object.keys(boundOptions).length > 0) {\n\t\t\tthrow new TypeError('Please use .pipe(\"file\", ..., options) or .pipe(execa(\"file\", ..., options)) instead of .pipe(options)(\"file\", ...).');\n\t\t}\n\n\t\tconst [rawFile, rawArguments, rawOptions] = normalizeParameters(firstArgument, ...pipeArguments);\n\t\tconst destination = createNested(mapDestinationArguments)(rawFile, rawArguments, rawOptions);\n\t\treturn {destination, pipeOptions: rawOptions};\n\t}\n\n\tif (SUBPROCESS_OPTIONS.has(firstArgument)) {\n\t\tif (Object.keys(boundOptions).length > 0) {\n\t\t\tthrow new TypeError('Please use .pipe(options)`command` or .pipe($(options)`command`) instead of .pipe(options)($`command`).');\n\t\t}\n\n\t\treturn {destination: firstArgument, pipeOptions: pipeArguments[0]};\n\t}\n\n\tthrow new TypeError(`The first argument must be a template string, an options object, or an Execa subprocess: ${firstArgument}`);\n};\n\n// Force `stdin: 'pipe'` with the destination subprocess\nconst mapDestinationArguments = ({options}) => ({options: {...options, stdin: 'pipe', piped: true}});\n\nconst getSourceStream = (source, from) => {\n\ttry {\n\t\tconst sourceStream = getFromStream(source, from);\n\t\treturn {sourceStream};\n\t} catch (error) {\n\t\treturn {sourceError: error};\n\t}\n};\n"
  },
  {
    "path": "lib/pipe/sequence.js",
    "content": "// Like Bash, we await both subprocesses. This is unlike some other shells which only await the destination subprocess.\n// Like Bash with the `pipefail` option, if either subprocess fails, the whole pipe fails.\n// Like Bash, if both subprocesses fail, we return the failure of the destination.\n// This ensures both subprocesses' errors are present, using `error.pipedFrom`.\nexport const waitForBothSubprocesses = async subprocessPromises => {\n\tconst [\n\t\t{status: sourceStatus, reason: sourceReason, value: sourceResult = sourceReason},\n\t\t{status: destinationStatus, reason: destinationReason, value: destinationResult = destinationReason},\n\t] = await subprocessPromises;\n\n\tif (!destinationResult.pipedFrom.includes(sourceResult)) {\n\t\tdestinationResult.pipedFrom.push(sourceResult);\n\t}\n\n\tif (destinationStatus === 'rejected') {\n\t\tthrow destinationResult;\n\t}\n\n\tif (sourceStatus === 'rejected') {\n\t\tthrow sourceResult;\n\t}\n\n\treturn destinationResult;\n};\n"
  },
  {
    "path": "lib/pipe/setup.js",
    "content": "import isPlainObject from 'is-plain-obj';\nimport {normalizePipeArguments} from './pipe-arguments.js';\nimport {handlePipeArgumentsError} from './throw.js';\nimport {waitForBothSubprocesses} from './sequence.js';\nimport {pipeSubprocessStream} from './streaming.js';\nimport {unpipeOnAbort} from './abort.js';\n\n// Pipe a subprocess' `stdout`/`stderr`/`stdio` into another subprocess' `stdin`\nexport const pipeToSubprocess = (sourceInfo, ...pipeArguments) => {\n\tif (isPlainObject(pipeArguments[0])) {\n\t\treturn pipeToSubprocess.bind(undefined, {\n\t\t\t...sourceInfo,\n\t\t\tboundOptions: {...sourceInfo.boundOptions, ...pipeArguments[0]},\n\t\t});\n\t}\n\n\tconst {destination, ...normalizedInfo} = normalizePipeArguments(sourceInfo, ...pipeArguments);\n\tconst promise = handlePipePromise({...normalizedInfo, destination});\n\tpromise.pipe = pipeToSubprocess.bind(undefined, {\n\t\t...sourceInfo,\n\t\tsource: destination,\n\t\tsourcePromise: promise,\n\t\tboundOptions: {},\n\t});\n\treturn promise;\n};\n\n// Asynchronous logic when piping subprocesses\nconst handlePipePromise = async ({\n\tsourcePromise,\n\tsourceStream,\n\tsourceOptions,\n\tsourceError,\n\tdestination,\n\tdestinationStream,\n\tdestinationError,\n\tunpipeSignal,\n\tfileDescriptors,\n\tstartTime,\n}) => {\n\tconst subprocessPromises = getSubprocessPromises(sourcePromise, destination);\n\thandlePipeArgumentsError({\n\t\tsourceStream,\n\t\tsourceError,\n\t\tdestinationStream,\n\t\tdestinationError,\n\t\tfileDescriptors,\n\t\tsourceOptions,\n\t\tstartTime,\n\t});\n\tconst maxListenersController = new AbortController();\n\ttry {\n\t\tconst mergedStream = pipeSubprocessStream(sourceStream, destinationStream, maxListenersController);\n\t\treturn await Promise.race([\n\t\t\twaitForBothSubprocesses(subprocessPromises),\n\t\t\t...unpipeOnAbort(unpipeSignal, {\n\t\t\t\tsourceStream,\n\t\t\t\tmergedStream,\n\t\t\t\tsourceOptions,\n\t\t\t\tfileDescriptors,\n\t\t\t\tstartTime,\n\t\t\t}),\n\t\t]);\n\t} finally {\n\t\tmaxListenersController.abort();\n\t}\n};\n\n// `.pipe()` awaits the subprocess promises.\n// When invalid arguments are passed to `.pipe()`, we throw an error, which prevents awaiting them.\n// We need to ensure this does not create unhandled rejections.\nconst getSubprocessPromises = (sourcePromise, destination) => Promise.allSettled([sourcePromise, destination]);\n"
  },
  {
    "path": "lib/pipe/streaming.js",
    "content": "import {finished} from 'node:stream/promises';\nimport mergeStreams from '@sindresorhus/merge-streams';\nimport {incrementMaxListeners} from '../utils/max-listeners.js';\nimport {pipeStreams} from '../io/pipeline.js';\n\n// The piping behavior is like Bash.\n// In particular, when one subprocess exits, the other is not terminated by a signal.\n// Instead, its stdout (for the source) or stdin (for the destination) closes.\n// If the subprocess uses it, it will make it error with SIGPIPE or EPIPE (for the source) or end (for the destination).\n// If it does not use it, it will continue running.\n// This allows for subprocesses to gracefully exit and lower the coupling between subprocesses.\nexport const pipeSubprocessStream = (sourceStream, destinationStream, maxListenersController) => {\n\tconst mergedStream = MERGED_STREAMS.has(destinationStream)\n\t\t? pipeMoreSubprocessStream(sourceStream, destinationStream)\n\t\t: pipeFirstSubprocessStream(sourceStream, destinationStream);\n\tincrementMaxListeners(sourceStream, SOURCE_LISTENERS_PER_PIPE, maxListenersController.signal);\n\tincrementMaxListeners(destinationStream, DESTINATION_LISTENERS_PER_PIPE, maxListenersController.signal);\n\tcleanupMergedStreamsMap(destinationStream);\n\treturn mergedStream;\n};\n\n// We use `merge-streams` to allow for multiple sources to pipe to the same destination.\nconst pipeFirstSubprocessStream = (sourceStream, destinationStream) => {\n\tconst mergedStream = mergeStreams([sourceStream]);\n\tpipeStreams(mergedStream, destinationStream);\n\tMERGED_STREAMS.set(destinationStream, mergedStream);\n\treturn mergedStream;\n};\n\nconst pipeMoreSubprocessStream = (sourceStream, destinationStream) => {\n\tconst mergedStream = MERGED_STREAMS.get(destinationStream);\n\tmergedStream.add(sourceStream);\n\treturn mergedStream;\n};\n\nconst cleanupMergedStreamsMap = async destinationStream => {\n\ttry {\n\t\tawait finished(destinationStream, {cleanup: true, readable: false, writable: true});\n\t} catch {}\n\n\tMERGED_STREAMS.delete(destinationStream);\n};\n\nconst MERGED_STREAMS = new WeakMap();\n\n// Number of listeners set up on `sourceStream` by each `sourceStream.pipe(destinationStream)`\n// Those are added by `merge-streams`\nconst SOURCE_LISTENERS_PER_PIPE = 2;\n// Number of listeners set up on `destinationStream` by each `sourceStream.pipe(destinationStream)`\n// Those are added by `finished()` in `cleanupMergedStreamsMap()`\nconst DESTINATION_LISTENERS_PER_PIPE = 1;\n"
  },
  {
    "path": "lib/pipe/throw.js",
    "content": "import {makeEarlyError} from '../return/result.js';\nimport {abortSourceStream, endDestinationStream} from '../io/pipeline.js';\n\n// When passing invalid arguments to `source.pipe()`, throw asynchronously.\n// We also abort both subprocesses.\nexport const handlePipeArgumentsError = ({\n\tsourceStream,\n\tsourceError,\n\tdestinationStream,\n\tdestinationError,\n\tfileDescriptors,\n\tsourceOptions,\n\tstartTime,\n}) => {\n\tconst error = getPipeArgumentsError({\n\t\tsourceStream,\n\t\tsourceError,\n\t\tdestinationStream,\n\t\tdestinationError,\n\t});\n\tif (error !== undefined) {\n\t\tthrow createNonCommandError({\n\t\t\terror,\n\t\t\tfileDescriptors,\n\t\t\tsourceOptions,\n\t\t\tstartTime,\n\t\t});\n\t}\n};\n\nconst getPipeArgumentsError = ({sourceStream, sourceError, destinationStream, destinationError}) => {\n\tif (sourceError !== undefined && destinationError !== undefined) {\n\t\treturn destinationError;\n\t}\n\n\tif (destinationError !== undefined) {\n\t\tabortSourceStream(sourceStream);\n\t\treturn destinationError;\n\t}\n\n\tif (sourceError !== undefined) {\n\t\tendDestinationStream(destinationStream);\n\t\treturn sourceError;\n\t}\n};\n\n// Specific error return value when passing invalid arguments to `subprocess.pipe()` or when using `unpipeSignal`\nexport const createNonCommandError = ({error, fileDescriptors, sourceOptions, startTime}) => makeEarlyError({\n\terror,\n\tcommand: PIPE_COMMAND_MESSAGE,\n\tescapedCommand: PIPE_COMMAND_MESSAGE,\n\tfileDescriptors,\n\toptions: sourceOptions,\n\tstartTime,\n\tisSync: false,\n});\n\nconst PIPE_COMMAND_MESSAGE = 'source.pipe(destination)';\n"
  },
  {
    "path": "lib/resolve/all-async.js",
    "content": "import mergeStreams from '@sindresorhus/merge-streams';\nimport {waitForSubprocessStream} from './stdio.js';\n\n// `all` interleaves `stdout` and `stderr`\nexport const makeAllStream = ({stdout, stderr}, {all}) => all && (stdout || stderr)\n\t? mergeStreams([stdout, stderr].filter(Boolean))\n\t: undefined;\n\n// Read the contents of `subprocess.all` and|or wait for its completion\nexport const waitForAllStream = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo}) => waitForSubprocessStream({\n\t...getAllStream(subprocess, buffer),\n\tfdNumber: 'all',\n\tencoding,\n\tmaxBuffer: maxBuffer[1] + maxBuffer[2],\n\tlines: lines[1] || lines[2],\n\tallMixed: getAllMixed(subprocess),\n\tstripFinalNewline,\n\tverboseInfo,\n\tstreamInfo,\n});\n\nconst getAllStream = ({stdout, stderr, all}, [, bufferStdout, bufferStderr]) => {\n\tconst buffer = bufferStdout || bufferStderr;\n\tif (!buffer) {\n\t\treturn {stream: all, buffer};\n\t}\n\n\tif (!bufferStdout) {\n\t\treturn {stream: stderr, buffer};\n\t}\n\n\tif (!bufferStderr) {\n\t\treturn {stream: stdout, buffer};\n\t}\n\n\treturn {stream: all, buffer};\n};\n\n// When `subprocess.stdout` is in objectMode but not `subprocess.stderr` (or the opposite), we need to use both:\n//  - `getStreamAsArray()` for the chunks in objectMode, to return as an array without changing each chunk\n//  - `getStreamAsArrayBuffer()` or `getStream()` for the chunks not in objectMode, to convert them from Buffers to string or Uint8Array\n// We do this by emulating the Buffer -> string|Uint8Array conversion performed by `get-stream` with our own, which is identical.\nconst getAllMixed = ({all, stdout, stderr}) => all\n\t&& stdout\n\t&& stderr\n\t&& stdout.readableObjectMode !== stderr.readableObjectMode;\n"
  },
  {
    "path": "lib/resolve/all-sync.js",
    "content": "import {isUint8Array, concatUint8Arrays} from '../utils/uint-array.js';\nimport {stripNewline} from '../io/strip-newline.js';\n\n// Retrieve `result.all` with synchronous methods\nexport const getAllSync = ([, stdout, stderr], options) => {\n\tif (!options.all) {\n\t\treturn;\n\t}\n\n\tif (stdout === undefined) {\n\t\treturn stderr;\n\t}\n\n\tif (stderr === undefined) {\n\t\treturn stdout;\n\t}\n\n\tif (Array.isArray(stdout)) {\n\t\treturn Array.isArray(stderr)\n\t\t\t? [...stdout, ...stderr]\n\t\t\t: [...stdout, stripNewline(stderr, options, 'all')];\n\t}\n\n\tif (Array.isArray(stderr)) {\n\t\treturn [stripNewline(stdout, options, 'all'), ...stderr];\n\t}\n\n\tif (isUint8Array(stdout) && isUint8Array(stderr)) {\n\t\treturn concatUint8Arrays([stdout, stderr]);\n\t}\n\n\treturn `${stdout}${stderr}`;\n};\n"
  },
  {
    "path": "lib/resolve/exit-async.js",
    "content": "import {once} from 'node:events';\nimport {DiscardedError} from '../return/final-error.js';\n\n// If `error` is emitted before `spawn`, `exit` will never be emitted.\n// However, `error` might be emitted after `spawn`.\n// In that case, `exit` will still be emitted.\n// Since the `exit` event contains the signal name, we want to make sure we are listening for it.\n// This function also takes into account the following unlikely cases:\n//  - `exit` being emitted in the same microtask as `spawn`\n//  - `error` being emitted multiple times\nexport const waitForExit = async (subprocess, context) => {\n\tconst [exitCode, signal] = await waitForExitOrError(subprocess);\n\tcontext.isForcefullyTerminated ??= false;\n\treturn [exitCode, signal];\n};\n\nconst waitForExitOrError = async subprocess => {\n\tconst [spawnPayload, exitPayload] = await Promise.allSettled([\n\t\tonce(subprocess, 'spawn'),\n\t\tonce(subprocess, 'exit'),\n\t]);\n\n\tif (spawnPayload.status === 'rejected') {\n\t\treturn [];\n\t}\n\n\treturn exitPayload.status === 'rejected'\n\t\t? waitForSubprocessExit(subprocess)\n\t\t: exitPayload.value;\n};\n\nconst waitForSubprocessExit = async subprocess => {\n\ttry {\n\t\treturn await once(subprocess, 'exit');\n\t} catch {\n\t\treturn waitForSubprocessExit(subprocess);\n\t}\n};\n\n// Retrieve the final exit code and|or signal name\nexport const waitForSuccessfulExit = async exitPromise => {\n\tconst [exitCode, signal] = await exitPromise;\n\n\tif (!isSubprocessErrorExit(exitCode, signal) && isFailedExit(exitCode, signal)) {\n\t\tthrow new DiscardedError();\n\t}\n\n\treturn [exitCode, signal];\n};\n\n// When the subprocess fails due to an `error` event\nconst isSubprocessErrorExit = (exitCode, signal) => exitCode === undefined && signal === undefined;\n// When the subprocess fails due to a non-0 exit code or to a signal termination\nexport const isFailedExit = (exitCode, signal) => exitCode !== 0 || signal !== null;\n"
  },
  {
    "path": "lib/resolve/exit-sync.js",
    "content": "import {DiscardedError} from '../return/final-error.js';\nimport {isMaxBufferSync} from '../io/max-buffer.js';\nimport {isFailedExit} from './exit-async.js';\n\n// Retrieve exit code, signal name and error information, with synchronous methods\nexport const getExitResultSync = ({error, status: exitCode, signal, output}, {maxBuffer}) => {\n\tconst resultError = getResultError(error, exitCode, signal);\n\tconst timedOut = resultError?.code === 'ETIMEDOUT';\n\tconst isMaxBuffer = isMaxBufferSync(resultError, output, maxBuffer);\n\treturn {\n\t\tresultError,\n\t\texitCode,\n\t\tsignal,\n\t\ttimedOut,\n\t\tisMaxBuffer,\n\t};\n};\n\nconst getResultError = (error, exitCode, signal) => {\n\tif (error !== undefined) {\n\t\treturn error;\n\t}\n\n\treturn isFailedExit(exitCode, signal) ? new DiscardedError() : undefined;\n};\n"
  },
  {
    "path": "lib/resolve/stdio.js",
    "content": "import {getStreamOutput} from '../io/contents.js';\nimport {waitForStream, isInputFileDescriptor} from './wait-stream.js';\n\n// Read the contents of `subprocess.std*` and|or wait for its completion\nexport const waitForStdioStreams = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, verboseInfo, streamInfo}) => subprocess.stdio.map((stream, fdNumber) => waitForSubprocessStream({\n\tstream,\n\tfdNumber,\n\tencoding,\n\tbuffer: buffer[fdNumber],\n\tmaxBuffer: maxBuffer[fdNumber],\n\tlines: lines[fdNumber],\n\tallMixed: false,\n\tstripFinalNewline,\n\tverboseInfo,\n\tstreamInfo,\n}));\n\n// Read the contents of `subprocess.std*` or `subprocess.all` and|or wait for its completion\nexport const waitForSubprocessStream = async ({stream, fdNumber, encoding, buffer, maxBuffer, lines, allMixed, stripFinalNewline, verboseInfo, streamInfo}) => {\n\tif (!stream) {\n\t\treturn;\n\t}\n\n\tconst onStreamEnd = waitForStream(stream, fdNumber, streamInfo);\n\tif (isInputFileDescriptor(streamInfo, fdNumber)) {\n\t\tawait onStreamEnd;\n\t\treturn;\n\t}\n\n\tconst [output] = await Promise.all([\n\t\tgetStreamOutput({\n\t\t\tstream,\n\t\t\tonStreamEnd,\n\t\t\tfdNumber,\n\t\t\tencoding,\n\t\t\tbuffer,\n\t\t\tmaxBuffer,\n\t\t\tlines,\n\t\t\tallMixed,\n\t\t\tstripFinalNewline,\n\t\t\tverboseInfo,\n\t\t\tstreamInfo,\n\t\t}),\n\t\tonStreamEnd,\n\t]);\n\treturn output;\n};\n"
  },
  {
    "path": "lib/resolve/wait-stream.js",
    "content": "import {finished} from 'node:stream/promises';\n\n// Wraps `finished(stream)` to handle the following case:\n//  - When the subprocess exits, Node.js automatically calls `subprocess.stdin.destroy()`, which we need to ignore.\n//  - However, we still need to throw if `subprocess.stdin.destroy()` is called before subprocess exit.\nexport const waitForStream = async (stream, fdNumber, streamInfo, {isSameDirection, stopOnExit = false} = {}) => {\n\tconst state = handleStdinDestroy(stream, streamInfo);\n\tconst abortController = new AbortController();\n\ttry {\n\t\tawait Promise.race([\n\t\t\t...(stopOnExit ? [streamInfo.exitPromise] : []),\n\t\t\tfinished(stream, {cleanup: true, signal: abortController.signal}),\n\t\t]);\n\t} catch (error) {\n\t\tif (!state.stdinCleanedUp) {\n\t\t\thandleStreamError(error, fdNumber, streamInfo, isSameDirection);\n\t\t}\n\t} finally {\n\t\tabortController.abort();\n\t}\n};\n\n// If `subprocess.stdin` is destroyed before being fully written to, it is considered aborted and should throw an error.\n// This can happen for example when user called `subprocess.stdin.destroy()` before `subprocess.stdin.end()`.\n// However, Node.js calls `subprocess.stdin.destroy()` on exit for cleanup purposes.\n// https://github.com/nodejs/node/blob/0b4cdb4b42956cbd7019058e409e06700a199e11/lib/internal/child_process.js#L278\n// This is normal and should not throw an error.\n// Therefore, we need to differentiate between both situations to know whether to throw an error.\n// Unfortunately, events (`close`, `error`, `end`, `exit`) cannot be used because `.destroy()` can take an arbitrary amount of time.\n// For example, `stdin: 'pipe'` is implemented as a TCP socket, and its `.destroy()` method waits for TCP disconnection.\n// Therefore `.destroy()` might end before or after subprocess exit, based on OS speed and load.\n// The only way to detect this is to spy on `subprocess.stdin._destroy()` by wrapping it.\n// If `subprocess.exitCode` or `subprocess.signalCode` is set, it means `.destroy()` is being called by Node.js itself.\nconst handleStdinDestroy = (stream, {originalStreams: [originalStdin], subprocess}) => {\n\tconst state = {stdinCleanedUp: false};\n\tif (stream === originalStdin) {\n\t\tspyOnStdinDestroy(stream, subprocess, state);\n\t}\n\n\treturn state;\n};\n\nconst spyOnStdinDestroy = (subprocessStdin, subprocess, state) => {\n\tconst {_destroy} = subprocessStdin;\n\tsubprocessStdin._destroy = (...destroyArguments) => {\n\t\tsetStdinCleanedUp(subprocess, state);\n\t\t_destroy.call(subprocessStdin, ...destroyArguments);\n\t};\n};\n\nconst setStdinCleanedUp = ({exitCode, signalCode}, state) => {\n\tif (exitCode !== null || signalCode !== null) {\n\t\tstate.stdinCleanedUp = true;\n\t}\n};\n\n// We ignore EPIPEs on writable streams and aborts on readable streams since those can happen normally.\n// When one stream errors, the error is propagated to the other streams on the same file descriptor.\n// Those other streams might have a different direction due to the above.\n// When this happens, the direction of both the initial stream and the others should then be taken into account.\n// Therefore, we keep track of whether a stream error is currently propagating.\nconst handleStreamError = (error, fdNumber, streamInfo, isSameDirection) => {\n\tif (!shouldIgnoreStreamError(error, fdNumber, streamInfo, isSameDirection)) {\n\t\tthrow error;\n\t}\n};\n\nconst shouldIgnoreStreamError = (error, fdNumber, streamInfo, isSameDirection = true) => {\n\tif (streamInfo.propagating) {\n\t\treturn isStreamEpipe(error) || isStreamAbort(error);\n\t}\n\n\tstreamInfo.propagating = true;\n\treturn isInputFileDescriptor(streamInfo, fdNumber) === isSameDirection\n\t\t? isStreamEpipe(error)\n\t\t: isStreamAbort(error);\n};\n\n// Unfortunately, we cannot use the stream's class or properties to know whether it is readable or writable.\n// For example, `subprocess.stdin` is technically a Duplex, but can only be used as a writable.\n// Therefore, we need to use the file descriptor's direction (`stdin` is input, `stdout` is output, etc.).\n// However, while `subprocess.std*` and transforms follow that direction, any stream passed the `std*` option has the opposite direction.\n// For example, `subprocess.stdin` is a writable, but the `stdin` option is a readable.\nexport const isInputFileDescriptor = ({fileDescriptors}, fdNumber) => fdNumber !== 'all' && fileDescriptors[fdNumber].direction === 'input';\n\n// When `stream.destroy()` is called without an `error` argument, stream is aborted.\n// This is the only way to abort a readable stream, which can be useful in some instances.\n// Therefore, we ignore this error on readable streams.\nexport const isStreamAbort = error => error?.code === 'ERR_STREAM_PREMATURE_CLOSE';\n\n// When `stream.write()` is called but the underlying source has been closed, `EPIPE` is emitted.\n// When piping subprocesses, the source subprocess usually decides when to stop piping.\n// However, there are some instances when the destination does instead, such as `... | head -n1`.\n// It notifies the source by using `EPIPE`.\n// Therefore, we ignore this error on writable streams.\nconst isStreamEpipe = error => error?.code === 'EPIPE';\n"
  },
  {
    "path": "lib/resolve/wait-subprocess.js",
    "content": "import {once} from 'node:events';\nimport {isStream as isNodeStream} from 'is-stream';\nimport {throwOnTimeout} from '../terminate/timeout.js';\nimport {throwOnCancel} from '../terminate/cancel.js';\nimport {throwOnGracefulCancel} from '../terminate/graceful.js';\nimport {isStandardStream} from '../utils/standard-stream.js';\nimport {TRANSFORM_TYPES} from '../stdio/type.js';\nimport {getBufferedData} from '../io/contents.js';\nimport {waitForIpcOutput, getBufferedIpcOutput} from '../ipc/buffer-messages.js';\nimport {sendIpcInput} from '../ipc/ipc-input.js';\nimport {waitForAllStream} from './all-async.js';\nimport {waitForStdioStreams} from './stdio.js';\nimport {waitForExit, waitForSuccessfulExit} from './exit-async.js';\nimport {waitForStream} from './wait-stream.js';\n\n// Retrieve result of subprocess: exit code, signal, error, streams (stdout/stderr/all)\nexport const waitForSubprocessResult = async ({\n\tsubprocess,\n\toptions: {\n\t\tencoding,\n\t\tbuffer,\n\t\tmaxBuffer,\n\t\tlines,\n\t\ttimeoutDuration: timeout,\n\t\tcancelSignal,\n\t\tgracefulCancel,\n\t\tforceKillAfterDelay,\n\t\tstripFinalNewline,\n\t\tipc,\n\t\tipcInput,\n\t},\n\tcontext,\n\tverboseInfo,\n\tfileDescriptors,\n\toriginalStreams,\n\tonInternalError,\n\tcontroller,\n}) => {\n\tconst exitPromise = waitForExit(subprocess, context);\n\tconst streamInfo = {\n\t\toriginalStreams,\n\t\tfileDescriptors,\n\t\tsubprocess,\n\t\texitPromise,\n\t\tpropagating: false,\n\t};\n\n\tconst stdioPromises = waitForStdioStreams({\n\t\tsubprocess,\n\t\tencoding,\n\t\tbuffer,\n\t\tmaxBuffer,\n\t\tlines,\n\t\tstripFinalNewline,\n\t\tverboseInfo,\n\t\tstreamInfo,\n\t});\n\tconst allPromise = waitForAllStream({\n\t\tsubprocess,\n\t\tencoding,\n\t\tbuffer,\n\t\tmaxBuffer,\n\t\tlines,\n\t\tstripFinalNewline,\n\t\tverboseInfo,\n\t\tstreamInfo,\n\t});\n\tconst ipcOutput = [];\n\tconst ipcOutputPromise = waitForIpcOutput({\n\t\tsubprocess,\n\t\tbuffer,\n\t\tmaxBuffer,\n\t\tipc,\n\t\tipcOutput,\n\t\tverboseInfo,\n\t});\n\tconst originalPromises = waitForOriginalStreams(originalStreams, subprocess, streamInfo);\n\tconst customStreamsEndPromises = waitForCustomStreamsEnd(fileDescriptors, streamInfo);\n\n\ttry {\n\t\treturn await Promise.race([\n\t\t\tPromise.all([\n\t\t\t\t{},\n\t\t\t\twaitForSuccessfulExit(exitPromise),\n\t\t\t\tPromise.all(stdioPromises),\n\t\t\t\tallPromise,\n\t\t\t\tipcOutputPromise,\n\t\t\t\tsendIpcInput(subprocess, ipcInput),\n\t\t\t\t...originalPromises,\n\t\t\t\t...customStreamsEndPromises,\n\t\t\t]),\n\t\t\tonInternalError,\n\t\t\tthrowOnSubprocessError(subprocess, controller),\n\t\t\t...throwOnTimeout(subprocess, timeout, context, controller),\n\t\t\t...throwOnCancel({\n\t\t\t\tsubprocess,\n\t\t\t\tcancelSignal,\n\t\t\t\tgracefulCancel,\n\t\t\t\tcontext,\n\t\t\t\tcontroller,\n\t\t\t}),\n\t\t\t...throwOnGracefulCancel({\n\t\t\t\tsubprocess,\n\t\t\t\tcancelSignal,\n\t\t\t\tgracefulCancel,\n\t\t\t\tforceKillAfterDelay,\n\t\t\t\tcontext,\n\t\t\t\tcontroller,\n\t\t\t}),\n\t\t]);\n\t} catch (error) {\n\t\tcontext.terminationReason ??= 'other';\n\t\treturn Promise.all([\n\t\t\t{error},\n\t\t\texitPromise,\n\t\t\tPromise.all(stdioPromises.map(stdioPromise => getBufferedData(stdioPromise))),\n\t\t\tgetBufferedData(allPromise),\n\t\t\tgetBufferedIpcOutput(ipcOutputPromise, ipcOutput),\n\t\t\tPromise.allSettled(originalPromises),\n\t\t\tPromise.allSettled(customStreamsEndPromises),\n\t\t]);\n\t}\n};\n\n// Transforms replace `subprocess.std*`, which means they are not exposed to users.\n// However, we still want to wait for their completion.\nconst waitForOriginalStreams = (originalStreams, subprocess, streamInfo) =>\n\toriginalStreams.map((stream, fdNumber) => stream === subprocess.stdio[fdNumber]\n\t\t? undefined\n\t\t: waitForStream(stream, fdNumber, streamInfo));\n\n// Some `stdin`/`stdout`/`stderr` options create a stream, e.g. when passing a file path.\n// The `.pipe()` method automatically ends that stream when `subprocess` ends.\n// This makes sure we wait for the completion of those streams, in order to catch any error.\nconst waitForCustomStreamsEnd = (fileDescriptors, streamInfo) => fileDescriptors.flatMap(({stdioItems}, fdNumber) => stdioItems\n\t.filter(({value, stream = value}) => isNodeStream(stream, {checkOpen: false}) && !isStandardStream(stream))\n\t.map(({type, value, stream = value}) => waitForStream(stream, fdNumber, streamInfo, {\n\t\tisSameDirection: TRANSFORM_TYPES.has(type),\n\t\tstopOnExit: type === 'native',\n\t})));\n\n// Fails when the subprocess emits an `error` event\nconst throwOnSubprocessError = async (subprocess, {signal}) => {\n\tconst [error] = await once(subprocess, 'error', {signal});\n\tthrow error;\n};\n"
  },
  {
    "path": "lib/return/duration.js",
    "content": "import {hrtime} from 'node:process';\n\n// Start counting time before spawning the subprocess\nexport const getStartTime = () => hrtime.bigint();\n\n// Compute duration after the subprocess ended.\n// Printed by the `verbose` option.\nexport const getDurationMs = startTime => Number(hrtime.bigint() - startTime) / 1e6;\n"
  },
  {
    "path": "lib/return/early-error.js",
    "content": "import {ChildProcess} from 'node:child_process';\nimport {\n\tPassThrough,\n\tReadable,\n\tWritable,\n\tDuplex,\n} from 'node:stream';\nimport {cleanupCustomStreams} from '../stdio/handle.js';\nimport {makeEarlyError} from './result.js';\nimport {handleResult} from './reject.js';\n\n// When the subprocess fails to spawn.\n// We ensure the returned error is always both a promise and a subprocess.\nexport const handleEarlyError = ({error, command, escapedCommand, fileDescriptors, options, startTime, verboseInfo}) => {\n\tcleanupCustomStreams(fileDescriptors);\n\n\tconst subprocess = new ChildProcess();\n\tcreateDummyStreams(subprocess, fileDescriptors);\n\tObject.assign(subprocess, {readable, writable, duplex});\n\n\tconst earlyError = makeEarlyError({\n\t\terror,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tfileDescriptors,\n\t\toptions,\n\t\tstartTime,\n\t\tisSync: false,\n\t});\n\tconst promise = handleDummyPromise(earlyError, verboseInfo, options);\n\treturn {subprocess, promise};\n};\n\nconst createDummyStreams = (subprocess, fileDescriptors) => {\n\tconst stdin = createDummyStream();\n\tconst stdout = createDummyStream();\n\tconst stderr = createDummyStream();\n\tconst extraStdio = Array.from({length: fileDescriptors.length - 3}, createDummyStream);\n\tconst all = createDummyStream();\n\tconst stdio = [stdin, stdout, stderr, ...extraStdio];\n\tObject.assign(subprocess, {\n\t\tstdin,\n\t\tstdout,\n\t\tstderr,\n\t\tall,\n\t\tstdio,\n\t});\n};\n\nconst createDummyStream = () => {\n\tconst stream = new PassThrough();\n\tstream.end();\n\treturn stream;\n};\n\nconst readable = () => new Readable({read() {}});\nconst writable = () => new Writable({write() {}});\nconst duplex = () => new Duplex({read() {}, write() {}});\n\nconst handleDummyPromise = async (error, verboseInfo, options) => handleResult(error, verboseInfo, options);\n"
  },
  {
    "path": "lib/return/final-error.js",
    "content": "// When the subprocess fails, this is the error instance being returned.\n// If another error instance is being thrown, it is kept as `error.cause`.\nexport const getFinalError = (originalError, message, isSync) => {\n\tconst ErrorClass = isSync ? ExecaSyncError : ExecaError;\n\tconst options = originalError instanceof DiscardedError ? {} : {cause: originalError};\n\treturn new ErrorClass(message, options);\n};\n\n// Indicates that the error is used only to interrupt control flow, but not in the return value\nexport class DiscardedError extends Error {}\n\n// Proper way to set `error.name`: it should be inherited and non-enumerable\nconst setErrorName = (ErrorClass, value) => {\n\tObject.defineProperty(ErrorClass.prototype, 'name', {\n\t\tvalue,\n\t\twritable: true,\n\t\tenumerable: false,\n\t\tconfigurable: true,\n\t});\n\tObject.defineProperty(ErrorClass.prototype, execaErrorSymbol, {\n\t\tvalue: true,\n\t\twritable: false,\n\t\tenumerable: false,\n\t\tconfigurable: false,\n\t});\n};\n\n// Unlike `instanceof`, this works across realms\nexport const isExecaError = error => isErrorInstance(error) && execaErrorSymbol in error;\n\nconst execaErrorSymbol = Symbol('isExecaError');\n\nexport const isErrorInstance = value => Object.prototype.toString.call(value) === '[object Error]';\n\n// We use two different Error classes for async/sync methods since they have slightly different shape and types\nexport class ExecaError extends Error {}\nsetErrorName(ExecaError, ExecaError.name);\n\nexport class ExecaSyncError extends Error {}\nsetErrorName(ExecaSyncError, ExecaSyncError.name);\n"
  },
  {
    "path": "lib/return/message.js",
    "content": "import {inspect} from 'node:util';\nimport stripFinalNewline from 'strip-final-newline';\nimport {isUint8Array, uint8ArrayToString} from '../utils/uint-array.js';\nimport {fixCwdError} from '../arguments/cwd.js';\nimport {escapeLines} from '../arguments/escape.js';\nimport {getMaxBufferMessage} from '../io/max-buffer.js';\nimport {getSignalDescription} from '../terminate/signal.js';\nimport {DiscardedError, isExecaError} from './final-error.js';\n\n// Computes `error.message`, `error.shortMessage` and `error.originalMessage`\nexport const createMessages = ({\n\tstdio,\n\tall,\n\tipcOutput,\n\toriginalError,\n\tsignal,\n\tsignalDescription,\n\texitCode,\n\tescapedCommand,\n\ttimedOut,\n\tisCanceled,\n\tisGracefullyCanceled,\n\tisMaxBuffer,\n\tisForcefullyTerminated,\n\tforceKillAfterDelay,\n\tkillSignal,\n\tmaxBuffer,\n\ttimeout,\n\tcwd,\n}) => {\n\tconst errorCode = originalError?.code;\n\tconst prefix = getErrorPrefix({\n\t\toriginalError,\n\t\ttimedOut,\n\t\ttimeout,\n\t\tisMaxBuffer,\n\t\tmaxBuffer,\n\t\terrorCode,\n\t\tsignal,\n\t\tsignalDescription,\n\t\texitCode,\n\t\tisCanceled,\n\t\tisGracefullyCanceled,\n\t\tisForcefullyTerminated,\n\t\tforceKillAfterDelay,\n\t\tkillSignal,\n\t});\n\tconst originalMessage = getOriginalMessage(originalError, cwd);\n\tconst suffix = originalMessage === undefined ? '' : `\\n${originalMessage}`;\n\tconst shortMessage = `${prefix}: ${escapedCommand}${suffix}`;\n\tconst messageStdio = all === undefined ? [stdio[2], stdio[1]] : [all];\n\tconst message = [\n\t\tshortMessage,\n\t\t...messageStdio,\n\t\t...stdio.slice(3),\n\t\tipcOutput.map(ipcMessage => serializeIpcMessage(ipcMessage)).join('\\n'),\n\t]\n\t\t.map(messagePart => escapeLines(stripFinalNewline(serializeMessagePart(messagePart))))\n\t\t.filter(Boolean)\n\t\t.join('\\n\\n');\n\treturn {originalMessage, shortMessage, message};\n};\n\nconst getErrorPrefix = ({\n\toriginalError,\n\ttimedOut,\n\ttimeout,\n\tisMaxBuffer,\n\tmaxBuffer,\n\terrorCode,\n\tsignal,\n\tsignalDescription,\n\texitCode,\n\tisCanceled,\n\tisGracefullyCanceled,\n\tisForcefullyTerminated,\n\tforceKillAfterDelay,\n\tkillSignal,\n}) => {\n\tconst forcefulSuffix = getForcefulSuffix(isForcefullyTerminated, forceKillAfterDelay);\n\n\tif (timedOut) {\n\t\treturn `Command timed out after ${timeout} milliseconds${forcefulSuffix}`;\n\t}\n\n\tif (isGracefullyCanceled) {\n\t\tif (signal === undefined) {\n\t\t\treturn `Command was gracefully canceled with exit code ${exitCode}`;\n\t\t}\n\n\t\treturn isForcefullyTerminated\n\t\t\t? `Command was gracefully canceled${forcefulSuffix}`\n\t\t\t: `Command was gracefully canceled with ${signal} (${signalDescription})`;\n\t}\n\n\tif (isCanceled) {\n\t\treturn `Command was canceled${forcefulSuffix}`;\n\t}\n\n\tif (isMaxBuffer) {\n\t\treturn `${getMaxBufferMessage(originalError, maxBuffer)}${forcefulSuffix}`;\n\t}\n\n\tif (errorCode !== undefined) {\n\t\treturn `Command failed with ${errorCode}${forcefulSuffix}`;\n\t}\n\n\tif (isForcefullyTerminated) {\n\t\treturn `Command was killed with ${killSignal} (${getSignalDescription(killSignal)})${forcefulSuffix}`;\n\t}\n\n\tif (signal !== undefined) {\n\t\treturn `Command was killed with ${signal} (${signalDescription})`;\n\t}\n\n\tif (exitCode !== undefined) {\n\t\treturn `Command failed with exit code ${exitCode}`;\n\t}\n\n\treturn 'Command failed';\n};\n\nconst getForcefulSuffix = (isForcefullyTerminated, forceKillAfterDelay) => isForcefullyTerminated\n\t? ` and was forcefully terminated after ${forceKillAfterDelay} milliseconds`\n\t: '';\n\nconst getOriginalMessage = (originalError, cwd) => {\n\tif (originalError instanceof DiscardedError) {\n\t\treturn;\n\t}\n\n\tconst originalMessage = isExecaError(originalError)\n\t\t? originalError.originalMessage\n\t\t: String(originalError?.message ?? originalError);\n\tconst escapedOriginalMessage = escapeLines(fixCwdError(originalMessage, cwd));\n\treturn escapedOriginalMessage === '' ? undefined : escapedOriginalMessage;\n};\n\nconst serializeIpcMessage = ipcMessage => typeof ipcMessage === 'string'\n\t? ipcMessage\n\t: inspect(ipcMessage);\n\nconst serializeMessagePart = messagePart => Array.isArray(messagePart)\n\t? messagePart.map(messageItem => stripFinalNewline(serializeMessageItem(messageItem))).filter(Boolean).join('\\n')\n\t: serializeMessageItem(messagePart);\n\nconst serializeMessageItem = messageItem => {\n\tif (typeof messageItem === 'string') {\n\t\treturn messageItem;\n\t}\n\n\tif (isUint8Array(messageItem)) {\n\t\treturn uint8ArrayToString(messageItem);\n\t}\n\n\treturn '';\n};\n"
  },
  {
    "path": "lib/return/reject.js",
    "content": "import {logResult} from '../verbose/complete.js';\n\n// Applies the `reject` option.\n// Also print the final log line with `verbose`.\nexport const handleResult = (result, verboseInfo, {reject}) => {\n\tlogResult(result, verboseInfo);\n\n\tif (result.failed && reject) {\n\t\tthrow result;\n\t}\n\n\treturn result;\n};\n"
  },
  {
    "path": "lib/return/result.js",
    "content": "import {getSignalDescription} from '../terminate/signal.js';\nimport {getDurationMs} from './duration.js';\nimport {getFinalError} from './final-error.js';\nimport {createMessages} from './message.js';\n\n// Object returned on subprocess success\nexport const makeSuccessResult = ({\n\tcommand,\n\tescapedCommand,\n\tstdio,\n\tall,\n\tipcOutput,\n\toptions: {cwd},\n\tstartTime,\n}) => omitUndefinedProperties({\n\tcommand,\n\tescapedCommand,\n\tcwd,\n\tdurationMs: getDurationMs(startTime),\n\tfailed: false,\n\ttimedOut: false,\n\tisCanceled: false,\n\tisGracefullyCanceled: false,\n\tisTerminated: false,\n\tisMaxBuffer: false,\n\tisForcefullyTerminated: false,\n\texitCode: 0,\n\tstdout: stdio[1],\n\tstderr: stdio[2],\n\tall,\n\tstdio,\n\tipcOutput,\n\tpipedFrom: [],\n});\n\n// Object returned on subprocess failure before spawning\nexport const makeEarlyError = ({\n\terror,\n\tcommand,\n\tescapedCommand,\n\tfileDescriptors,\n\toptions,\n\tstartTime,\n\tisSync,\n}) => makeError({\n\terror,\n\tcommand,\n\tescapedCommand,\n\tstartTime,\n\ttimedOut: false,\n\tisCanceled: false,\n\tisGracefullyCanceled: false,\n\tisMaxBuffer: false,\n\tisForcefullyTerminated: false,\n\tstdio: Array.from({length: fileDescriptors.length}),\n\tipcOutput: [],\n\toptions,\n\tisSync,\n});\n\n// Object returned on subprocess failure\nexport const makeError = ({\n\terror: originalError,\n\tcommand,\n\tescapedCommand,\n\tstartTime,\n\ttimedOut,\n\tisCanceled,\n\tisGracefullyCanceled,\n\tisMaxBuffer,\n\tisForcefullyTerminated,\n\texitCode: rawExitCode,\n\tsignal: rawSignal,\n\tstdio,\n\tall,\n\tipcOutput,\n\toptions: {\n\t\ttimeoutDuration,\n\t\ttimeout = timeoutDuration,\n\t\tforceKillAfterDelay,\n\t\tkillSignal,\n\t\tcwd,\n\t\tmaxBuffer,\n\t},\n\tisSync,\n}) => {\n\tconst {exitCode, signal, signalDescription} = normalizeExitPayload(rawExitCode, rawSignal);\n\tconst {originalMessage, shortMessage, message} = createMessages({\n\t\tstdio,\n\t\tall,\n\t\tipcOutput,\n\t\toriginalError,\n\t\tsignal,\n\t\tsignalDescription,\n\t\texitCode,\n\t\tescapedCommand,\n\t\ttimedOut,\n\t\tisCanceled,\n\t\tisGracefullyCanceled,\n\t\tisMaxBuffer,\n\t\tisForcefullyTerminated,\n\t\tforceKillAfterDelay,\n\t\tkillSignal,\n\t\tmaxBuffer,\n\t\ttimeout,\n\t\tcwd,\n\t});\n\tconst error = getFinalError(originalError, message, isSync);\n\tObject.assign(error, getErrorProperties({\n\t\terror,\n\t\tcommand,\n\t\tescapedCommand,\n\t\tstartTime,\n\t\ttimedOut,\n\t\tisCanceled,\n\t\tisGracefullyCanceled,\n\t\tisMaxBuffer,\n\t\tisForcefullyTerminated,\n\t\texitCode,\n\t\tsignal,\n\t\tsignalDescription,\n\t\tstdio,\n\t\tall,\n\t\tipcOutput,\n\t\tcwd,\n\t\toriginalMessage,\n\t\tshortMessage,\n\t}));\n\treturn error;\n};\n\nconst getErrorProperties = ({\n\terror,\n\tcommand,\n\tescapedCommand,\n\tstartTime,\n\ttimedOut,\n\tisCanceled,\n\tisGracefullyCanceled,\n\tisMaxBuffer,\n\tisForcefullyTerminated,\n\texitCode,\n\tsignal,\n\tsignalDescription,\n\tstdio,\n\tall,\n\tipcOutput,\n\tcwd,\n\toriginalMessage,\n\tshortMessage,\n}) => omitUndefinedProperties({\n\tshortMessage,\n\toriginalMessage,\n\tcommand,\n\tescapedCommand,\n\tcwd,\n\tdurationMs: getDurationMs(startTime),\n\tfailed: true,\n\ttimedOut,\n\tisCanceled,\n\tisGracefullyCanceled,\n\tisTerminated: signal !== undefined,\n\tisMaxBuffer,\n\tisForcefullyTerminated,\n\texitCode,\n\tsignal,\n\tsignalDescription,\n\tcode: error.cause?.code,\n\tstdout: stdio[1],\n\tstderr: stdio[2],\n\tall,\n\tstdio,\n\tipcOutput,\n\tpipedFrom: [],\n});\n\nconst omitUndefinedProperties = result => Object.fromEntries(Object.entries(result).filter(([, value]) => value !== undefined));\n\n// `signal` and `exitCode` emitted on `subprocess.on('exit')` event can be `null`.\n// We normalize them to `undefined`\nconst normalizeExitPayload = (rawExitCode, rawSignal) => {\n\tconst exitCode = rawExitCode === null ? undefined : rawExitCode;\n\tconst signal = rawSignal === null ? undefined : rawSignal;\n\tconst signalDescription = signal === undefined ? undefined : getSignalDescription(rawSignal);\n\treturn {exitCode, signal, signalDescription};\n};\n"
  },
  {
    "path": "lib/stdio/direction.js",
    "content": "import process from 'node:process';\nimport {\n\tisStream as isNodeStream,\n\tisReadableStream as isNodeReadableStream,\n\tisWritableStream as isNodeWritableStream,\n} from 'is-stream';\nimport {isWritableStream} from './type.js';\n\n// For `stdio[fdNumber]` beyond stdin/stdout/stderr, we need to guess whether the value passed is intended for inputs or outputs.\n// This allows us to know whether to pipe _into_ or _from_ the stream.\n// When `stdio[fdNumber]` is a single value, this guess is fairly straightforward.\n// However, when it is an array instead, we also need to make sure the different values are not incompatible with each other.\nexport const getStreamDirection = (stdioItems, fdNumber, optionName) => {\n\tconst directions = stdioItems.map(stdioItem => getStdioItemDirection(stdioItem, fdNumber));\n\n\tif (directions.includes('input') && directions.includes('output')) {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option must not be an array of both readable and writable values.`);\n\t}\n\n\treturn directions.find(Boolean) ?? DEFAULT_DIRECTION;\n};\n\nconst getStdioItemDirection = ({type, value}, fdNumber) => KNOWN_DIRECTIONS[fdNumber] ?? guessStreamDirection[type](value);\n\n// `stdin`/`stdout`/`stderr` have a known direction\nconst KNOWN_DIRECTIONS = ['input', 'output', 'output'];\n\nconst anyDirection = () => undefined;\nconst alwaysInput = () => 'input';\n\n// `string` can only be added through the `input` option, i.e. does not need to be handled here\nconst guessStreamDirection = {\n\tgenerator: anyDirection,\n\tasyncGenerator: anyDirection,\n\tfileUrl: anyDirection,\n\tfilePath: anyDirection,\n\titerable: alwaysInput,\n\tasyncIterable: alwaysInput,\n\tuint8Array: alwaysInput,\n\twebStream: value => isWritableStream(value) ? 'output' : 'input',\n\tnodeStream(value) {\n\t\tif (!isNodeReadableStream(value, {checkOpen: false})) {\n\t\t\treturn 'output';\n\t\t}\n\n\t\treturn isNodeWritableStream(value, {checkOpen: false}) ? undefined : 'input';\n\t},\n\twebTransform: anyDirection,\n\tduplex: anyDirection,\n\tnative(value) {\n\t\tconst standardStreamDirection = getStandardStreamDirection(value);\n\t\tif (standardStreamDirection !== undefined) {\n\t\t\treturn standardStreamDirection;\n\t\t}\n\n\t\tif (isNodeStream(value, {checkOpen: false})) {\n\t\t\treturn guessStreamDirection.nodeStream(value);\n\t\t}\n\t},\n};\n\nconst getStandardStreamDirection = value => {\n\tif ([0, process.stdin].includes(value)) {\n\t\treturn 'input';\n\t}\n\n\tif ([1, 2, process.stdout, process.stderr].includes(value)) {\n\t\treturn 'output';\n\t}\n};\n\n// When ambiguous, we initially keep the direction as `undefined`.\n// This allows arrays of `stdio` values to resolve the ambiguity.\n// For example, `stdio[3]: DuplexStream` is ambiguous, but `stdio[3]: [DuplexStream, WritableStream]` is not.\n// When the ambiguity remains, we default to `output` since it is the most common use case for additional file descriptors.\nconst DEFAULT_DIRECTION = 'output';\n"
  },
  {
    "path": "lib/stdio/duplicate.js",
    "content": "import {\n\tSPECIAL_DUPLICATE_TYPES_SYNC,\n\tSPECIAL_DUPLICATE_TYPES,\n\tFORBID_DUPLICATE_TYPES,\n\tTYPE_TO_MESSAGE,\n} from './type.js';\n\n// Duplicates in the same file descriptor is most likely an error.\n// However, this can be useful with generators.\nexport const filterDuplicates = stdioItems => stdioItems.filter((stdioItemOne, indexOne) =>\n\tstdioItems.every((stdioItemTwo, indexTwo) => stdioItemOne.value !== stdioItemTwo.value\n\t\t|| indexOne >= indexTwo\n\t\t|| stdioItemOne.type === 'generator'\n\t\t|| stdioItemOne.type === 'asyncGenerator'));\n\n// Check if two file descriptors are sharing the same target.\n// For example `{stdout: {file: './output.txt'}, stderr: {file: './output.txt'}}`.\nexport const getDuplicateStream = ({stdioItem: {type, value, optionName}, direction, fileDescriptors, isSync}) => {\n\tconst otherStdioItems = getOtherStdioItems(fileDescriptors, type);\n\tif (otherStdioItems.length === 0) {\n\t\treturn;\n\t}\n\n\tif (isSync) {\n\t\tvalidateDuplicateStreamSync({\n\t\t\totherStdioItems,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\toptionName,\n\t\t\tdirection,\n\t\t});\n\t\treturn;\n\t}\n\n\tif (SPECIAL_DUPLICATE_TYPES.has(type)) {\n\t\treturn getDuplicateStreamInstance({\n\t\t\totherStdioItems,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\toptionName,\n\t\t\tdirection,\n\t\t});\n\t}\n\n\tif (FORBID_DUPLICATE_TYPES.has(type)) {\n\t\tvalidateDuplicateTransform({\n\t\t\totherStdioItems,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\toptionName,\n\t\t});\n\t}\n};\n\n// Values shared by multiple file descriptors\nconst getOtherStdioItems = (fileDescriptors, type) => fileDescriptors\n\t.flatMap(({direction, stdioItems}) => stdioItems\n\t\t.filter(stdioItem => stdioItem.type === type)\n\t\t.map((stdioItem => ({...stdioItem, direction}))));\n\n// With `execaSync()`, do not allow setting a file path both in input and output\nconst validateDuplicateStreamSync = ({otherStdioItems, type, value, optionName, direction}) => {\n\tif (SPECIAL_DUPLICATE_TYPES_SYNC.has(type)) {\n\t\tgetDuplicateStreamInstance({\n\t\t\totherStdioItems,\n\t\t\ttype,\n\t\t\tvalue,\n\t\t\toptionName,\n\t\t\tdirection,\n\t\t});\n\t}\n};\n\n// When two file descriptors share the file or stream, we need to re-use the same underlying stream.\n// Otherwise, the stream would be closed twice when piping ends.\n// This is only an issue with output file descriptors.\n// This is not a problem with generator functions since those create a new instance for each file descriptor.\n// We also forbid input and output file descriptors sharing the same file or stream, since that does not make sense.\nconst getDuplicateStreamInstance = ({otherStdioItems, type, value, optionName, direction}) => {\n\tconst duplicateStdioItems = otherStdioItems.filter(stdioItem => hasSameValue(stdioItem, value));\n\tif (duplicateStdioItems.length === 0) {\n\t\treturn;\n\t}\n\n\tconst differentStdioItem = duplicateStdioItems.find(stdioItem => stdioItem.direction !== direction);\n\tthrowOnDuplicateStream(differentStdioItem, optionName, type);\n\n\treturn direction === 'output' ? duplicateStdioItems[0].stream : undefined;\n};\n\nconst hasSameValue = ({type, value}, secondValue) => {\n\tif (type === 'filePath') {\n\t\treturn value.file === secondValue.file;\n\t}\n\n\tif (type === 'fileUrl') {\n\t\treturn value.href === secondValue.href;\n\t}\n\n\treturn value === secondValue;\n};\n\n// We do not allow two file descriptors to share the same Duplex or TransformStream.\n// This is because those are set directly to `subprocess.std*`.\n// For example, this could result in `subprocess.stdout` and `subprocess.stderr` being the same value.\n// This means reading from either would get data from both stdout and stderr.\nconst validateDuplicateTransform = ({otherStdioItems, type, value, optionName}) => {\n\tconst duplicateStdioItem = otherStdioItems.find(({value: {transform}}) => transform === value.transform);\n\tthrowOnDuplicateStream(duplicateStdioItem, optionName, type);\n};\n\nconst throwOnDuplicateStream = (stdioItem, optionName, type) => {\n\tif (stdioItem !== undefined) {\n\t\tthrow new TypeError(`The \\`${stdioItem.optionName}\\` and \\`${optionName}\\` options must not target ${TYPE_TO_MESSAGE[type]} that is the same.`);\n\t}\n};\n"
  },
  {
    "path": "lib/stdio/handle-async.js",
    "content": "import {createReadStream, createWriteStream} from 'node:fs';\nimport {Buffer} from 'node:buffer';\nimport {Readable, Writable, Duplex} from 'node:stream';\nimport {generatorToStream} from '../transform/generator.js';\nimport {handleStdio} from './handle.js';\nimport {TYPE_TO_MESSAGE} from './type.js';\n\n// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async mode\nexport const handleStdioAsync = (options, verboseInfo) => handleStdio(addPropertiesAsync, options, verboseInfo, false);\n\nconst forbiddenIfAsync = ({type, optionName}) => {\n\tthrow new TypeError(`The \\`${optionName}\\` option cannot be ${TYPE_TO_MESSAGE[type]}.`);\n};\n\n// Create streams used internally for piping when using specific values for the `std*` options, in async mode.\n// For example, `stdout: {file}` creates a file stream, which is piped from/to.\nconst addProperties = {\n\tfileNumber: forbiddenIfAsync,\n\tgenerator: generatorToStream,\n\tasyncGenerator: generatorToStream,\n\tnodeStream: ({value}) => ({stream: value}),\n\twebTransform({value: {transform, writableObjectMode, readableObjectMode}}) {\n\t\tconst objectMode = writableObjectMode || readableObjectMode;\n\t\tconst stream = Duplex.fromWeb(transform, {objectMode});\n\t\treturn {stream};\n\t},\n\tduplex: ({value: {transform}}) => ({stream: transform}),\n\tnative() {},\n};\n\nconst addPropertiesAsync = {\n\tinput: {\n\t\t...addProperties,\n\t\tfileUrl: ({value}) => ({stream: createReadStream(value)}),\n\t\tfilePath: ({value: {file}}) => ({stream: createReadStream(file)}),\n\t\twebStream: ({value}) => ({stream: Readable.fromWeb(value)}),\n\t\titerable: ({value}) => ({stream: Readable.from(value)}),\n\t\tasyncIterable: ({value}) => ({stream: Readable.from(value)}),\n\t\tstring: ({value}) => ({stream: Readable.from(value)}),\n\t\tuint8Array: ({value}) => ({stream: Readable.from(Buffer.from(value))}),\n\t},\n\toutput: {\n\t\t...addProperties,\n\t\tfileUrl: ({value}) => ({stream: createWriteStream(value)}),\n\t\tfilePath: ({value: {file, append}}) => ({stream: createWriteStream(file, append ? {flags: 'a'} : {})}),\n\t\twebStream: ({value}) => ({stream: Writable.fromWeb(value)}),\n\t\titerable: forbiddenIfAsync,\n\t\tasyncIterable: forbiddenIfAsync,\n\t\tstring: forbiddenIfAsync,\n\t\tuint8Array: forbiddenIfAsync,\n\t},\n};\n"
  },
  {
    "path": "lib/stdio/handle-sync.js",
    "content": "import {readFileSync} from 'node:fs';\nimport {bufferToUint8Array} from '../utils/uint-array.js';\nimport {handleStdio} from './handle.js';\nimport {TYPE_TO_MESSAGE} from './type.js';\n\n// Normalize `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in sync mode\nexport const handleStdioSync = (options, verboseInfo) => handleStdio(addPropertiesSync, options, verboseInfo, true);\n\nconst forbiddenIfSync = ({type, optionName}) => {\n\tthrowInvalidSyncValue(optionName, TYPE_TO_MESSAGE[type]);\n};\n\nconst forbiddenNativeIfSync = ({optionName, value}) => {\n\tif (value === 'ipc' || value === 'overlapped') {\n\t\tthrowInvalidSyncValue(optionName, `\"${value}\"`);\n\t}\n\n\treturn {};\n};\n\nconst throwInvalidSyncValue = (optionName, value) => {\n\tthrow new TypeError(`The \\`${optionName}\\` option cannot be ${value} with synchronous methods.`);\n};\n\n// Create streams used internally for redirecting when using specific values for the `std*` options, in sync mode.\n// For example, `stdin: {file}` reads the file synchronously, then passes it as the `input` option.\nconst addProperties = {\n\tgenerator() {},\n\tasyncGenerator: forbiddenIfSync,\n\twebStream: forbiddenIfSync,\n\tnodeStream: forbiddenIfSync,\n\twebTransform: forbiddenIfSync,\n\tduplex: forbiddenIfSync,\n\tasyncIterable: forbiddenIfSync,\n\tnative: forbiddenNativeIfSync,\n};\n\nconst addPropertiesSync = {\n\tinput: {\n\t\t...addProperties,\n\t\tfileUrl: ({value}) => ({contents: [bufferToUint8Array(readFileSync(value))]}),\n\t\tfilePath: ({value: {file}}) => ({contents: [bufferToUint8Array(readFileSync(file))]}),\n\t\tfileNumber: forbiddenIfSync,\n\t\titerable: ({value}) => ({contents: [...value]}),\n\t\tstring: ({value}) => ({contents: [value]}),\n\t\tuint8Array: ({value}) => ({contents: [value]}),\n\t},\n\toutput: {\n\t\t...addProperties,\n\t\tfileUrl: ({value}) => ({path: value}),\n\t\tfilePath: ({value: {file, append}}) => ({path: file, append}),\n\t\tfileNumber: ({value}) => ({path: value}),\n\t\titerable: forbiddenIfSync,\n\t\tstring: forbiddenIfSync,\n\t\tuint8Array: forbiddenIfSync,\n\t},\n};\n"
  },
  {
    "path": "lib/stdio/handle.js",
    "content": "import {getStreamName, isStandardStream} from '../utils/standard-stream.js';\nimport {normalizeTransforms} from '../transform/normalize.js';\nimport {getFdObjectMode} from '../transform/object-mode.js';\nimport {\n\tgetStdioItemType,\n\tisRegularUrl,\n\tisUnknownStdioString,\n\tFILE_TYPES,\n} from './type.js';\nimport {getStreamDirection} from './direction.js';\nimport {normalizeStdioOption} from './stdio-option.js';\nimport {handleNativeStream} from './native.js';\nimport {handleInputOptions} from './input-option.js';\nimport {filterDuplicates, getDuplicateStream} from './duplicate.js';\n\n// Handle `input`, `inputFile`, `stdin`, `stdout` and `stderr` options, before spawning, in async/sync mode\n// They are converted into an array of `fileDescriptors`.\n// Each `fileDescriptor` is normalized, validated and contains all information necessary for further handling.\nexport const handleStdio = (addProperties, options, verboseInfo, isSync) => {\n\tconst stdio = normalizeStdioOption(options, verboseInfo, isSync);\n\tconst initialFileDescriptors = stdio.map((stdioOption, fdNumber) => getFileDescriptor({\n\t\tstdioOption,\n\t\tfdNumber,\n\t\toptions,\n\t\tisSync,\n\t}));\n\tconst fileDescriptors = getFinalFileDescriptors({\n\t\tinitialFileDescriptors,\n\t\taddProperties,\n\t\toptions,\n\t\tisSync,\n\t});\n\toptions.stdio = fileDescriptors.map(({stdioItems}) => forwardStdio(stdioItems));\n\treturn fileDescriptors;\n};\n\nconst getFileDescriptor = ({stdioOption, fdNumber, options, isSync}) => {\n\tconst optionName = getStreamName(fdNumber);\n\tconst {stdioItems: initialStdioItems, isStdioArray} = initializeStdioItems({\n\t\tstdioOption,\n\t\tfdNumber,\n\t\toptions,\n\t\toptionName,\n\t});\n\tconst direction = getStreamDirection(initialStdioItems, fdNumber, optionName);\n\tconst stdioItems = initialStdioItems.map(stdioItem => handleNativeStream({\n\t\tstdioItem,\n\t\tisStdioArray,\n\t\tfdNumber,\n\t\tdirection,\n\t\tisSync,\n\t}));\n\tconst normalizedStdioItems = normalizeTransforms(stdioItems, optionName, direction, options);\n\tconst objectMode = getFdObjectMode(normalizedStdioItems, direction);\n\tvalidateFileObjectMode(normalizedStdioItems, objectMode);\n\treturn {direction, objectMode, stdioItems: normalizedStdioItems};\n};\n\n// We make sure passing an array with a single item behaves the same as passing that item without an array.\n// This is what users would expect.\n// For example, `stdout: ['ignore']` behaves the same as `stdout: 'ignore'`.\nconst initializeStdioItems = ({stdioOption, fdNumber, options, optionName}) => {\n\tconst values = Array.isArray(stdioOption) ? stdioOption : [stdioOption];\n\tconst initialStdioItems = [\n\t\t...values.map(value => initializeStdioItem(value, optionName)),\n\t\t...handleInputOptions(options, fdNumber),\n\t];\n\n\tconst stdioItems = filterDuplicates(initialStdioItems);\n\tconst isStdioArray = stdioItems.length > 1;\n\tvalidateStdioArray(stdioItems, isStdioArray, optionName);\n\tvalidateStreams(stdioItems);\n\treturn {stdioItems, isStdioArray};\n};\n\nconst initializeStdioItem = (value, optionName) => ({\n\ttype: getStdioItemType(value, optionName),\n\tvalue,\n\toptionName,\n});\n\nconst validateStdioArray = (stdioItems, isStdioArray, optionName) => {\n\tif (stdioItems.length === 0) {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option must not be an empty array.`);\n\t}\n\n\tif (!isStdioArray) {\n\t\treturn;\n\t}\n\n\tfor (const {value, optionName} of stdioItems) {\n\t\tif (INVALID_STDIO_ARRAY_OPTIONS.has(value)) {\n\t\t\tthrow new Error(`The \\`${optionName}\\` option must not include \\`${value}\\`.`);\n\t\t}\n\t}\n};\n\n// Using those `stdio` values together with others for the same stream does not make sense, so we make it fail.\n// However, we do allow it if the array has a single item.\nconst INVALID_STDIO_ARRAY_OPTIONS = new Set(['ignore', 'ipc']);\n\nconst validateStreams = stdioItems => {\n\tfor (const stdioItem of stdioItems) {\n\t\tvalidateFileStdio(stdioItem);\n\t}\n};\n\nconst validateFileStdio = ({type, value, optionName}) => {\n\tif (isRegularUrl(value)) {\n\t\tthrow new TypeError(`The \\`${optionName}: URL\\` option must use the \\`file:\\` scheme.\nFor example, you can use the \\`pathToFileURL()\\` method of the \\`url\\` core module.`);\n\t}\n\n\tif (isUnknownStdioString(type, value)) {\n\t\tthrow new TypeError(`The \\`${optionName}: { file: '...' }\\` option must be used instead of \\`${optionName}: '...'\\`.`);\n\t}\n};\n\nconst validateFileObjectMode = (stdioItems, objectMode) => {\n\tif (!objectMode) {\n\t\treturn;\n\t}\n\n\tconst fileStdioItem = stdioItems.find(({type}) => FILE_TYPES.has(type));\n\tif (fileStdioItem !== undefined) {\n\t\tthrow new TypeError(`The \\`${fileStdioItem.optionName}\\` option cannot use both files and transforms in objectMode.`);\n\t}\n};\n\n// Some `stdio` values require Execa to create streams.\n// For example, file paths create file read/write streams.\n// Those transformations are specified in `addProperties`, which is both direction-specific and type-specific.\nconst getFinalFileDescriptors = ({initialFileDescriptors, addProperties, options, isSync}) => {\n\tconst fileDescriptors = [];\n\n\ttry {\n\t\tfor (const fileDescriptor of initialFileDescriptors) {\n\t\t\tfileDescriptors.push(getFinalFileDescriptor({\n\t\t\t\tfileDescriptor,\n\t\t\t\tfileDescriptors,\n\t\t\t\taddProperties,\n\t\t\t\toptions,\n\t\t\t\tisSync,\n\t\t\t}));\n\t\t}\n\n\t\treturn fileDescriptors;\n\t} catch (error) {\n\t\tcleanupCustomStreams(fileDescriptors);\n\t\tthrow error;\n\t}\n};\n\nconst getFinalFileDescriptor = ({\n\tfileDescriptor: {direction, objectMode, stdioItems},\n\tfileDescriptors,\n\taddProperties,\n\toptions,\n\tisSync,\n}) => {\n\tconst finalStdioItems = stdioItems.map(stdioItem => addStreamProperties({\n\t\tstdioItem,\n\t\taddProperties,\n\t\tdirection,\n\t\toptions,\n\t\tfileDescriptors,\n\t\tisSync,\n\t}));\n\treturn {direction, objectMode, stdioItems: finalStdioItems};\n};\n\nconst addStreamProperties = ({stdioItem, addProperties, direction, options, fileDescriptors, isSync}) => {\n\tconst duplicateStream = getDuplicateStream({\n\t\tstdioItem,\n\t\tdirection,\n\t\tfileDescriptors,\n\t\tisSync,\n\t});\n\n\tif (duplicateStream !== undefined) {\n\t\treturn {...stdioItem, stream: duplicateStream};\n\t}\n\n\treturn {\n\t\t...stdioItem,\n\t\t...addProperties[direction][stdioItem.type](stdioItem, options),\n\t};\n};\n\n// The stream error handling is performed by the piping logic above, which cannot be performed before subprocess spawning.\n// If the subprocess spawning fails (e.g. due to an invalid command), the streams need to be manually destroyed.\n// We need to create those streams before subprocess spawning, in case their creation fails, e.g. when passing an invalid generator as argument.\n// Like this, an exception would be thrown, which would prevent spawning a subprocess.\nexport const cleanupCustomStreams = fileDescriptors => {\n\tfor (const {stdioItems} of fileDescriptors) {\n\t\tfor (const {stream} of stdioItems) {\n\t\t\tif (stream !== undefined && !isStandardStream(stream)) {\n\t\t\t\tstream.destroy();\n\t\t\t}\n\t\t}\n\t}\n};\n\n// When the `std*: Iterable | WebStream | URL | filePath`, `input` or `inputFile` option is used, we pipe to `subprocess.std*`.\n// When the `std*: Array` option is used, we emulate some of the native values ('inherit', Node.js stream and file descriptor integer). To do so, we also need to pipe to `subprocess.std*`.\n// Therefore the `std*` options must be either `pipe` or `overlapped`. Other values do not set `subprocess.std*`.\nconst forwardStdio = stdioItems => {\n\tif (stdioItems.length > 1) {\n\t\treturn stdioItems.some(({value}) => value === 'overlapped') ? 'overlapped' : 'pipe';\n\t}\n\n\tconst [{type, value}] = stdioItems;\n\treturn type === 'native' ? value : 'pipe';\n};\n"
  },
  {
    "path": "lib/stdio/input-option.js",
    "content": "import {isReadableStream} from 'is-stream';\nimport {isUint8Array} from '../utils/uint-array.js';\nimport {isUrl, isFilePathString} from './type.js';\n\n// Append the `stdin` option with the `input` and `inputFile` options\nexport const handleInputOptions = ({input, inputFile}, fdNumber) => fdNumber === 0\n\t? [\n\t\t...handleInputOption(input),\n\t\t...handleInputFileOption(inputFile),\n\t]\n\t: [];\n\nconst handleInputOption = input => input === undefined ? [] : [{\n\ttype: getInputType(input),\n\tvalue: input,\n\toptionName: 'input',\n}];\n\nconst getInputType = input => {\n\tif (isReadableStream(input, {checkOpen: false})) {\n\t\treturn 'nodeStream';\n\t}\n\n\tif (typeof input === 'string') {\n\t\treturn 'string';\n\t}\n\n\tif (isUint8Array(input)) {\n\t\treturn 'uint8Array';\n\t}\n\n\tthrow new Error('The `input` option must be a string, a Uint8Array or a Node.js Readable stream.');\n};\n\nconst handleInputFileOption = inputFile => inputFile === undefined ? [] : [{\n\t...getInputFileType(inputFile),\n\toptionName: 'inputFile',\n}];\n\nconst getInputFileType = inputFile => {\n\tif (isUrl(inputFile)) {\n\t\treturn {type: 'fileUrl', value: inputFile};\n\t}\n\n\tif (isFilePathString(inputFile)) {\n\t\treturn {type: 'filePath', value: {file: inputFile}};\n\t}\n\n\tthrow new Error('The `inputFile` option must be a file path string or a file URL.');\n};\n"
  },
  {
    "path": "lib/stdio/native.js",
    "content": "import {readFileSync} from 'node:fs';\nimport tty from 'node:tty';\nimport {isStream as isNodeStream} from 'is-stream';\nimport {STANDARD_STREAMS} from '../utils/standard-stream.js';\nimport {bufferToUint8Array} from '../utils/uint-array.js';\nimport {serializeOptionValue} from '../arguments/fd-options.js';\n\n// When we use multiple `stdio` values for the same streams, we pass 'pipe' to `child_process.spawn()`.\n// We then emulate the piping done by core Node.js.\n// To do so, we transform the following values:\n//  - Node.js streams are marked as `type: nodeStream`\n//  - 'inherit' becomes `process.stdin|stdout|stderr`\n//  - any file descriptor integer becomes `process.stdio[fdNumber]`\n// All of the above transformations tell Execa to perform manual piping.\nexport const handleNativeStream = ({stdioItem, stdioItem: {type}, isStdioArray, fdNumber, direction, isSync}) => {\n\tif (!isStdioArray || type !== 'native') {\n\t\treturn stdioItem;\n\t}\n\n\treturn isSync\n\t\t? handleNativeStreamSync({stdioItem, fdNumber, direction})\n\t\t: handleNativeStreamAsync({stdioItem, fdNumber});\n};\n\n// Synchronous methods use a different logic.\n// 'inherit', file descriptors and process.std* are handled by readFileSync()/writeFileSync().\nconst handleNativeStreamSync = ({stdioItem, stdioItem: {value, optionName}, fdNumber, direction}) => {\n\tconst targetFd = getTargetFd({\n\t\tvalue,\n\t\toptionName,\n\t\tfdNumber,\n\t\tdirection,\n\t});\n\tif (targetFd !== undefined) {\n\t\treturn targetFd;\n\t}\n\n\tif (isNodeStream(value, {checkOpen: false})) {\n\t\tthrow new TypeError(`The \\`${optionName}: Stream\\` option cannot both be an array and include a stream with synchronous methods.`);\n\t}\n\n\treturn stdioItem;\n};\n\nconst getTargetFd = ({value, optionName, fdNumber, direction}) => {\n\tconst targetFdNumber = getTargetFdNumber(value, fdNumber);\n\tif (targetFdNumber === undefined) {\n\t\treturn;\n\t}\n\n\tif (direction === 'output') {\n\t\treturn {type: 'fileNumber', value: targetFdNumber, optionName};\n\t}\n\n\tif (tty.isatty(targetFdNumber)) {\n\t\tthrow new TypeError(`The \\`${optionName}: ${serializeOptionValue(value)}\\` option is invalid: it cannot be a TTY with synchronous methods.`);\n\t}\n\n\treturn {type: 'uint8Array', value: bufferToUint8Array(readFileSync(targetFdNumber)), optionName};\n};\n\nconst getTargetFdNumber = (value, fdNumber) => {\n\tif (value === 'inherit') {\n\t\treturn fdNumber;\n\t}\n\n\tif (typeof value === 'number') {\n\t\treturn value;\n\t}\n\n\tconst standardStreamIndex = STANDARD_STREAMS.indexOf(value);\n\tif (standardStreamIndex !== -1) {\n\t\treturn standardStreamIndex;\n\t}\n};\n\nconst handleNativeStreamAsync = ({stdioItem, stdioItem: {value, optionName}, fdNumber}) => {\n\tif (value === 'inherit') {\n\t\treturn {type: 'nodeStream', value: getStandardStream(fdNumber, value, optionName), optionName};\n\t}\n\n\tif (typeof value === 'number') {\n\t\treturn {type: 'nodeStream', value: getStandardStream(value, value, optionName), optionName};\n\t}\n\n\tif (isNodeStream(value, {checkOpen: false})) {\n\t\treturn {type: 'nodeStream', value, optionName};\n\t}\n\n\treturn stdioItem;\n};\n\n// Node.js does not allow to easily retrieve file descriptors beyond stdin/stdout/stderr as streams.\n//  - `fs.createReadStream()`/`fs.createWriteStream()` with the `fd` option do not work with character devices that use blocking reads/writes (such as interactive TTYs).\n//  - Using a TCP `Socket` would work but be rather complex to implement.\n// Since this is an edge case, we simply throw an error message.\n// See https://github.com/sindresorhus/execa/pull/643#discussion_r1435905707\nconst getStandardStream = (fdNumber, value, optionName) => {\n\tconst standardStream = STANDARD_STREAMS[fdNumber];\n\n\tif (standardStream === undefined) {\n\t\tthrow new TypeError(`The \\`${optionName}: ${value}\\` option is invalid: no such standard stream.`);\n\t}\n\n\treturn standardStream;\n};\n"
  },
  {
    "path": "lib/stdio/stdio-option.js",
    "content": "import {STANDARD_STREAMS_ALIASES} from '../utils/standard-stream.js';\nimport {normalizeIpcStdioArray} from '../ipc/array.js';\nimport {isFullVerbose} from '../verbose/values.js';\n\n// Add support for `stdin`/`stdout`/`stderr` as an alias for `stdio`.\n// Also normalize the `stdio` option.\nexport const normalizeStdioOption = ({stdio, ipc, buffer, ...options}, verboseInfo, isSync) => {\n\tconst stdioArray = getStdioArray(stdio, options).map((stdioOption, fdNumber) => addDefaultValue(stdioOption, fdNumber));\n\treturn isSync\n\t\t? normalizeStdioSync(stdioArray, buffer, verboseInfo)\n\t\t: normalizeIpcStdioArray(stdioArray, ipc);\n};\n\nconst getStdioArray = (stdio, options) => {\n\tif (stdio === undefined) {\n\t\treturn STANDARD_STREAMS_ALIASES.map(alias => options[alias]);\n\t}\n\n\tif (hasAlias(options)) {\n\t\tthrow new Error(`It's not possible to provide \\`stdio\\` in combination with one of ${STANDARD_STREAMS_ALIASES.map(alias => `\\`${alias}\\``).join(', ')}`);\n\t}\n\n\tif (typeof stdio === 'string') {\n\t\treturn [stdio, stdio, stdio];\n\t}\n\n\tif (!Array.isArray(stdio)) {\n\t\tthrow new TypeError(`Expected \\`stdio\\` to be of type \\`string\\` or \\`Array\\`, got \\`${typeof stdio}\\``);\n\t}\n\n\tconst length = Math.max(stdio.length, STANDARD_STREAMS_ALIASES.length);\n\treturn Array.from({length}, (_, fdNumber) => stdio[fdNumber]);\n};\n\nconst hasAlias = options => STANDARD_STREAMS_ALIASES.some(alias => options[alias] !== undefined);\n\nconst addDefaultValue = (stdioOption, fdNumber) => {\n\tif (Array.isArray(stdioOption)) {\n\t\treturn stdioOption.map(item => addDefaultValue(item, fdNumber));\n\t}\n\n\tif (stdioOption === null || stdioOption === undefined) {\n\t\treturn fdNumber >= STANDARD_STREAMS_ALIASES.length ? 'ignore' : 'pipe';\n\t}\n\n\treturn stdioOption;\n};\n\n// Using `buffer: false` with synchronous methods implies `stdout`/`stderr`: `ignore`.\n// Unless the output is needed, e.g. due to `verbose: 'full'` or to redirecting to a file.\nconst normalizeStdioSync = (stdioArray, buffer, verboseInfo) => stdioArray.map((stdioOption, fdNumber) =>\n\t!buffer[fdNumber]\n\t&& fdNumber !== 0\n\t&& !isFullVerbose(verboseInfo, fdNumber)\n\t&& isOutputPipeOnly(stdioOption)\n\t\t? 'ignore'\n\t\t: stdioOption);\n\nconst isOutputPipeOnly = stdioOption => stdioOption === 'pipe'\n\t|| (Array.isArray(stdioOption) && stdioOption.every(item => item === 'pipe'));\n"
  },
  {
    "path": "lib/stdio/type.js",
    "content": "import {isStream as isNodeStream, isDuplexStream} from 'is-stream';\nimport isPlainObj from 'is-plain-obj';\nimport {isUint8Array} from '../utils/uint-array.js';\n\n// The `stdin`/`stdout`/`stderr` option can be of many types. This detects it.\nexport const getStdioItemType = (value, optionName) => {\n\tif (isAsyncGenerator(value)) {\n\t\treturn 'asyncGenerator';\n\t}\n\n\tif (isSyncGenerator(value)) {\n\t\treturn 'generator';\n\t}\n\n\tif (isUrl(value)) {\n\t\treturn 'fileUrl';\n\t}\n\n\tif (isFilePathObject(value)) {\n\t\treturn 'filePath';\n\t}\n\n\tif (isWebStream(value)) {\n\t\treturn 'webStream';\n\t}\n\n\tif (isNodeStream(value, {checkOpen: false})) {\n\t\treturn 'native';\n\t}\n\n\tif (isUint8Array(value)) {\n\t\treturn 'uint8Array';\n\t}\n\n\tif (isAsyncIterableObject(value)) {\n\t\treturn 'asyncIterable';\n\t}\n\n\tif (isIterableObject(value)) {\n\t\treturn 'iterable';\n\t}\n\n\tif (isTransformStream(value)) {\n\t\treturn getTransformStreamType({transform: value}, optionName);\n\t}\n\n\tif (isTransformOptions(value)) {\n\t\treturn getTransformObjectType(value, optionName);\n\t}\n\n\treturn 'native';\n};\n\nconst getTransformObjectType = (value, optionName) => {\n\tif (isDuplexStream(value.transform, {checkOpen: false})) {\n\t\treturn getDuplexType(value, optionName);\n\t}\n\n\tif (isTransformStream(value.transform)) {\n\t\treturn getTransformStreamType(value, optionName);\n\t}\n\n\treturn getGeneratorObjectType(value, optionName);\n};\n\nconst getDuplexType = (value, optionName) => {\n\tvalidateNonGeneratorType(value, optionName, 'Duplex stream');\n\treturn 'duplex';\n};\n\nconst getTransformStreamType = (value, optionName) => {\n\tvalidateNonGeneratorType(value, optionName, 'web TransformStream');\n\treturn 'webTransform';\n};\n\nconst validateNonGeneratorType = ({final, binary, objectMode}, optionName, typeName) => {\n\tcheckUndefinedOption(final, `${optionName}.final`, typeName);\n\tcheckUndefinedOption(binary, `${optionName}.binary`, typeName);\n\tcheckBooleanOption(objectMode, `${optionName}.objectMode`);\n};\n\nconst checkUndefinedOption = (value, optionName, typeName) => {\n\tif (value !== undefined) {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option can only be defined when using a generator, not a ${typeName}.`);\n\t}\n};\n\nconst getGeneratorObjectType = ({transform, final, binary, objectMode}, optionName) => {\n\tif (transform !== undefined && !isGenerator(transform)) {\n\t\tthrow new TypeError(`The \\`${optionName}.transform\\` option must be a generator, a Duplex stream or a web TransformStream.`);\n\t}\n\n\tif (isDuplexStream(final, {checkOpen: false})) {\n\t\tthrow new TypeError(`The \\`${optionName}.final\\` option must not be a Duplex stream.`);\n\t}\n\n\tif (isTransformStream(final)) {\n\t\tthrow new TypeError(`The \\`${optionName}.final\\` option must not be a web TransformStream.`);\n\t}\n\n\tif (final !== undefined && !isGenerator(final)) {\n\t\tthrow new TypeError(`The \\`${optionName}.final\\` option must be a generator.`);\n\t}\n\n\tcheckBooleanOption(binary, `${optionName}.binary`);\n\tcheckBooleanOption(objectMode, `${optionName}.objectMode`);\n\n\treturn isAsyncGenerator(transform) || isAsyncGenerator(final) ? 'asyncGenerator' : 'generator';\n};\n\nconst checkBooleanOption = (value, optionName) => {\n\tif (value !== undefined && typeof value !== 'boolean') {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option must use a boolean.`);\n\t}\n};\n\nconst isGenerator = value => isAsyncGenerator(value) || isSyncGenerator(value);\nexport const isAsyncGenerator = value => Object.prototype.toString.call(value) === '[object AsyncGeneratorFunction]';\nconst isSyncGenerator = value => Object.prototype.toString.call(value) === '[object GeneratorFunction]';\nconst isTransformOptions = value => isPlainObj(value)\n\t&& (value.transform !== undefined || value.final !== undefined);\n\nexport const isUrl = value => Object.prototype.toString.call(value) === '[object URL]';\nexport const isRegularUrl = value => isUrl(value) && value.protocol !== 'file:';\n\nconst isFilePathObject = value => isPlainObj(value)\n\t&& Object.keys(value).length > 0\n\t&& Object.keys(value).every(key => FILE_PATH_KEYS.has(key))\n\t&& isFilePathString(value.file);\nconst FILE_PATH_KEYS = new Set(['file', 'append']);\nexport const isFilePathString = file => typeof file === 'string';\n\nexport const isUnknownStdioString = (type, value) => type === 'native'\n\t&& typeof value === 'string'\n\t&& !KNOWN_STDIO_STRINGS.has(value);\nconst KNOWN_STDIO_STRINGS = new Set(['ipc', 'ignore', 'inherit', 'overlapped', 'pipe']);\n\nconst isReadableStream = value => Object.prototype.toString.call(value) === '[object ReadableStream]';\nexport const isWritableStream = value => Object.prototype.toString.call(value) === '[object WritableStream]';\nconst isWebStream = value => isReadableStream(value) || isWritableStream(value);\nconst isTransformStream = value => isReadableStream(value?.readable) && isWritableStream(value?.writable);\n\nconst isAsyncIterableObject = value => isObject(value) && typeof value[Symbol.asyncIterator] === 'function';\nconst isIterableObject = value => isObject(value) && typeof value[Symbol.iterator] === 'function';\nconst isObject = value => typeof value === 'object' && value !== null;\n\n// Types which modify `subprocess.std*`\nexport const TRANSFORM_TYPES = new Set(['generator', 'asyncGenerator', 'duplex', 'webTransform']);\n// Types which write to a file or a file descriptor\nexport const FILE_TYPES = new Set(['fileUrl', 'filePath', 'fileNumber']);\n// When two file descriptors of this type share the same target, we need to do some special logic\nexport const SPECIAL_DUPLICATE_TYPES_SYNC = new Set(['fileUrl', 'filePath']);\nexport const SPECIAL_DUPLICATE_TYPES = new Set([...SPECIAL_DUPLICATE_TYPES_SYNC, 'webStream', 'nodeStream']);\n// Do not allow two file descriptors of this type sharing the same target\nexport const FORBID_DUPLICATE_TYPES = new Set(['webTransform', 'duplex']);\n\n// Convert types to human-friendly strings for error messages\nexport const TYPE_TO_MESSAGE = {\n\tgenerator: 'a generator',\n\tasyncGenerator: 'an async generator',\n\tfileUrl: 'a file URL',\n\tfilePath: 'a file path string',\n\tfileNumber: 'a file descriptor number',\n\twebStream: 'a web stream',\n\tnodeStream: 'a Node.js stream',\n\twebTransform: 'a web TransformStream',\n\tduplex: 'a Duplex stream',\n\tnative: 'any value',\n\titerable: 'an iterable',\n\tasyncIterable: 'an async iterable',\n\tstring: 'a string',\n\tuint8Array: 'a Uint8Array',\n};\n"
  },
  {
    "path": "lib/terminate/cancel.js",
    "content": "import {onAbortedSignal} from '../utils/abort-signal.js';\n\n// Validate the `cancelSignal` option\nexport const validateCancelSignal = ({cancelSignal}) => {\n\tif (cancelSignal !== undefined && Object.prototype.toString.call(cancelSignal) !== '[object AbortSignal]') {\n\t\tthrow new Error(`The \\`cancelSignal\\` option must be an AbortSignal: ${String(cancelSignal)}`);\n\t}\n};\n\n// Terminate the subprocess when aborting the `cancelSignal` option and `gracefulSignal` is `false`\nexport const throwOnCancel = ({subprocess, cancelSignal, gracefulCancel, context, controller}) => cancelSignal === undefined || gracefulCancel\n\t? []\n\t: [terminateOnCancel(subprocess, cancelSignal, context, controller)];\n\nconst terminateOnCancel = async (subprocess, cancelSignal, context, {signal}) => {\n\tawait onAbortedSignal(cancelSignal, signal);\n\tcontext.terminationReason ??= 'cancel';\n\tsubprocess.kill();\n\tthrow cancelSignal.reason;\n};\n"
  },
  {
    "path": "lib/terminate/cleanup.js",
    "content": "import {addAbortListener} from 'node:events';\nimport {onExit} from 'signal-exit';\n\n// If the `cleanup` option is used, call `subprocess.kill()` when the parent process exits\nexport const cleanupOnExit = (subprocess, {cleanup, detached}, {signal}) => {\n\tif (!cleanup || detached) {\n\t\treturn;\n\t}\n\n\tconst removeExitHandler = onExit(() => {\n\t\tsubprocess.kill();\n\t});\n\taddAbortListener(signal, () => {\n\t\tremoveExitHandler();\n\t});\n};\n"
  },
  {
    "path": "lib/terminate/graceful.js",
    "content": "import {onAbortedSignal} from '../utils/abort-signal.js';\nimport {sendAbort} from '../ipc/graceful.js';\nimport {killOnTimeout} from './kill.js';\n\n// Validate the `gracefulCancel` option\nexport const validateGracefulCancel = ({gracefulCancel, cancelSignal, ipc, serialization}) => {\n\tif (!gracefulCancel) {\n\t\treturn;\n\t}\n\n\tif (cancelSignal === undefined) {\n\t\tthrow new Error('The `cancelSignal` option must be defined when setting the `gracefulCancel` option.');\n\t}\n\n\tif (!ipc) {\n\t\tthrow new Error('The `ipc` option cannot be false when setting the `gracefulCancel` option.');\n\t}\n\n\tif (serialization === 'json') {\n\t\tthrow new Error('The `serialization` option cannot be \\'json\\' when setting the `gracefulCancel` option.');\n\t}\n};\n\n// Send abort reason to the subprocess when aborting the `cancelSignal` option and `gracefulCancel` is `true`\nexport const throwOnGracefulCancel = ({\n\tsubprocess,\n\tcancelSignal,\n\tgracefulCancel,\n\tforceKillAfterDelay,\n\tcontext,\n\tcontroller,\n}) => gracefulCancel\n\t? [sendOnAbort({\n\t\tsubprocess,\n\t\tcancelSignal,\n\t\tforceKillAfterDelay,\n\t\tcontext,\n\t\tcontroller,\n\t})]\n\t: [];\n\nconst sendOnAbort = async ({subprocess, cancelSignal, forceKillAfterDelay, context, controller: {signal}}) => {\n\tawait onAbortedSignal(cancelSignal, signal);\n\tconst reason = getReason(cancelSignal);\n\tawait sendAbort(subprocess, reason);\n\tkillOnTimeout({\n\t\tkill: subprocess.kill,\n\t\tforceKillAfterDelay,\n\t\tcontext,\n\t\tcontrollerSignal: signal,\n\t});\n\tcontext.terminationReason ??= 'gracefulCancel';\n\tthrow cancelSignal.reason;\n};\n\n// The default `reason` is a DOMException, which is not serializable with V8\n// See https://github.com/nodejs/node/issues/53225\nconst getReason = ({reason}) => {\n\tif (!(reason instanceof DOMException)) {\n\t\treturn reason;\n\t}\n\n\tconst error = new Error(reason.message);\n\tObject.defineProperty(error, 'stack', {\n\t\tvalue: reason.stack,\n\t\tenumerable: false,\n\t\tconfigurable: true,\n\t\twritable: true,\n\t});\n\treturn error;\n};\n"
  },
  {
    "path": "lib/terminate/kill.js",
    "content": "import {setTimeout} from 'node:timers/promises';\nimport {isErrorInstance} from '../return/final-error.js';\nimport {normalizeSignalArgument} from './signal.js';\n\n// Normalize the `forceKillAfterDelay` option\nexport const normalizeForceKillAfterDelay = forceKillAfterDelay => {\n\tif (forceKillAfterDelay === false) {\n\t\treturn forceKillAfterDelay;\n\t}\n\n\tif (forceKillAfterDelay === true) {\n\t\treturn DEFAULT_FORCE_KILL_TIMEOUT;\n\t}\n\n\tif (!Number.isFinite(forceKillAfterDelay) || forceKillAfterDelay < 0) {\n\t\tthrow new TypeError(`Expected the \\`forceKillAfterDelay\\` option to be a non-negative integer, got \\`${forceKillAfterDelay}\\` (${typeof forceKillAfterDelay})`);\n\t}\n\n\treturn forceKillAfterDelay;\n};\n\nconst DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;\n\n// Monkey-patches `subprocess.kill()` to add `forceKillAfterDelay` behavior and `.kill(error)`\nexport const subprocessKill = (\n\t{kill, options: {forceKillAfterDelay, killSignal}, onInternalError, context, controller},\n\tsignalOrError,\n\terrorArgument,\n) => {\n\tconst {signal, error} = parseKillArguments(signalOrError, errorArgument, killSignal);\n\temitKillError(error, onInternalError);\n\tconst killResult = kill(signal);\n\tsetKillTimeout({\n\t\tkill,\n\t\tsignal,\n\t\tforceKillAfterDelay,\n\t\tkillSignal,\n\t\tkillResult,\n\t\tcontext,\n\t\tcontroller,\n\t});\n\treturn killResult;\n};\n\nconst parseKillArguments = (signalOrError, errorArgument, killSignal) => {\n\tconst [signal = killSignal, error] = isErrorInstance(signalOrError)\n\t\t? [undefined, signalOrError]\n\t\t: [signalOrError, errorArgument];\n\n\tif (typeof signal !== 'string' && !Number.isInteger(signal)) {\n\t\tthrow new TypeError(`The first argument must be an error instance or a signal name string/integer: ${String(signal)}`);\n\t}\n\n\tif (error !== undefined && !isErrorInstance(error)) {\n\t\tthrow new TypeError(`The second argument is optional. If specified, it must be an error instance: ${error}`);\n\t}\n\n\treturn {signal: normalizeSignalArgument(signal), error};\n};\n\n// Fails right away when calling `subprocess.kill(error)`.\n// Does not wait for actual signal termination.\n// Uses a deferred promise instead of the `error` event on the subprocess, as this is less intrusive.\nconst emitKillError = (error, onInternalError) => {\n\tif (error !== undefined) {\n\t\tonInternalError.reject(error);\n\t}\n};\n\nconst setKillTimeout = async ({kill, signal, forceKillAfterDelay, killSignal, killResult, context, controller}) => {\n\tif (signal === killSignal && killResult) {\n\t\tkillOnTimeout({\n\t\t\tkill,\n\t\t\tforceKillAfterDelay,\n\t\t\tcontext,\n\t\t\tcontrollerSignal: controller.signal,\n\t\t});\n\t}\n};\n\n// Forcefully terminate a subprocess after a timeout\nexport const killOnTimeout = async ({kill, forceKillAfterDelay, context, controllerSignal}) => {\n\tif (forceKillAfterDelay === false) {\n\t\treturn;\n\t}\n\n\ttry {\n\t\tawait setTimeout(forceKillAfterDelay, undefined, {signal: controllerSignal});\n\t\tif (kill('SIGKILL')) {\n\t\t\tcontext.isForcefullyTerminated ??= true;\n\t\t}\n\t} catch {}\n};\n"
  },
  {
    "path": "lib/terminate/signal.js",
    "content": "import {constants} from 'node:os';\nimport {signalsByName} from 'human-signals';\n\n// Normalize signals for comparison purpose.\n// Also validate the signal exists.\nexport const normalizeKillSignal = killSignal => {\n\tconst optionName = 'option `killSignal`';\n\tif (killSignal === 0) {\n\t\tthrow new TypeError(`Invalid ${optionName}: 0 cannot be used.`);\n\t}\n\n\treturn normalizeSignal(killSignal, optionName);\n};\n\nexport const normalizeSignalArgument = signal => signal === 0\n\t? signal\n\t: normalizeSignal(signal, '`subprocess.kill()`\\'s argument');\n\nconst normalizeSignal = (signalNameOrInteger, optionName) => {\n\tif (Number.isInteger(signalNameOrInteger)) {\n\t\treturn normalizeSignalInteger(signalNameOrInteger, optionName);\n\t}\n\n\tif (typeof signalNameOrInteger === 'string') {\n\t\treturn normalizeSignalName(signalNameOrInteger, optionName);\n\t}\n\n\tthrow new TypeError(`Invalid ${optionName} ${String(signalNameOrInteger)}: it must be a string or an integer.\\n${getAvailableSignals()}`);\n};\n\nconst normalizeSignalInteger = (signalInteger, optionName) => {\n\tif (signalsIntegerToName.has(signalInteger)) {\n\t\treturn signalsIntegerToName.get(signalInteger);\n\t}\n\n\tthrow new TypeError(`Invalid ${optionName} ${signalInteger}: this signal integer does not exist.\\n${getAvailableSignals()}`);\n};\n\nconst getSignalsIntegerToName = () => new Map(Object.entries(constants.signals)\n\t.reverse()\n\t.map(([signalName, signalInteger]) => [signalInteger, signalName]));\n\nconst signalsIntegerToName = getSignalsIntegerToName();\n\nconst normalizeSignalName = (signalName, optionName) => {\n\tif (signalName in constants.signals) {\n\t\treturn signalName;\n\t}\n\n\tif (signalName.toUpperCase() in constants.signals) {\n\t\tthrow new TypeError(`Invalid ${optionName} '${signalName}': please rename it to '${signalName.toUpperCase()}'.`);\n\t}\n\n\tthrow new TypeError(`Invalid ${optionName} '${signalName}': this signal name does not exist.\\n${getAvailableSignals()}`);\n};\n\nconst getAvailableSignals = () => `Available signal names: ${getAvailableSignalNames()}.\nAvailable signal numbers: ${getAvailableSignalIntegers()}.`;\n\nconst getAvailableSignalNames = () => Object.keys(constants.signals)\n\t.sort()\n\t.map(signalName => `'${signalName}'`)\n\t.join(', ');\n\nconst getAvailableSignalIntegers = () => [...new Set(Object.values(constants.signals)\n\t.sort((signalInteger, signalIntegerTwo) => signalInteger - signalIntegerTwo))]\n\t.join(', ');\n\n// Human-friendly description of a signal\nexport const getSignalDescription = signal => signalsByName[signal].description;\n"
  },
  {
    "path": "lib/terminate/timeout.js",
    "content": "import {setTimeout} from 'node:timers/promises';\nimport {DiscardedError} from '../return/final-error.js';\n\n// Validate `timeout` option\nexport const validateTimeout = ({timeout}) => {\n\tif (timeout !== undefined && (!Number.isFinite(timeout) || timeout < 0)) {\n\t\tthrow new TypeError(`Expected the \\`timeout\\` option to be a non-negative integer, got \\`${timeout}\\` (${typeof timeout})`);\n\t}\n};\n\n// Fails when the `timeout` option is exceeded\nexport const throwOnTimeout = (subprocess, timeout, context, controller) => timeout === 0 || timeout === undefined\n\t? []\n\t: [killAfterTimeout(subprocess, timeout, context, controller)];\n\nconst killAfterTimeout = async (subprocess, timeout, context, {signal}) => {\n\tawait setTimeout(timeout, undefined, {signal});\n\tcontext.terminationReason ??= 'timeout';\n\tsubprocess.kill();\n\tthrow new DiscardedError();\n};\n"
  },
  {
    "path": "lib/transform/encoding-transform.js",
    "content": "import {Buffer} from 'node:buffer';\nimport {StringDecoder} from 'node:string_decoder';\nimport {isUint8Array, bufferToUint8Array} from '../utils/uint-array.js';\n\n/*\nWhen using binary encodings, add an internal generator that converts chunks from `Buffer` to `string` or `Uint8Array`.\nChunks might be Buffer, Uint8Array or strings since:\n- `subprocess.stdout|stderr` emits Buffers\n- `subprocess.stdin.write()` accepts Buffer, Uint8Array or string\n- Previous generators might return Uint8Array or string\n\nHowever, those are converted to Buffer:\n- on writes: `Duplex.writable` `decodeStrings: true` default option\n- on reads: `Duplex.readable` `readableEncoding: null` default option\n*/\nexport const getEncodingTransformGenerator = (binary, encoding, skipped) => {\n\tif (skipped) {\n\t\treturn;\n\t}\n\n\tif (binary) {\n\t\treturn {transform: encodingUint8ArrayGenerator.bind(undefined, new TextEncoder())};\n\t}\n\n\tconst stringDecoder = new StringDecoder(encoding);\n\treturn {\n\t\ttransform: encodingStringGenerator.bind(undefined, stringDecoder),\n\t\tfinal: encodingStringFinal.bind(undefined, stringDecoder),\n\t};\n};\n\nconst encodingUint8ArrayGenerator = function * (textEncoder, chunk) {\n\tif (Buffer.isBuffer(chunk)) {\n\t\tyield bufferToUint8Array(chunk);\n\t} else if (typeof chunk === 'string') {\n\t\tyield textEncoder.encode(chunk);\n\t} else {\n\t\tyield chunk;\n\t}\n};\n\nconst encodingStringGenerator = function * (stringDecoder, chunk) {\n\tyield isUint8Array(chunk) ? stringDecoder.write(chunk) : chunk;\n};\n\nconst encodingStringFinal = function * (stringDecoder) {\n\tconst lastChunk = stringDecoder.end();\n\tif (lastChunk !== '') {\n\t\tyield lastChunk;\n\t}\n};\n"
  },
  {
    "path": "lib/transform/generator.js",
    "content": "import {Transform, getDefaultHighWaterMark} from 'node:stream';\nimport {isAsyncGenerator} from '../stdio/type.js';\nimport {getSplitLinesGenerator, getAppendNewlineGenerator} from './split.js';\nimport {getValidateTransformInput, getValidateTransformReturn} from './validate.js';\nimport {getEncodingTransformGenerator} from './encoding-transform.js';\nimport {\n\tpushChunks,\n\ttransformChunk,\n\tfinalChunks,\n\tdestroyTransform,\n} from './run-async.js';\nimport {\n\tpushChunksSync,\n\ttransformChunkSync,\n\tfinalChunksSync,\n\trunTransformSync,\n} from './run-sync.js';\n\n/*\nGenerators can be used to transform/filter standard streams.\n\nGenerators have a simple syntax, yet allows all of the following:\n- Sharing `state` between chunks\n- Flushing logic, by using a `final` function\n- Asynchronous logic\n- Emitting multiple chunks from a single source chunk, even if spaced in time, by using multiple `yield`\n- Filtering, by using no `yield`\n\nTherefore, there is no need to allow Node.js or web transform streams.\n\nThe `highWaterMark` is kept as the default value, since this is what `subprocess.std*` uses.\n\nChunks are currently processed serially. We could add a `concurrency` option to parallelize in the future.\n\nTransform an array of generator functions into a `Transform` stream.\n`Duplex.from(generator)` cannot be used because it does not allow setting the `objectMode` and `highWaterMark`.\n*/\nexport const generatorToStream = ({\n\tvalue,\n\tvalue: {transform, final, writableObjectMode, readableObjectMode},\n\toptionName,\n}, {encoding}) => {\n\tconst state = {};\n\tconst generators = addInternalGenerators(value, encoding, optionName);\n\n\tconst transformAsync = isAsyncGenerator(transform);\n\tconst finalAsync = isAsyncGenerator(final);\n\tconst transformMethod = transformAsync\n\t\t? pushChunks.bind(undefined, transformChunk, state)\n\t\t: pushChunksSync.bind(undefined, transformChunkSync);\n\tconst finalMethod = transformAsync || finalAsync\n\t\t? pushChunks.bind(undefined, finalChunks, state)\n\t\t: pushChunksSync.bind(undefined, finalChunksSync);\n\tconst destroyMethod = transformAsync || finalAsync\n\t\t? destroyTransform.bind(undefined, state)\n\t\t: undefined;\n\n\tconst stream = new Transform({\n\t\twritableObjectMode,\n\t\twritableHighWaterMark: getDefaultHighWaterMark(writableObjectMode),\n\t\treadableObjectMode,\n\t\treadableHighWaterMark: getDefaultHighWaterMark(readableObjectMode),\n\t\ttransform(chunk, encoding, done) {\n\t\t\ttransformMethod([chunk, generators, 0], this, done);\n\t\t},\n\t\tflush(done) {\n\t\t\tfinalMethod([generators], this, done);\n\t\t},\n\t\tdestroy: destroyMethod,\n\t});\n\treturn {stream};\n};\n\n// Applies transform generators in sync mode\nexport const runGeneratorsSync = (chunks, stdioItems, encoding, isInput) => {\n\tconst generators = stdioItems.filter(({type}) => type === 'generator');\n\tconst reversedGenerators = isInput ? generators.reverse() : generators;\n\n\tfor (const {value, optionName} of reversedGenerators) {\n\t\tconst generators = addInternalGenerators(value, encoding, optionName);\n\t\tchunks = runTransformSync(generators, chunks);\n\t}\n\n\treturn chunks;\n};\n\n// Generators used internally to convert the chunk type, validate it, and split into lines\nconst addInternalGenerators = (\n\t{transform, final, binary, writableObjectMode, readableObjectMode, preserveNewlines},\n\tencoding,\n\toptionName,\n) => {\n\tconst state = {};\n\treturn [\n\t\t{transform: getValidateTransformInput(writableObjectMode, optionName)},\n\t\tgetEncodingTransformGenerator(binary, encoding, writableObjectMode),\n\t\tgetSplitLinesGenerator(binary, preserveNewlines, writableObjectMode, state),\n\t\t{transform, final},\n\t\t{transform: getValidateTransformReturn(readableObjectMode, optionName)},\n\t\tgetAppendNewlineGenerator({\n\t\t\tbinary,\n\t\t\tpreserveNewlines,\n\t\t\treadableObjectMode,\n\t\t\tstate,\n\t\t}),\n\t].filter(Boolean);\n};\n"
  },
  {
    "path": "lib/transform/normalize.js",
    "content": "import isPlainObj from 'is-plain-obj';\nimport {BINARY_ENCODINGS} from '../arguments/encoding-option.js';\nimport {TRANSFORM_TYPES} from '../stdio/type.js';\nimport {getTransformObjectModes} from './object-mode.js';\n\n// Transforms generators/duplex/TransformStream can have multiple shapes.\n// This normalizes it and applies default values.\nexport const normalizeTransforms = (stdioItems, optionName, direction, options) => [\n\t...stdioItems.filter(({type}) => !TRANSFORM_TYPES.has(type)),\n\t...getTransforms(stdioItems, optionName, direction, options),\n];\n\nconst getTransforms = (stdioItems, optionName, direction, {encoding}) => {\n\tconst transforms = stdioItems.filter(({type}) => TRANSFORM_TYPES.has(type));\n\tconst newTransforms = Array.from({length: transforms.length});\n\n\tfor (const [index, stdioItem] of Object.entries(transforms)) {\n\t\tnewTransforms[index] = normalizeTransform({\n\t\t\tstdioItem,\n\t\t\tindex: Number(index),\n\t\t\tnewTransforms,\n\t\t\toptionName,\n\t\t\tdirection,\n\t\t\tencoding,\n\t\t});\n\t}\n\n\treturn sortTransforms(newTransforms, direction);\n};\n\nconst normalizeTransform = ({stdioItem, stdioItem: {type}, index, newTransforms, optionName, direction, encoding}) => {\n\tif (type === 'duplex') {\n\t\treturn normalizeDuplex({stdioItem, optionName});\n\t}\n\n\tif (type === 'webTransform') {\n\t\treturn normalizeTransformStream({\n\t\t\tstdioItem,\n\t\t\tindex,\n\t\t\tnewTransforms,\n\t\t\tdirection,\n\t\t});\n\t}\n\n\treturn normalizeGenerator({\n\t\tstdioItem,\n\t\tindex,\n\t\tnewTransforms,\n\t\tdirection,\n\t\tencoding,\n\t});\n};\n\nconst normalizeDuplex = ({\n\tstdioItem,\n\tstdioItem: {\n\t\tvalue: {\n\t\t\ttransform,\n\t\t\ttransform: {writableObjectMode, readableObjectMode},\n\t\t\tobjectMode = readableObjectMode,\n\t\t},\n\t},\n\toptionName,\n}) => {\n\tif (objectMode && !readableObjectMode) {\n\t\tthrow new TypeError(`The \\`${optionName}.objectMode\\` option can only be \\`true\\` if \\`new Duplex({objectMode: true})\\` is used.`);\n\t}\n\n\tif (!objectMode && readableObjectMode) {\n\t\tthrow new TypeError(`The \\`${optionName}.objectMode\\` option cannot be \\`false\\` if \\`new Duplex({objectMode: true})\\` is used.`);\n\t}\n\n\treturn {\n\t\t...stdioItem,\n\t\tvalue: {transform, writableObjectMode, readableObjectMode},\n\t};\n};\n\nconst normalizeTransformStream = ({stdioItem, stdioItem: {value}, index, newTransforms, direction}) => {\n\tconst {transform, objectMode} = isPlainObj(value) ? value : {transform: value};\n\tconst {writableObjectMode, readableObjectMode} = getTransformObjectModes(objectMode, index, newTransforms, direction);\n\treturn ({\n\t\t...stdioItem,\n\t\tvalue: {transform, writableObjectMode, readableObjectMode},\n\t});\n};\n\nconst normalizeGenerator = ({stdioItem, stdioItem: {value}, index, newTransforms, direction, encoding}) => {\n\tconst {\n\t\ttransform,\n\t\tfinal,\n\t\tbinary: binaryOption = false,\n\t\tpreserveNewlines = false,\n\t\tobjectMode,\n\t} = isPlainObj(value) ? value : {transform: value};\n\tconst binary = binaryOption || BINARY_ENCODINGS.has(encoding);\n\tconst {writableObjectMode, readableObjectMode} = getTransformObjectModes(objectMode, index, newTransforms, direction);\n\treturn {\n\t\t...stdioItem,\n\t\tvalue: {\n\t\t\ttransform,\n\t\t\tfinal,\n\t\t\tbinary,\n\t\t\tpreserveNewlines,\n\t\t\twritableObjectMode,\n\t\t\treadableObjectMode,\n\t\t},\n\t};\n};\n\nconst sortTransforms = (newTransforms, direction) => direction === 'input' ? newTransforms.reverse() : newTransforms;\n"
  },
  {
    "path": "lib/transform/object-mode.js",
    "content": "import {TRANSFORM_TYPES} from '../stdio/type.js';\n\n/*\nRetrieve the `objectMode`s of a single transform.\n`objectMode` determines the return value's type, i.e. the `readableObjectMode`.\nThe chunk argument's type is based on the previous generator's return value, i.e. the `writableObjectMode` is based on the previous `readableObjectMode`.\nThe last input's generator is read by `subprocess.stdin` which:\n- should not be in `objectMode` for performance reasons.\n- can only be strings, Buffers and Uint8Arrays.\nTherefore its `readableObjectMode` must be `false`.\nThe same applies to the first output's generator's `writableObjectMode`.\n*/\nexport const getTransformObjectModes = (objectMode, index, newTransforms, direction) => direction === 'output'\n\t? getOutputObjectModes(objectMode, index, newTransforms)\n\t: getInputObjectModes(objectMode, index, newTransforms);\n\nconst getOutputObjectModes = (objectMode, index, newTransforms) => {\n\tconst writableObjectMode = index !== 0 && newTransforms[index - 1].value.readableObjectMode;\n\tconst readableObjectMode = objectMode ?? writableObjectMode;\n\treturn {writableObjectMode, readableObjectMode};\n};\n\nconst getInputObjectModes = (objectMode, index, newTransforms) => {\n\tconst writableObjectMode = index === 0\n\t\t? objectMode === true\n\t\t: newTransforms[index - 1].value.readableObjectMode;\n\tconst readableObjectMode = index !== newTransforms.length - 1 && (objectMode ?? writableObjectMode);\n\treturn {writableObjectMode, readableObjectMode};\n};\n\n// Retrieve the `objectMode` of a file descriptor, e.g. `stdout` or `stderr`\nexport const getFdObjectMode = (stdioItems, direction) => {\n\tconst lastTransform = stdioItems.findLast(({type}) => TRANSFORM_TYPES.has(type));\n\tif (lastTransform === undefined) {\n\t\treturn false;\n\t}\n\n\treturn direction === 'input'\n\t\t? lastTransform.value.writableObjectMode\n\t\t: lastTransform.value.readableObjectMode;\n};\n"
  },
  {
    "path": "lib/transform/run-async.js",
    "content": "import {callbackify} from 'node:util';\n\n// Applies a series of generator functions asynchronously\nexport const pushChunks = callbackify(async (getChunks, state, getChunksArguments, transformStream) => {\n\tstate.currentIterable = getChunks(...getChunksArguments);\n\n\ttry {\n\t\tfor await (const chunk of state.currentIterable) {\n\t\t\ttransformStream.push(chunk);\n\t\t}\n\t} finally {\n\t\tdelete state.currentIterable;\n\t}\n});\n\n// For each new chunk, apply each `transform()` method\nexport const transformChunk = async function * (chunk, generators, index) {\n\tif (index === generators.length) {\n\t\tyield chunk;\n\t\treturn;\n\t}\n\n\tconst {transform = identityGenerator} = generators[index];\n\tfor await (const transformedChunk of transform(chunk)) {\n\t\tyield * transformChunk(transformedChunk, generators, index + 1);\n\t}\n};\n\n// At the end, apply each `final()` method, followed by the `transform()` method of the next transforms\nexport const finalChunks = async function * (generators) {\n\tfor (const [index, {final}] of Object.entries(generators)) {\n\t\tyield * generatorFinalChunks(final, Number(index), generators);\n\t}\n};\n\nconst generatorFinalChunks = async function * (final, index, generators) {\n\tif (final === undefined) {\n\t\treturn;\n\t}\n\n\tfor await (const finalChunk of final()) {\n\t\tyield * transformChunk(finalChunk, generators, index + 1);\n\t}\n};\n\n// Cancel any ongoing async generator when the Transform is destroyed, e.g. when the subprocess errors\nexport const destroyTransform = callbackify(async ({currentIterable}, error) => {\n\tif (currentIterable !== undefined) {\n\t\tawait (error ? currentIterable.throw(error) : currentIterable.return());\n\t\treturn;\n\t}\n\n\tif (error) {\n\t\tthrow error;\n\t}\n});\n\nconst identityGenerator = function * (chunk) {\n\tyield chunk;\n};\n"
  },
  {
    "path": "lib/transform/run-sync.js",
    "content": "// Duplicate the code from `run-async.js` but as synchronous functions\nexport const pushChunksSync = (getChunksSync, getChunksArguments, transformStream, done) => {\n\ttry {\n\t\tfor (const chunk of getChunksSync(...getChunksArguments)) {\n\t\t\ttransformStream.push(chunk);\n\t\t}\n\n\t\tdone();\n\t} catch (error) {\n\t\tdone(error);\n\t}\n};\n\n// Run synchronous generators with `execaSync()`\nexport const runTransformSync = (generators, chunks) => [\n\t...chunks.flatMap(chunk => [...transformChunkSync(chunk, generators, 0)]),\n\t...finalChunksSync(generators),\n];\n\nexport const transformChunkSync = function * (chunk, generators, index) {\n\tif (index === generators.length) {\n\t\tyield chunk;\n\t\treturn;\n\t}\n\n\tconst {transform = identityGenerator} = generators[index];\n\tfor (const transformedChunk of transform(chunk)) {\n\t\tyield * transformChunkSync(transformedChunk, generators, index + 1);\n\t}\n};\n\nexport const finalChunksSync = function * (generators) {\n\tfor (const [index, {final}] of Object.entries(generators)) {\n\t\tyield * generatorFinalChunksSync(final, Number(index), generators);\n\t}\n};\n\nconst generatorFinalChunksSync = function * (final, index, generators) {\n\tif (final === undefined) {\n\t\treturn;\n\t}\n\n\tfor (const finalChunk of final()) {\n\t\tyield * transformChunkSync(finalChunk, generators, index + 1);\n\t}\n};\n\nconst identityGenerator = function * (chunk) {\n\tyield chunk;\n};\n"
  },
  {
    "path": "lib/transform/split.js",
    "content": "// Split chunks line-wise for generators passed to the `std*` options\nexport const getSplitLinesGenerator = (binary, preserveNewlines, skipped, state) => binary || skipped\n\t? undefined\n\t: initializeSplitLines(preserveNewlines, state);\n\n// Same but for synchronous methods\nexport const splitLinesSync = (chunk, preserveNewlines, objectMode) => objectMode\n\t? chunk.flatMap(item => splitLinesItemSync(item, preserveNewlines))\n\t: splitLinesItemSync(chunk, preserveNewlines);\n\nconst splitLinesItemSync = (chunk, preserveNewlines) => {\n\tconst {transform, final} = initializeSplitLines(preserveNewlines, {});\n\treturn [...transform(chunk), ...final()];\n};\n\nconst initializeSplitLines = (preserveNewlines, state) => {\n\tstate.previousChunks = '';\n\treturn {\n\t\ttransform: splitGenerator.bind(undefined, state, preserveNewlines),\n\t\tfinal: linesFinal.bind(undefined, state),\n\t};\n};\n\n// This imperative logic is much faster than using `String.split()` and uses very low memory.\nconst splitGenerator = function * (state, preserveNewlines, chunk) {\n\tif (typeof chunk !== 'string') {\n\t\tyield chunk;\n\t\treturn;\n\t}\n\n\tlet {previousChunks} = state;\n\tlet start = -1;\n\n\tfor (let end = 0; end < chunk.length; end += 1) {\n\t\tif (chunk[end] === '\\n') {\n\t\t\tconst newlineLength = getNewlineLength(chunk, end, preserveNewlines, state);\n\t\t\tlet line = chunk.slice(start + 1, end + 1 - newlineLength);\n\n\t\t\tif (previousChunks.length > 0) {\n\t\t\t\tline = concatString(previousChunks, line);\n\t\t\t\tpreviousChunks = '';\n\t\t\t}\n\n\t\t\tyield line;\n\t\t\tstart = end;\n\t\t}\n\t}\n\n\tif (start !== chunk.length - 1) {\n\t\tpreviousChunks = concatString(previousChunks, chunk.slice(start + 1));\n\t}\n\n\tstate.previousChunks = previousChunks;\n};\n\nconst getNewlineLength = (chunk, end, preserveNewlines, state) => {\n\tif (preserveNewlines) {\n\t\treturn 0;\n\t}\n\n\tstate.isWindowsNewline = end !== 0 && chunk[end - 1] === '\\r';\n\treturn state.isWindowsNewline ? 2 : 1;\n};\n\nconst linesFinal = function * ({previousChunks}) {\n\tif (previousChunks.length > 0) {\n\t\tyield previousChunks;\n\t}\n};\n\n// Unless `preserveNewlines: true` is used, we strip the newline of each line.\n// This re-adds them after the user `transform` code has run.\nexport const getAppendNewlineGenerator = ({binary, preserveNewlines, readableObjectMode, state}) => binary || preserveNewlines || readableObjectMode\n\t? undefined\n\t: {transform: appendNewlineGenerator.bind(undefined, state)};\n\nconst appendNewlineGenerator = function * ({isWindowsNewline = false}, chunk) {\n\tconst {unixNewline, windowsNewline, LF, concatBytes} = typeof chunk === 'string' ? linesStringInfo : linesUint8ArrayInfo;\n\n\tif (chunk.at(-1) === LF) {\n\t\tyield chunk;\n\t\treturn;\n\t}\n\n\tconst newline = isWindowsNewline ? windowsNewline : unixNewline;\n\tyield concatBytes(chunk, newline);\n};\n\nconst concatString = (firstChunk, secondChunk) => `${firstChunk}${secondChunk}`;\n\nconst linesStringInfo = {\n\twindowsNewline: '\\r\\n',\n\tunixNewline: '\\n',\n\tLF: '\\n',\n\tconcatBytes: concatString,\n};\n\nconst concatUint8Array = (firstChunk, secondChunk) => {\n\tconst chunk = new Uint8Array(firstChunk.length + secondChunk.length);\n\tchunk.set(firstChunk, 0);\n\tchunk.set(secondChunk, firstChunk.length);\n\treturn chunk;\n};\n\nconst linesUint8ArrayInfo = {\n\twindowsNewline: new Uint8Array([0x0D, 0x0A]),\n\tunixNewline: new Uint8Array([0x0A]),\n\tLF: 0x0A,\n\tconcatBytes: concatUint8Array,\n};\n"
  },
  {
    "path": "lib/transform/validate.js",
    "content": "import {Buffer} from 'node:buffer';\nimport {isUint8Array} from '../utils/uint-array.js';\n\n// Validate the type of chunk argument passed to transform generators\nexport const getValidateTransformInput = (writableObjectMode, optionName) => writableObjectMode\n\t? undefined\n\t: validateStringTransformInput.bind(undefined, optionName);\n\nconst validateStringTransformInput = function * (optionName, chunk) {\n\tif (typeof chunk !== 'string' && !isUint8Array(chunk) && !Buffer.isBuffer(chunk)) {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option's transform must use \"objectMode: true\" to receive as input: ${typeof chunk}.`);\n\t}\n\n\tyield chunk;\n};\n\n// Validate the type of the value returned by transform generators\nexport const getValidateTransformReturn = (readableObjectMode, optionName) => readableObjectMode\n\t? validateObjectTransformReturn.bind(undefined, optionName)\n\t: validateStringTransformReturn.bind(undefined, optionName);\n\nconst validateObjectTransformReturn = function * (optionName, chunk) {\n\tvalidateEmptyReturn(optionName, chunk);\n\tyield chunk;\n};\n\nconst validateStringTransformReturn = function * (optionName, chunk) {\n\tvalidateEmptyReturn(optionName, chunk);\n\n\tif (typeof chunk !== 'string' && !isUint8Array(chunk)) {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option's function must yield a string or an Uint8Array, not ${typeof chunk}.`);\n\t}\n\n\tyield chunk;\n};\n\nconst validateEmptyReturn = (optionName, chunk) => {\n\tif (chunk === null || chunk === undefined) {\n\t\tthrow new TypeError(`The \\`${optionName}\\` option's function must not call \\`yield ${chunk}\\`.\nInstead, \\`yield\\` should either be called with a value, or not be called at all. For example:\n  if (condition) { yield value; }`);\n\t}\n};\n"
  },
  {
    "path": "lib/utils/abort-signal.js",
    "content": "import {once} from 'node:events';\n\n// Combines `util.aborted()` and `events.addAbortListener()`: promise-based and cleaned up with a stop signal\nexport const onAbortedSignal = async (mainSignal, stopSignal) => {\n\tif (!mainSignal.aborted) {\n\t\tawait once(mainSignal, 'abort', {signal: stopSignal});\n\t}\n};\n"
  },
  {
    "path": "lib/utils/deferred.js",
    "content": "export const createDeferred = () => {\n\tconst methods = {};\n\tconst promise = new Promise((resolve, reject) => {\n\t\tObject.assign(methods, {resolve, reject});\n\t});\n\treturn Object.assign(promise, methods);\n};\n"
  },
  {
    "path": "lib/utils/max-listeners.js",
    "content": "import {addAbortListener} from 'node:events';\n\n// Temporarily increase the maximum number of listeners on an eventEmitter\nexport const incrementMaxListeners = (eventEmitter, maxListenersIncrement, signal) => {\n\tconst maxListeners = eventEmitter.getMaxListeners();\n\tif (maxListeners === 0 || maxListeners === Number.POSITIVE_INFINITY) {\n\t\treturn;\n\t}\n\n\teventEmitter.setMaxListeners(maxListeners + maxListenersIncrement);\n\taddAbortListener(signal, () => {\n\t\teventEmitter.setMaxListeners(eventEmitter.getMaxListeners() - maxListenersIncrement);\n\t});\n};\n"
  },
  {
    "path": "lib/utils/standard-stream.js",
    "content": "import process from 'node:process';\n\nexport const isStandardStream = stream => STANDARD_STREAMS.includes(stream);\nexport const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];\nexport const STANDARD_STREAMS_ALIASES = ['stdin', 'stdout', 'stderr'];\nexport const getStreamName = fdNumber => STANDARD_STREAMS_ALIASES[fdNumber] ?? `stdio[${fdNumber}]`;\n"
  },
  {
    "path": "lib/utils/uint-array.js",
    "content": "import {StringDecoder} from 'node:string_decoder';\n\nconst {toString: objectToString} = Object.prototype;\n\nexport const isArrayBuffer = value => objectToString.call(value) === '[object ArrayBuffer]';\n\n// Is either Uint8Array or Buffer\nexport const isUint8Array = value => objectToString.call(value) === '[object Uint8Array]';\n\nexport const bufferToUint8Array = buffer => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n\nconst textEncoder = new TextEncoder();\nconst stringToUint8Array = string => textEncoder.encode(string);\n\nconst textDecoder = new TextDecoder();\nexport const uint8ArrayToString = uint8Array => textDecoder.decode(uint8Array);\n\nexport const joinToString = (uint8ArraysOrStrings, encoding) => {\n\tconst strings = uint8ArraysToStrings(uint8ArraysOrStrings, encoding);\n\treturn strings.join('');\n};\n\nconst uint8ArraysToStrings = (uint8ArraysOrStrings, encoding) => {\n\tif (encoding === 'utf8' && uint8ArraysOrStrings.every(uint8ArrayOrString => typeof uint8ArrayOrString === 'string')) {\n\t\treturn uint8ArraysOrStrings;\n\t}\n\n\tconst decoder = new StringDecoder(encoding);\n\tconst strings = uint8ArraysOrStrings\n\t\t.map(uint8ArrayOrString => typeof uint8ArrayOrString === 'string'\n\t\t\t? stringToUint8Array(uint8ArrayOrString)\n\t\t\t: uint8ArrayOrString)\n\t\t.map(uint8Array => decoder.write(uint8Array));\n\tconst finalString = decoder.end();\n\treturn finalString === '' ? strings : [...strings, finalString];\n};\n\nexport const joinToUint8Array = uint8ArraysOrStrings => {\n\tif (uint8ArraysOrStrings.length === 1 && isUint8Array(uint8ArraysOrStrings[0])) {\n\t\treturn uint8ArraysOrStrings[0];\n\t}\n\n\treturn concatUint8Arrays(stringsToUint8Arrays(uint8ArraysOrStrings));\n};\n\nconst stringsToUint8Arrays = uint8ArraysOrStrings => uint8ArraysOrStrings.map(uint8ArrayOrString => typeof uint8ArrayOrString === 'string'\n\t? stringToUint8Array(uint8ArrayOrString)\n\t: uint8ArrayOrString);\n\nexport const concatUint8Arrays = uint8Arrays => {\n\tconst result = new Uint8Array(getJoinLength(uint8Arrays));\n\n\tlet index = 0;\n\tfor (const uint8Array of uint8Arrays) {\n\t\tresult.set(uint8Array, index);\n\t\tindex += uint8Array.length;\n\t}\n\n\treturn result;\n};\n\nconst getJoinLength = uint8Arrays => {\n\tlet joinLength = 0;\n\tfor (const uint8Array of uint8Arrays) {\n\t\tjoinLength += uint8Array.length;\n\t}\n\n\treturn joinLength;\n};\n"
  },
  {
    "path": "lib/verbose/complete.js",
    "content": "import prettyMs from 'pretty-ms';\nimport {isVerbose} from './values.js';\nimport {verboseLog} from './log.js';\nimport {logError} from './error.js';\n\n// When `verbose` is `short|full|custom`, print each command's completion, duration and error\nexport const logResult = (result, verboseInfo) => {\n\tif (!isVerbose(verboseInfo)) {\n\t\treturn;\n\t}\n\n\tlogError(result, verboseInfo);\n\tlogDuration(result, verboseInfo);\n};\n\nconst logDuration = (result, verboseInfo) => {\n\tconst verboseMessage = `(done in ${prettyMs(result.durationMs)})`;\n\tverboseLog({\n\t\ttype: 'duration',\n\t\tverboseMessage,\n\t\tverboseInfo,\n\t\tresult,\n\t});\n};\n"
  },
  {
    "path": "lib/verbose/custom.js",
    "content": "import {getVerboseFunction} from './values.js';\n\n// Apply the `verbose` function on each line\nexport const applyVerboseOnLines = (printedLines, verboseInfo, fdNumber) => {\n\tconst verboseFunction = getVerboseFunction(verboseInfo, fdNumber);\n\treturn printedLines\n\t\t.map(({verboseLine, verboseObject}) => applyVerboseFunction(verboseLine, verboseObject, verboseFunction))\n\t\t.filter(printedLine => printedLine !== undefined)\n\t\t.map(printedLine => appendNewline(printedLine))\n\t\t.join('');\n};\n\nconst applyVerboseFunction = (verboseLine, verboseObject, verboseFunction) => {\n\tif (verboseFunction === undefined) {\n\t\treturn verboseLine;\n\t}\n\n\tconst printedLine = verboseFunction(verboseLine, verboseObject);\n\tif (typeof printedLine === 'string') {\n\t\treturn printedLine;\n\t}\n};\n\nconst appendNewline = printedLine => printedLine.endsWith('\\n')\n\t? printedLine\n\t: `${printedLine}\\n`;\n"
  },
  {
    "path": "lib/verbose/default.js",
    "content": "import figures from 'figures';\nimport {\n\tgray,\n\tbold,\n\tredBright,\n\tyellowBright,\n} from 'yoctocolors';\n\n// Default when `verbose` is not a function\nexport const defaultVerboseFunction = ({\n\ttype,\n\tmessage,\n\ttimestamp,\n\tpiped,\n\tcommandId,\n\tresult: {failed = false} = {},\n\toptions: {reject = true},\n}) => {\n\tconst timestampString = serializeTimestamp(timestamp);\n\tconst icon = ICONS[type]({failed, reject, piped});\n\tconst color = COLORS[type]({reject});\n\treturn `${gray(`[${timestampString}]`)} ${gray(`[${commandId}]`)} ${color(icon)} ${color(message)}`;\n};\n\n// Prepending the timestamp allows debugging the slow paths of a subprocess\nconst serializeTimestamp = timestamp => `${padField(timestamp.getHours(), 2)}:${padField(timestamp.getMinutes(), 2)}:${padField(timestamp.getSeconds(), 2)}.${padField(timestamp.getMilliseconds(), 3)}`;\n\nconst padField = (field, padding) => String(field).padStart(padding, '0');\n\nconst getFinalIcon = ({failed, reject}) => {\n\tif (!failed) {\n\t\treturn figures.tick;\n\t}\n\n\treturn reject ? figures.cross : figures.warning;\n};\n\nconst ICONS = {\n\tcommand: ({piped}) => piped ? '|' : '$',\n\toutput: () => ' ',\n\tipc: () => '*',\n\terror: getFinalIcon,\n\tduration: getFinalIcon,\n};\n\nconst identity = string => string;\n\nconst COLORS = {\n\tcommand: () => bold,\n\toutput: () => identity,\n\tipc: () => identity,\n\terror: ({reject}) => reject ? redBright : yellowBright,\n\tduration: () => gray,\n};\n"
  },
  {
    "path": "lib/verbose/error.js",
    "content": "import {verboseLog} from './log.js';\n\n// When `verbose` is `short|full|custom`, print each command's error when it fails\nexport const logError = (result, verboseInfo) => {\n\tif (result.failed) {\n\t\tverboseLog({\n\t\t\ttype: 'error',\n\t\t\tverboseMessage: result.shortMessage,\n\t\t\tverboseInfo,\n\t\t\tresult,\n\t\t});\n\t}\n};\n"
  },
  {
    "path": "lib/verbose/info.js",
    "content": "import {isVerbose, VERBOSE_VALUES, isVerboseFunction} from './values.js';\n\n// Information computed before spawning, used by the `verbose` option\nexport const getVerboseInfo = (verbose, escapedCommand, rawOptions) => {\n\tvalidateVerbose(verbose);\n\tconst commandId = getCommandId(verbose);\n\treturn {\n\t\tverbose,\n\t\tescapedCommand,\n\t\tcommandId,\n\t\trawOptions,\n\t};\n};\n\nconst getCommandId = verbose => isVerbose({verbose}) ? COMMAND_ID++ : undefined;\n\n// Prepending the `pid` is useful when multiple commands print their output at the same time.\n// However, we cannot use the real PID since this is not available with `child_process.spawnSync()`.\n// Also, we cannot use the real PID if we want to print it before `child_process.spawn()` is run.\n// As a pro, it is shorter than a normal PID and never re-uses the same id.\n// As a con, it cannot be used to send signals.\nlet COMMAND_ID = 0n;\n\nconst validateVerbose = verbose => {\n\tfor (const fdVerbose of verbose) {\n\t\tif (fdVerbose === false) {\n\t\t\tthrow new TypeError('The \"verbose: false\" option was renamed to \"verbose: \\'none\\'\".');\n\t\t}\n\n\t\tif (fdVerbose === true) {\n\t\t\tthrow new TypeError('The \"verbose: true\" option was renamed to \"verbose: \\'short\\'\".');\n\t\t}\n\n\t\tif (!VERBOSE_VALUES.includes(fdVerbose) && !isVerboseFunction(fdVerbose)) {\n\t\t\tconst allowedValues = VERBOSE_VALUES.map(allowedValue => `'${allowedValue}'`).join(', ');\n\t\t\tthrow new TypeError(`The \"verbose\" option must not be ${fdVerbose}. Allowed values are: ${allowedValues} or a function.`);\n\t\t}\n\t}\n};\n"
  },
  {
    "path": "lib/verbose/ipc.js",
    "content": "import {verboseLog, serializeVerboseMessage} from './log.js';\nimport {isFullVerbose} from './values.js';\n\n// When `verbose` is `'full'`, print IPC messages from the subprocess\nexport const shouldLogIpc = verboseInfo => isFullVerbose(verboseInfo, 'ipc');\n\nexport const logIpcOutput = (message, verboseInfo) => {\n\tconst verboseMessage = serializeVerboseMessage(message);\n\tverboseLog({\n\t\ttype: 'ipc',\n\t\tverboseMessage,\n\t\tfdNumber: 'ipc',\n\t\tverboseInfo,\n\t});\n};\n"
  },
  {
    "path": "lib/verbose/log.js",
    "content": "import {inspect} from 'node:util';\nimport {escapeLines} from '../arguments/escape.js';\nimport {defaultVerboseFunction} from './default.js';\nimport {applyVerboseOnLines} from './custom.js';\n\n// This prints on stderr.\n// If the subprocess prints on stdout and is using `stdout: 'inherit'`,\n// there is a chance both writes will compete (introducing a race condition).\n// This means their respective order is not deterministic.\n// In particular, this means the verbose command lines might be after the start of the subprocess output.\n// Using synchronous I/O does not solve this problem.\n// However, this only seems to happen when the stdout/stderr target\n// (e.g. a terminal) is being written to by many subprocesses at once, which is unlikely in real scenarios.\nexport const verboseLog = ({type, verboseMessage, fdNumber, verboseInfo, result}) => {\n\tconst verboseObject = getVerboseObject({type, result, verboseInfo});\n\tconst printedLines = getPrintedLines(verboseMessage, verboseObject);\n\tconst finalLines = applyVerboseOnLines(printedLines, verboseInfo, fdNumber);\n\tif (finalLines !== '') {\n\t\tconsole.warn(finalLines.slice(0, -1));\n\t}\n};\n\nconst getVerboseObject = ({\n\ttype,\n\tresult,\n\tverboseInfo: {escapedCommand, commandId, rawOptions: {piped = false, ...options}},\n}) => ({\n\ttype,\n\tescapedCommand,\n\tcommandId: `${commandId}`,\n\ttimestamp: new Date(),\n\tpiped,\n\tresult,\n\toptions,\n});\n\nconst getPrintedLines = (verboseMessage, verboseObject) => verboseMessage\n\t.split('\\n')\n\t.map(message => getPrintedLine({...verboseObject, message}));\n\nconst getPrintedLine = verboseObject => {\n\tconst verboseLine = defaultVerboseFunction(verboseObject);\n\treturn {verboseLine, verboseObject};\n};\n\n// Serialize any type to a line string, for logging\nexport const serializeVerboseMessage = message => {\n\tconst messageString = typeof message === 'string' ? message : inspect(message);\n\tconst escapedMessage = escapeLines(messageString);\n\treturn escapedMessage.replaceAll('\\t', ' '.repeat(TAB_SIZE));\n};\n\n// Same as `util.inspect()`\nconst TAB_SIZE = 2;\n"
  },
  {
    "path": "lib/verbose/output.js",
    "content": "import {BINARY_ENCODINGS} from '../arguments/encoding-option.js';\nimport {TRANSFORM_TYPES} from '../stdio/type.js';\nimport {verboseLog, serializeVerboseMessage} from './log.js';\nimport {isFullVerbose} from './values.js';\n\n// `ignore` opts-out of `verbose` for a specific stream.\n// `ipc` cannot use piping.\n// `inherit` would result in double printing.\n// They can also lead to double printing when passing file descriptor integers or `process.std*`.\n// This only leaves with `pipe` and `overlapped`.\nexport const shouldLogOutput = ({stdioItems, encoding, verboseInfo, fdNumber}) => fdNumber !== 'all'\n\t&& isFullVerbose(verboseInfo, fdNumber)\n\t&& !BINARY_ENCODINGS.has(encoding)\n\t&& fdUsesVerbose(fdNumber)\n\t&& (stdioItems.some(({type, value}) => type === 'native' && PIPED_STDIO_VALUES.has(value))\n\t|| stdioItems.every(({type}) => TRANSFORM_TYPES.has(type)));\n\n// Printing input streams would be confusing.\n// Files and streams can produce big outputs, which we don't want to print.\n// We could print `stdio[3+]` but it often is redirected to files and streams, with the same issue.\n// So we only print stdout and stderr.\nconst fdUsesVerbose = fdNumber => fdNumber === 1 || fdNumber === 2;\n\nconst PIPED_STDIO_VALUES = new Set(['pipe', 'overlapped']);\n\n// `verbose: 'full'` printing logic with async methods\nexport const logLines = async (linesIterable, stream, fdNumber, verboseInfo) => {\n\tfor await (const line of linesIterable) {\n\t\tif (!isPipingStream(stream)) {\n\t\t\tlogLine(line, fdNumber, verboseInfo);\n\t\t}\n\t}\n};\n\n// `verbose: 'full'` printing logic with sync methods\nexport const logLinesSync = (linesArray, fdNumber, verboseInfo) => {\n\tfor (const line of linesArray) {\n\t\tlogLine(line, fdNumber, verboseInfo);\n\t}\n};\n\n// When `subprocess.stdout|stderr.pipe()` is called, `verbose` becomes a noop.\n// This prevents the following problems:\n//  - `.pipe()` achieves the same result as using `stdout: 'inherit'`, `stdout: stream`, etc. which also make `verbose` a noop.\n//    For example, `subprocess.stdout.pipe(process.stdin)` would print each line twice.\n//  - When chaining subprocesses with `subprocess.pipe(otherSubprocess)`, only the last one should print its output.\n// Detecting whether `.pipe()` is impossible without monkey-patching it, so we use the following undocumented property.\n// This is not a critical behavior since changes of the following property would only make `verbose` more verbose.\nconst isPipingStream = stream => stream._readableState.pipes.length > 0;\n\n// When `verbose` is `full`, print stdout|stderr\nconst logLine = (line, fdNumber, verboseInfo) => {\n\tconst verboseMessage = serializeVerboseMessage(line);\n\tverboseLog({\n\t\ttype: 'output',\n\t\tverboseMessage,\n\t\tfdNumber,\n\t\tverboseInfo,\n\t});\n};\n"
  },
  {
    "path": "lib/verbose/start.js",
    "content": "import {isVerbose} from './values.js';\nimport {verboseLog} from './log.js';\n\n// When `verbose` is `short|full|custom`, print each command\nexport const logCommand = (escapedCommand, verboseInfo) => {\n\tif (!isVerbose(verboseInfo)) {\n\t\treturn;\n\t}\n\n\tverboseLog({\n\t\ttype: 'command',\n\t\tverboseMessage: escapedCommand,\n\t\tverboseInfo,\n\t});\n};\n"
  },
  {
    "path": "lib/verbose/values.js",
    "content": "import {getFdSpecificValue} from '../arguments/specific.js';\n\n// The `verbose` option can have different values for `stdout`/`stderr`\nexport const isVerbose = ({verbose}, fdNumber) => getFdVerbose(verbose, fdNumber) !== 'none';\n\n// Whether IPC and output and logged\nexport const isFullVerbose = ({verbose}, fdNumber) => !['none', 'short'].includes(getFdVerbose(verbose, fdNumber));\n\n// The `verbose` option can be a function to customize logging\nexport const getVerboseFunction = ({verbose}, fdNumber) => {\n\tconst fdVerbose = getFdVerbose(verbose, fdNumber);\n\treturn isVerboseFunction(fdVerbose) ? fdVerbose : undefined;\n};\n\n// When using `verbose: {stdout, stderr, fd3, ipc}`:\n//  - `verbose.stdout|stderr|fd3` is used for 'output'\n//  - `verbose.ipc` is only used for 'ipc'\n//  - highest `verbose.*` value is used for 'command', 'error' and 'duration'\nconst getFdVerbose = (verbose, fdNumber) => fdNumber === undefined\n\t? getFdGenericVerbose(verbose)\n\t: getFdSpecificValue(verbose, fdNumber);\n\n// When using `verbose: {stdout, stderr, fd3, ipc}` and logging is not specific to a file descriptor.\n// We then use the highest `verbose.*` value, using the following order:\n//  - function > 'full' > 'short' > 'none'\n//  - if several functions are defined: stdout > stderr > fd3 > ipc\nconst getFdGenericVerbose = verbose => verbose.find(fdVerbose => isVerboseFunction(fdVerbose))\n\t?? VERBOSE_VALUES.findLast(fdVerbose => verbose.includes(fdVerbose));\n\n// Whether the `verbose` option is customized using a function\nexport const isVerboseFunction = fdVerbose => typeof fdVerbose === 'function';\n\nexport const VERBOSE_VALUES = ['none', 'short', 'full'];\n"
  },
  {
    "path": "license",
    "content": "MIT License\n\nCopyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "package.json",
    "content": "{\n\t\"name\": \"execa\",\n\t\"version\": \"9.6.1\",\n\t\"description\": \"Process execution for humans\",\n\t\"license\": \"MIT\",\n\t\"repository\": \"sindresorhus/execa\",\n\t\"funding\": \"https://github.com/sindresorhus/execa?sponsor=1\",\n\t\"author\": {\n\t\t\"name\": \"Sindre Sorhus\",\n\t\t\"email\": \"sindresorhus@gmail.com\",\n\t\t\"url\": \"https://sindresorhus.com\"\n\t},\n\t\"type\": \"module\",\n\t\"exports\": {\n\t\t\"types\": \"./index.d.ts\",\n\t\t\"default\": \"./index.js\"\n\t},\n\t\"sideEffects\": false,\n\t\"engines\": {\n\t\t\"node\": \"^18.19.0 || >=20.5.0\"\n\t},\n\t\"scripts\": {\n\t\t\"test\": \"npm run lint && npm run unit && npm run type\",\n\t\t\"lint\": \"xo\",\n\t\t\"unit\": \"c8 --merge-async ava\",\n\t\t\"type\": \"tsd && tsc && npx --yes tsd@0.29.0 && npx --yes --package typescript@5.1 tsc\"\n\t},\n\t\"files\": [\n\t\t\"index.js\",\n\t\t\"index.d.ts\",\n\t\t\"lib/**/*.js\",\n\t\t\"types/**/*.ts\"\n\t],\n\t\"keywords\": [\n\t\t\"exec\",\n\t\t\"child\",\n\t\t\"process\",\n\t\t\"subprocess\",\n\t\t\"execute\",\n\t\t\"fork\",\n\t\t\"execfile\",\n\t\t\"spawn\",\n\t\t\"file\",\n\t\t\"shell\",\n\t\t\"bin\",\n\t\t\"binary\",\n\t\t\"binaries\",\n\t\t\"npm\",\n\t\t\"path\",\n\t\t\"local\",\n\t\t\"zx\"\n\t],\n\t\"dependencies\": {\n\t\t\"@sindresorhus/merge-streams\": \"^4.0.0\",\n\t\t\"cross-spawn\": \"^7.0.6\",\n\t\t\"figures\": \"^6.1.0\",\n\t\t\"get-stream\": \"^9.0.0\",\n\t\t\"human-signals\": \"^8.0.1\",\n\t\t\"is-plain-obj\": \"^4.1.0\",\n\t\t\"is-stream\": \"^4.0.1\",\n\t\t\"npm-run-path\": \"^6.0.0\",\n\t\t\"pretty-ms\": \"^9.2.0\",\n\t\t\"signal-exit\": \"^4.1.0\",\n\t\t\"strip-final-newline\": \"^4.0.0\",\n\t\t\"yoctocolors\": \"^2.1.1\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@types/node\": \"^22.15.21\",\n\t\t\"ava\": \"^6.3.0\",\n\t\t\"c8\": \"^10.1.3\",\n\t\t\"get-node\": \"^15.0.3\",\n\t\t\"is-in-ci\": \"^1.0.0\",\n\t\t\"is-running\": \"^2.1.0\",\n\t\t\"log-process-errors\": \"^12.0.1\",\n\t\t\"path-exists\": \"^5.0.0\",\n\t\t\"path-key\": \"^4.0.0\",\n\t\t\"tempfile\": \"^5.0.0\",\n\t\t\"tsd\": \"^0.32.0\",\n\t\t\"typescript\": \"^5.8.3\",\n\t\t\"which\": \"^5.0.0\",\n\t\t\"xo\": \"^0.60.0\"\n\t},\n\t\"c8\": {\n\t\t\"reporter\": [\n\t\t\t\"text\",\n\t\t\t\"lcov\"\n\t\t],\n\t\t\"exclude\": [\n\t\t\t\"**/fixtures/**\",\n\t\t\t\"**/test.js\",\n\t\t\t\"**/test/**\"\n\t\t]\n\t},\n\t\"ava\": {\n\t\t\"workerThreads\": false,\n\t\t\"concurrency\": 1,\n\t\t\"timeout\": \"240s\"\n\t},\n\t\"xo\": {\n\t\t\"rules\": {\n\t\t\t\"unicorn/no-empty-file\": \"off\",\n\t\t\t\"@typescript-eslint/ban-types\": \"off\"\n\t\t}\n\t}\n}\n"
  },
  {
    "path": "readme.md",
    "content": "<picture>\n\t<source media=\"(prefers-color-scheme: dark)\" srcset=\"media/logo_dark.svg\">\n\t<img alt=\"execa logo\" src=\"media/logo.svg\" width=\"400\">\n</picture>\n<br>\n\n[![Coverage Status](https://codecov.io/gh/sindresorhus/execa/branch/main/graph/badge.svg)](https://codecov.io/gh/sindresorhus/execa)\n\n> Process execution for humans\n\n<br>\n\n---\n\n<div align=\"center\">\n\t<p>\n\t\t<p>\n\t\t\t<sup>\n\t\t\t\t<a href=\"https://github.com/sponsors/sindresorhus\">Sindre's open source work is supported by the community</a>\n\t\t\t</sup>\n\t\t</p>\n\t\t<sup>Special thanks to:</sup>\n\t\t<br>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://coderabbit.ai?utm_source=sindre&utm_medium=execa\">\n\t\t\t<img width=\"300\" src=\"https://sindresorhus.com/assets/thanks/coderabbit-logo.png\" alt=\"CodeRabbit logo\">\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://kruu.com\">\n\t\t\t<picture>\n\t\t\t\t<source srcset=\"https://sindresorhus.com/assets/thanks/kruu-logo-dark.svg?y\" media=\"(prefers-color-scheme: dark)\" width=\"260\">\n\t\t\t\t<source srcset=\"https://sindresorhus.com/assets/thanks/kruu-logo-light.svg?y\" media=\"(prefers-color-scheme: light)\" width=\"260\">\n\t\t\t\t<img src=\"https://sindresorhus.com/assets/thanks/kruu-logo-light.svg?y\" width=\"260\"alt=\"KRUU logo\">\n\t\t\t</picture>\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t\t<br>\n\t\t<a href=\"https://depot.dev?utm_source=github&utm_medium=sindresorhus\">\n\t\t\t<div>\n\t\t\t\t<picture>\n\t\t\t\t\t<source width=\"180\" media=\"(prefers-color-scheme: dark)\" srcset=\"https://sindresorhus.com/assets/thanks/depot-logo-dark.svg\">\n\t\t\t\t\t<source width=\"180\" media=\"(prefers-color-scheme: light)\" srcset=\"https://sindresorhus.com/assets/thanks/depot-logo-light.svg\">\n\t\t\t\t\t<img width=\"180\" src=\"https://sindresorhus.com/assets/thanks/depot-logo-light.svg\" alt=\"Depot logo\">\n\t\t\t\t</picture>\n\t\t\t</div>\n\t\t\t<b>Fast remote container builds and GitHub Actions runners.</b>\n\t\t</a>\n\t\t<br>\n\t\t<br>\n\t\t<br>\n\t</p>\n</div>\n\n---\n\n<br>\n\nExeca runs commands in your script, application or library. Unlike shells, it is [optimized](docs/bash.md) for programmatic usage. Built on top of the [`child_process`](https://nodejs.org/api/child_process.html) core module.\n\n## Features\n\n- [Simple syntax](#simple-syntax): promises and [template strings](docs/execution.md#template-string-syntax), like [`zx`](docs/bash.md).\n- [Script](#script) interface.\n- [No escaping](docs/escaping.md) nor quoting needed. No risk of shell injection.\n- Execute [locally installed binaries](#local-binaries) without `npx`.\n- Improved [Windows support](docs/windows.md): [shebangs](docs/windows.md#shebang), [`PATHEXT`](https://ss64.com/nt/path.html#pathext), [graceful termination](#graceful-termination), [and more](https://github.com/moxystudio/node-cross-spawn?tab=readme-ov-file#why).\n- [Detailed errors](#detailed-error), [verbose mode](#verbose-mode) and [custom logging](#custom-logging), for [debugging](docs/debugging.md).\n- [Pipe multiple subprocesses](#pipe-multiple-subprocesses) better than in shells: retrieve [intermediate results](docs/pipe.md#result), use multiple [sources](docs/pipe.md#multiple-sources-1-destination)/[destinations](docs/pipe.md#1-source-multiple-destinations), [unpipe](docs/pipe.md#unpipe).\n- [Split](#split-into-text-lines) the output into text lines, or [iterate](#iterate-over-text-lines) progressively over them.\n- Strip [unnecessary newlines](docs/lines.md#newlines).\n- Pass any [input](docs/input.md) to the subprocess: [files](#file-input), [strings](#simple-input), [`Uint8Array`s](docs/binary.md#binary-input), [iterables](docs/streams.md#iterables-as-input), [objects](docs/transform.md#object-mode) and almost any [other type](#any-input-type).\n- Return [almost any type](#any-output-type) from the subprocess, or redirect it to [files](#file-output).\n- Get [interleaved output](#interleaved-output) from `stdout` and `stderr` similar to what is printed on the terminal.\n- Retrieve the output [programmatically and print it](#programmatic--terminal-output) on the console at the same time.\n- [Transform or filter](#transformfilter-output) the input and output with [simple functions](docs/transform.md).\n- Pass [Node.js streams](docs/streams.md#nodejs-streams) or [web streams](#web-streams) to subprocesses, or [convert](#convert-to-duplex-stream) subprocesses to [a stream](docs/streams.md#converting-a-subprocess-to-a-stream).\n- [Exchange messages](#exchange-messages) with the subprocess.\n- Ensure subprocesses exit even when they [intercept termination signals](docs/termination.md#forceful-termination), or when the current process [ends abruptly](docs/termination.md#current-process-exit).\n\n## Install\n\n```sh\nnpm install execa\n```\n\n## Documentation\n\nExecution:\n- ▶️ [Basic execution](docs/execution.md)\n- 💬 [Escaping/quoting](docs/escaping.md)\n- 💻 [Shell](docs/shell.md)\n- 📜 [Scripts](docs/scripts.md)\n- 🐢 [Node.js files](docs/node.md)\n- 🌐 [Environment](docs/environment.md)\n- ❌ [Errors](docs/errors.md)\n- 🏁 [Termination](docs/termination.md)\n\nInput/output:\n- 🎹 [Input](docs/input.md)\n- 📢 [Output](docs/output.md)\n- 📃 [Text lines](docs/lines.md)\n- 🤖 [Binary data](docs/binary.md)\n- 🧙 [Transforms](docs/transform.md)\n\nAdvanced usage:\n- 🔀 [Piping multiple subprocesses](docs/pipe.md)\n- ⏳️ [Streams](docs/streams.md)\n- 📞 [Inter-process communication](docs/ipc.md)\n- 🐛 [Debugging](docs/debugging.md)\n- 📎 [Windows](docs/windows.md)\n- 🔍 [Difference with Bash and zx](docs/bash.md)\n- 🐭 [Small packages](docs/small.md)\n- 🤓 [TypeScript](docs/typescript.md)\n- 📔 [API reference](docs/api.md)\n\n## Examples\n\n### Execution\n\n#### Simple syntax\n\n```js\nimport {execa} from 'execa';\n\nconst {stdout} = await execa`npm run build`;\n// Print command's output\nconsole.log(stdout);\n```\n\n#### Script\n\n```js\nimport {$} from 'execa';\n\nconst {stdout: name} = await $`cat package.json`.pipe`grep name`;\nconsole.log(name);\n\nconst branch = await $`git branch --show-current`;\nawait $`dep deploy --branch=${branch}`;\n\nawait Promise.all([\n\t$`sleep 1`,\n\t$`sleep 2`,\n\t$`sleep 3`,\n]);\n\nconst directoryName = 'foo bar';\nawait $`mkdir /tmp/${directoryName}`;\n```\n\n#### Local binaries\n\n```sh\n$ npm install -D eslint\n```\n\n```js\nawait execa({preferLocal: true})`eslint`;\n```\n\n#### Pipe multiple subprocesses\n\n```js\nconst {stdout, pipedFrom} = await execa`npm run build`\n\t.pipe`sort`\n\t.pipe`head -n 2`;\n\n// Output of `npm run build | sort | head -n 2`\nconsole.log(stdout);\n// Output of `npm run build | sort`\nconsole.log(pipedFrom[0].stdout);\n// Output of `npm run build`\nconsole.log(pipedFrom[0].pipedFrom[0].stdout);\n```\n\n### Input/output\n\n#### Interleaved output\n\n```js\nconst {all} = await execa({all: true})`npm run build`;\n// stdout + stderr, interleaved\nconsole.log(all);\n```\n\n#### Programmatic + terminal output\n\n```js\nconst {stdout} = await execa({stdout: ['pipe', 'inherit']})`npm run build`;\n// stdout is also printed to the terminal\nconsole.log(stdout);\n```\n\n#### Simple input\n\n```js\nconst getInputString = () => { /* ... */ };\nconst {stdout} = await execa({input: getInputString()})`sort`;\nconsole.log(stdout);\n```\n\n#### File input\n\n```js\n// Similar to: npm run build < input.txt\nawait execa({stdin: {file: 'input.txt'}})`npm run build`;\n```\n\n#### File output\n\n```js\n// Similar to: npm run build > output.txt\nawait execa({stdout: {file: 'output.txt'}})`npm run build`;\n```\n\n#### Split into text lines\n\n```js\nconst {stdout} = await execa({lines: true})`npm run build`;\n// Print first 10 lines\nconsole.log(stdout.slice(0, 10).join('\\n'));\n```\n\n### Streaming\n\n#### Iterate over text lines\n\n```js\nfor await (const line of execa`npm run build`) {\n\tif (line.includes('WARN')) {\n\t\tconsole.warn(line);\n\t}\n}\n```\n\n#### Transform/filter output\n\n```js\nlet count = 0;\n\n// Filter out secret lines, then prepend the line number\nconst transform = function * (line) {\n\tif (!line.includes('secret')) {\n\t\tyield `[${count++}] ${line}`;\n\t}\n};\n\nawait execa({stdout: transform})`npm run build`;\n```\n\n#### Web streams\n\n```js\nconst response = await fetch('https://example.com');\nawait execa({stdin: response.body})`sort`;\n```\n\n#### Convert to Duplex stream\n\n```js\nimport {execa} from 'execa';\nimport {pipeline} from 'node:stream/promises';\nimport {createReadStream, createWriteStream} from 'node:fs';\n\nawait pipeline(\n\tcreateReadStream('./input.txt'),\n\texeca`node ./transform.js`.duplex(),\n\tcreateWriteStream('./output.txt'),\n);\n```\n\n### IPC\n\n#### Exchange messages\n\n```js\n// parent.js\nimport {execaNode} from 'execa';\n\nconst subprocess = execaNode`child.js`;\nawait subprocess.sendMessage('Hello from parent');\nconst message = await subprocess.getOneMessage();\nconsole.log(message); // 'Hello from child'\n```\n\n```js\n// child.js\nimport {getOneMessage, sendMessage} from 'execa';\n\nconst message = await getOneMessage(); // 'Hello from parent'\nconst newMessage = message.replace('parent', 'child'); // 'Hello from child'\nawait sendMessage(newMessage);\n```\n\n#### Any input type\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst ipcInput = [\n\t{task: 'lint', ignore: /test\\.js/},\n\t{task: 'copy', files: new Set(['main.js', 'index.js']),\n}];\nawait execaNode({ipcInput})`build.js`;\n```\n\n```js\n// build.js\nimport {getOneMessage} from 'execa';\n\nconst ipcInput = await getOneMessage();\n```\n\n#### Any output type\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst {ipcOutput} = await execaNode`build.js`;\nconsole.log(ipcOutput[0]); // {kind: 'start', timestamp: date}\nconsole.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}\n```\n\n```js\n// build.js\nimport {sendMessage} from 'execa';\n\nconst runBuild = () => { /* ... */ };\n\nawait sendMessage({kind: 'start', timestamp: new Date()});\nawait runBuild();\nawait sendMessage({kind: 'stop', timestamp: new Date()});\n```\n\n#### Graceful termination\n\n```js\n// main.js\nimport {execaNode} from 'execa';\n\nconst controller = new AbortController();\nsetTimeout(() => {\n\tcontroller.abort();\n}, 5000);\n\nawait execaNode({\n\tcancelSignal: controller.signal,\n\tgracefulCancel: true,\n})`build.js`;\n```\n\n```js\n// build.js\nimport {getCancelSignal} from 'execa';\n\nconst cancelSignal = await getCancelSignal();\nconst url = 'https://example.com/build/info';\nconst response = await fetch(url, {signal: cancelSignal});\n```\n\n### Debugging\n\n#### Detailed error\n\n```js\nimport {execa, ExecaError} from 'execa';\n\ntry {\n\tawait execa`unknown command`;\n} catch (error) {\n\tif (error instanceof ExecaError) {\n\t\tconsole.log(error);\n\t}\n\t/*\n\tExecaError: Command failed with ENOENT: unknown command\n\tspawn unknown ENOENT\n\t\t\tat ...\n\t\t\tat ... {\n\t\tshortMessage: 'Command failed with ENOENT: unknown command\\nspawn unknown ENOENT',\n\t\toriginalMessage: 'spawn unknown ENOENT',\n\t\tcommand: 'unknown command',\n\t\tescapedCommand: 'unknown command',\n\t\tcwd: '/path/to/cwd',\n\t\tdurationMs: 28.217566,\n\t\tfailed: true,\n\t\ttimedOut: false,\n\t\tisCanceled: false,\n\t\tisTerminated: false,\n\t\tisMaxBuffer: false,\n\t\tcode: 'ENOENT',\n\t\tstdout: '',\n\t\tstderr: '',\n\t\tstdio: [undefined, '', ''],\n\t\tpipedFrom: []\n\t\t[cause]: Error: spawn unknown ENOENT\n\t\t\t\tat ...\n\t\t\t\tat ... {\n\t\t\terrno: -2,\n\t\t\tcode: 'ENOENT',\n\t\t\tsyscall: 'spawn unknown',\n\t\t\tpath: 'unknown',\n\t\t\tspawnargs: [ 'command' ]\n\t\t}\n\t}\n\t*/\n}\n```\n\n#### Verbose mode\n\n```js\nawait execa`npm run build`;\nawait execa`npm run test`;\n```\n\n<img alt=\"execa verbose output\" src=\"media/verbose.png\" width=\"603\">\n\n#### Custom logging\n\n```js\nimport {execa as execa_} from 'execa';\nimport {createLogger, transports} from 'winston';\n\n// Log to a file using Winston\nconst transport = new transports.File({filename: 'logs.txt'});\nconst logger = createLogger({transports: [transport]});\nconst LOG_LEVELS = {\n\tcommand: 'info',\n\toutput: 'verbose',\n\tipc: 'verbose',\n\terror: 'error',\n\tduration: 'info',\n};\n\nconst execa = execa_({\n\tverbose(verboseLine, {message, ...verboseObject}) {\n\t\tconst level = LOG_LEVELS[verboseObject.type];\n\t\tlogger[level](message, verboseObject);\n\t},\n});\n\nawait execa`npm run build`;\nawait execa`npm run test`;\n```\n\n## Related\n\n- [nano-spawn](https://github.com/sindresorhus/nano-spawn) - Like Execa but [smaller](docs/small.md)\n- [gulp-execa](https://github.com/ehmicky/gulp-execa) - Gulp plugin for Execa\n- [nvexeca](https://github.com/ehmicky/nvexeca) - Run Execa using any Node.js version\n\n## Maintainers\n\n- [Sindre Sorhus](https://github.com/sindresorhus)\n- [@ehmicky](https://github.com/ehmicky)\n"
  },
  {
    "path": "test/arguments/cwd.js",
    "content": "import {mkdir, rmdir} from 'node:fs/promises';\nimport path from 'node:path';\nimport process from 'node:process';\nimport {pathToFileURL, fileURLToPath} from 'node:url';\nimport tempfile from 'tempfile';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {FIXTURES_DIRECTORY, setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {majorNodeVersion} from '../helpers/node-version.js';\n\nsetFixtureDirectory();\n\nconst isWindows = process.platform === 'win32';\n\nconst testOptionCwdString = async (t, execaMethod) => {\n\tconst cwd = '/';\n\tconst {stdout} = await execaMethod('node', ['-p', 'process.cwd()'], {cwd});\n\tt.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));\n};\n\ntest('The \"cwd\" option can be a string', testOptionCwdString, execa);\ntest('The \"cwd\" option can be a string - sync', testOptionCwdString, execaSync);\n\nconst testOptionCwdUrl = async (t, execaMethod) => {\n\tconst cwd = '/';\n\tconst cwdUrl = pathToFileURL(cwd);\n\tconst {stdout} = await execaMethod('node', ['-p', 'process.cwd()'], {cwd: cwdUrl});\n\tt.is(path.toNamespacedPath(stdout), path.toNamespacedPath(cwd));\n};\n\ntest('The \"cwd\" option can be a URL', testOptionCwdUrl, execa);\ntest('The \"cwd\" option can be a URL - sync', testOptionCwdUrl, execaSync);\n\nconst testOptionCwdInvalid = (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', {cwd: true});\n\t}, {message: /The \"cwd\" option must be a string or a file URL: true/});\n};\n\ntest('The \"cwd\" option cannot be an invalid type', testOptionCwdInvalid, execa);\ntest('The \"cwd\" option cannot be an invalid type - sync', testOptionCwdInvalid, execaSync);\n\nconst testErrorCwdDefault = async (t, execaMethod) => {\n\tconst {cwd} = await execaMethod('empty.js');\n\tt.is(cwd, process.cwd());\n};\n\ntest('The \"cwd\" option defaults to process.cwd()', testErrorCwdDefault, execa);\ntest('The \"cwd\" option defaults to process.cwd() - sync', testErrorCwdDefault, execaSync);\n\n// Windows does not allow removing a directory used as `cwd` of a running subprocess\nif (!isWindows) {\n\tconst testCwdPreSpawn = async (t, execaMethod) => {\n\t\tconst currentCwd = process.cwd();\n\t\tconst filePath = tempfile();\n\t\tawait mkdir(filePath);\n\t\tprocess.chdir(filePath);\n\t\tawait rmdir(filePath);\n\n\t\ttry {\n\t\t\tt.throws(() => {\n\t\t\t\texecaMethod('empty.js');\n\t\t\t}, {message: /The current directory does not exist/});\n\t\t} finally {\n\t\t\tprocess.chdir(currentCwd);\n\t\t}\n\t};\n\n\ttest.serial('The \"cwd\" option default fails if current cwd is missing', testCwdPreSpawn, execa);\n\ttest.serial('The \"cwd\" option default fails if current cwd is missing - sync', testCwdPreSpawn, execaSync);\n}\n\nconst cwdNotExisting = {cwd: 'does_not_exist', expectedCode: 'ENOENT', expectedMessage: 'The \"cwd\" option is invalid'};\nconst cwdTooLong = {cwd: '.'.repeat(1e5), expectedCode: isWindows && majorNodeVersion >= 20 ? 'ENOENT' : 'ENAMETOOLONG', expectedMessage: 'The \"cwd\" option is invalid'};\n// @todo: use import.meta.dirname after dropping support for Node <20.11.0\nconst cwdNotDirectory = {cwd: fileURLToPath(import.meta.url), expectedCode: isWindows ? 'ENOENT' : 'ENOTDIR', expectedMessage: 'The \"cwd\" option is not a directory'};\n\nconst testCwdPostSpawn = async (t, {cwd, expectedCode, expectedMessage}, execaMethod) => {\n\tconst {failed, code, message} = await execaMethod('empty.js', {cwd, reject: false});\n\tt.true(failed);\n\tt.is(code, expectedCode);\n\tt.true(message.includes(expectedMessage));\n\tt.true(message.includes(cwd));\n};\n\ntest('The \"cwd\" option must be an existing file', testCwdPostSpawn, cwdNotExisting, execa);\ntest('The \"cwd\" option must be an existing file - sync', testCwdPostSpawn, cwdNotExisting, execaSync);\ntest('The \"cwd\" option must not be too long', testCwdPostSpawn, cwdTooLong, execa);\ntest('The \"cwd\" option must not be too long - sync', testCwdPostSpawn, cwdTooLong, execaSync);\ntest('The \"cwd\" option must be a directory', testCwdPostSpawn, cwdNotDirectory, execa);\ntest('The \"cwd\" option must be a directory - sync', testCwdPostSpawn, cwdNotDirectory, execaSync);\n\nconst successProperties = {fixtureName: 'empty.js', expectedFailed: false};\nconst errorProperties = {fixtureName: 'fail.js', expectedFailed: true};\n\nconst testErrorCwd = async (t, execaMethod, {fixtureName, expectedFailed}) => {\n\tconst {failed, cwd} = await execaMethod(fixtureName, {cwd: path.relative('.', FIXTURES_DIRECTORY), reject: false});\n\tt.is(failed, expectedFailed);\n\tt.is(cwd, FIXTURES_DIRECTORY);\n};\n\ntest('result.cwd is defined', testErrorCwd, execa, successProperties);\ntest('result.cwd is defined - sync', testErrorCwd, execaSync, successProperties);\ntest('error.cwd is defined', testErrorCwd, execa, errorProperties);\ntest('error.cwd is defined - sync', testErrorCwd, execaSync, errorProperties);\n"
  },
  {
    "path": "test/arguments/encoding-option.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst testInvalidEncoding = (t, encoding, message, execaMethod) => {\n\tconst error = t.throws(() => {\n\t\texecaMethod('empty.js', {encoding});\n\t});\n\tt.true(error.message.includes(message));\n};\n\nconst UNKNOWN_ENCODING_MESSAGE = 'Please rename it to one of';\nconst getCorrectEncodingMessage = correctEncoding => `Please rename it to \"${correctEncoding}\"`;\n\ntest('cannot pass unknown encodings', testInvalidEncoding, 'unknown', UNKNOWN_ENCODING_MESSAGE, execa);\ntest('cannot pass unknown encodings, sync', testInvalidEncoding, 'unknown', UNKNOWN_ENCODING_MESSAGE, execaSync);\ntest('cannot pass empty encodings', testInvalidEncoding, '', UNKNOWN_ENCODING_MESSAGE, execa);\ntest('cannot pass encoding: false', testInvalidEncoding, false, UNKNOWN_ENCODING_MESSAGE, execa);\ntest('cannot pass encoding: Symbol', testInvalidEncoding, Symbol('test'), UNKNOWN_ENCODING_MESSAGE, execa);\ntest('cannot pass encoding: null', testInvalidEncoding, null, getCorrectEncodingMessage('buffer'), execa);\ntest('cannot pass encoding: null, sync', testInvalidEncoding, null, getCorrectEncodingMessage('buffer'), execaSync);\n/* eslint-disable unicorn/text-encoding-identifier-case */\ntest('cannot pass encoding: utf-8', testInvalidEncoding, 'utf-8', getCorrectEncodingMessage('utf8'), execa);\ntest('cannot pass encoding: utf-8, sync', testInvalidEncoding, 'utf-8', getCorrectEncodingMessage('utf8'), execaSync);\ntest('cannot pass encoding: UTF-8', testInvalidEncoding, 'UTF-8', getCorrectEncodingMessage('utf8'), execa);\ntest('cannot pass encoding: UTF-8, sync', testInvalidEncoding, 'UTF-8', getCorrectEncodingMessage('utf8'), execaSync);\ntest('cannot pass encoding: UTF8', testInvalidEncoding, 'UTF8', getCorrectEncodingMessage('utf8'), execa);\ntest('cannot pass encoding: UTF8, sync', testInvalidEncoding, 'UTF8', getCorrectEncodingMessage('utf8'), execaSync);\n/* eslint-enable unicorn/text-encoding-identifier-case */\ntest('cannot pass encoding: utf-16le', testInvalidEncoding, 'utf-16le', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: UTF-16LE', testInvalidEncoding, 'UTF-16LE', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: UTF16LE', testInvalidEncoding, 'UTF16LE', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: ucs2', testInvalidEncoding, 'ucs2', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: UCS2', testInvalidEncoding, 'UCS2', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: ucs-2', testInvalidEncoding, 'ucs-2', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: UCS-2', testInvalidEncoding, 'UCS-2', getCorrectEncodingMessage('utf16le'), execa);\ntest('cannot pass encoding: binary', testInvalidEncoding, 'binary', getCorrectEncodingMessage('latin1'), execa);\n"
  },
  {
    "path": "test/arguments/env.js",
    "content": "import process from 'node:process';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory, PATH_KEY} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\nprocess.env.FOO = 'foo';\n\nconst isWindows = process.platform === 'win32';\n\ntest('use environment variables by default', async t => {\n\tconst {stdout} = await execa('environment.js');\n\tt.deepEqual(stdout.split('\\n'), ['foo', 'undefined']);\n});\n\ntest('extend environment variables by default', async t => {\n\tconst {stdout} = await execa('environment.js', [], {env: {BAR: 'bar', [PATH_KEY]: process.env[PATH_KEY]}});\n\tt.deepEqual(stdout.split('\\n'), ['foo', 'bar']);\n});\n\ntest('do not extend environment with `extendEnv: false`', async t => {\n\tconst {stdout} = await execa('environment.js', [], {env: {BAR: 'bar', [PATH_KEY]: process.env[PATH_KEY]}, extendEnv: false});\n\tt.deepEqual(stdout.split('\\n'), ['undefined', 'bar']);\n});\n\ntest('use extend environment with `extendEnv: true` and `shell: true`', async t => {\n\tprocess.env.TEST = 'test';\n\tconst command = isWindows ? 'echo %TEST%' : 'echo $TEST';\n\tconst {stdout} = await execa(command, {shell: true, env: {}, extendEnv: true});\n\tt.is(stdout, 'test');\n\tdelete process.env.TEST;\n});\n"
  },
  {
    "path": "test/arguments/escape-no-icu.js",
    "content": "// Mimics Node.js when built without ICU support\n// See https://github.com/sindresorhus/execa/issues/1143\nglobalThis.RegExp = class extends RegExp {\n\tconstructor(regExpString, flags) {\n\t\tif (flags?.includes('u') && regExpString.includes('\\\\p{')) {\n\t\t\tthrow new Error('Invalid property name');\n\t\t}\n\n\t\tsuper(regExpString, flags);\n\t}\n\n\tstatic isMocked = true;\n};\n\n// Execa computes the RegExp when first loaded, so we must delay this import\nawait import('./escape.js');\n"
  },
  {
    "path": "test/arguments/escape.js",
    "content": "import {platform} from 'node:process';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst isWindows = platform === 'win32';\n\nconst testResultCommand = async (t, expected, ...commandArguments) => {\n\tconst {command: failCommand} = await t.throwsAsync(execa('fail.js', commandArguments));\n\tt.is(failCommand, `fail.js${expected}`);\n\n\tconst {command} = await execa('noop.js', commandArguments);\n\tt.is(command, `noop.js${expected}`);\n};\n\ntestResultCommand.title = (message, expected) => `result.command is: ${JSON.stringify(expected)}`;\n\ntest(testResultCommand, ' foo bar', 'foo', 'bar');\ntest(testResultCommand, ' baz quz', 'baz', 'quz');\ntest(testResultCommand, '');\n\n// eslint-disable-next-line max-params\nconst testEscapedCommand = async (t, commandArguments, expectedUnix, expectedWindows, expectedUnixNoIcu = expectedUnix, expectedWindowsNoIcu = expectedWindows) => {\n\tconst expected = RegExp.isMocked\n\t\t? (isWindows ? expectedWindowsNoIcu : expectedUnixNoIcu)\n\t\t: (isWindows ? expectedWindows : expectedUnix);\n\n\tt.like(\n\t\tawait t.throwsAsync(execa('fail.js', commandArguments)),\n\t\t{escapedCommand: `fail.js ${expected}`},\n\t);\n\n\tt.like(t.throws(() => {\n\t\texecaSync('fail.js', commandArguments);\n\t}), {escapedCommand: `fail.js ${expected}`});\n\n\tt.like(\n\t\tawait execa('noop.js', commandArguments),\n\t\t{escapedCommand: `noop.js ${expected}`},\n\t);\n\n\tt.like(\n\t\texecaSync('noop.js', commandArguments),\n\t\t{escapedCommand: `noop.js ${expected}`},\n\t);\n};\n\ntest('result.escapedCommand - foo bar', testEscapedCommand, ['foo', 'bar'], 'foo bar', 'foo bar');\ntest('result.escapedCommand - foo\\\\ bar', testEscapedCommand, ['foo bar'], '\\'foo bar\\'', '\"foo bar\"');\ntest('result.escapedCommand - \"foo\"', testEscapedCommand, ['\"foo\"'], '\\'\"foo\"\\'', '\"\"\"foo\"\"\"');\ntest('result.escapedCommand - \\'foo\\'', testEscapedCommand, ['\\'foo\\''], '\\'\\'\\\\\\'\\'foo\\'\\\\\\'\\'\\'', '\"\\'foo\\'\"');\ntest('result.escapedCommand - \"0\"', testEscapedCommand, ['0'], '0', '0');\ntest('result.escapedCommand - 0', testEscapedCommand, [0], '0', '0');\ntest('result.escapedCommand - *', testEscapedCommand, ['*'], '\\'*\\'', '\"*\"');\ntest('result.escapedCommand - .', testEscapedCommand, ['.'], '.', '.');\ntest('result.escapedCommand - -', testEscapedCommand, ['-'], '-', '-');\ntest('result.escapedCommand - _', testEscapedCommand, ['_'], '_', '_');\ntest('result.escapedCommand - /', testEscapedCommand, ['/'], '/', '/');\ntest('result.escapedCommand - ,', testEscapedCommand, [','], '\\',\\'', '\",\"');\ntest('result.escapedCommand - :', testEscapedCommand, [':'], '\\':\\'', '\":\"');\ntest('result.escapedCommand - ;', testEscapedCommand, [';'], '\\';\\'', '\";\"');\ntest('result.escapedCommand - ~', testEscapedCommand, ['~'], '\\'~\\'', '\"~\"');\ntest('result.escapedCommand - %', testEscapedCommand, ['%'], '\\'%\\'', '\"%\"');\ntest('result.escapedCommand - $', testEscapedCommand, ['$'], '\\'$\\'', '\"$\"');\ntest('result.escapedCommand - !', testEscapedCommand, ['!'], '\\'!\\'', '\"!\"');\ntest('result.escapedCommand - ?', testEscapedCommand, ['?'], '\\'?\\'', '\"?\"');\ntest('result.escapedCommand - #', testEscapedCommand, ['#'], '\\'#\\'', '\"#\"');\ntest('result.escapedCommand - &', testEscapedCommand, ['&'], '\\'&\\'', '\"&\"');\ntest('result.escapedCommand - =', testEscapedCommand, ['='], '\\'=\\'', '\"=\"');\ntest('result.escapedCommand - @', testEscapedCommand, ['@'], '\\'@\\'', '\"@\"');\ntest('result.escapedCommand - ^', testEscapedCommand, ['^'], '\\'^\\'', '\"^\"');\ntest('result.escapedCommand - `', testEscapedCommand, ['`'], '\\'`\\'', '\"`\"');\ntest('result.escapedCommand - |', testEscapedCommand, ['|'], '\\'|\\'', '\"|\"');\ntest('result.escapedCommand - +', testEscapedCommand, ['+'], '\\'+\\'', '\"+\"');\ntest('result.escapedCommand - \\\\', testEscapedCommand, ['\\\\'], '\\'\\\\\\'', '\"\\\\\"');\ntest('result.escapedCommand - ()', testEscapedCommand, ['()'], '\\'()\\'', '\"()\"');\ntest('result.escapedCommand - {}', testEscapedCommand, ['{}'], '\\'{}\\'', '\"{}\"');\ntest('result.escapedCommand - []', testEscapedCommand, ['[]'], '\\'[]\\'', '\"[]\"');\ntest('result.escapedCommand - <>', testEscapedCommand, ['<>'], '\\'<>\\'', '\"<>\"');\ntest('result.escapedCommand - ã', testEscapedCommand, ['ã'], '\\'ã\\'', '\"ã\"');\ntest('result.escapedCommand - \\\\a', testEscapedCommand, ['\\u0007'], '\\'\\\\u0007\\'', '\"\\\\u0007\"');\ntest('result.escapedCommand - \\\\b', testEscapedCommand, ['\\b'], '\\'\\\\b\\'', '\"\\\\b\"');\ntest('result.escapedCommand - \\\\e', testEscapedCommand, ['\\u001B'], '\\'\\\\u001b\\'', '\"\\\\u001b\"');\ntest('result.escapedCommand - \\\\f', testEscapedCommand, ['\\f'], '\\'\\\\f\\'', '\"\\\\f\"');\ntest('result.escapedCommand - \\\\n', testEscapedCommand, ['\\n'], '\\'\\\\n\\'', '\"\\\\n\"');\ntest('result.escapedCommand - \\\\r\\\\n', testEscapedCommand, ['\\r\\n'], '\\'\\\\r\\\\n\\'', '\"\\\\r\\\\n\"');\ntest('result.escapedCommand - \\\\t', testEscapedCommand, ['\\t'], '\\'\\\\t\\'', '\"\\\\t\"');\ntest('result.escapedCommand - \\\\v', testEscapedCommand, ['\\v'], '\\'\\\\u000b\\'', '\"\\\\u000b\"');\ntest('result.escapedCommand - \\\\x01', testEscapedCommand, ['\\u0001'], '\\'\\\\u0001\\'', '\"\\\\u0001\"');\ntest('result.escapedCommand - \\\\x7f', testEscapedCommand, ['\\u007F'], '\\'\\\\u007f\\'', '\"\\\\u007f\"');\ntest('result.escapedCommand - \\\\u0085', testEscapedCommand, ['\\u0085'], '\\'\\\\u0085\\'', '\"\\\\u0085\"');\ntest('result.escapedCommand - \\\\u2000', testEscapedCommand, ['\\u2000'], '\\'\\\\u2000\\'', '\"\\\\u2000\"');\ntest('result.escapedCommand - \\\\u200E', testEscapedCommand, ['\\u200E'], '\\'\\\\u200e\\'', '\"\\\\u200e\"', '\\'\\u200E\\'', '\"\\u200E\"');\ntest('result.escapedCommand - \\\\u2028', testEscapedCommand, ['\\u2028'], '\\'\\\\u2028\\'', '\"\\\\u2028\"');\ntest('result.escapedCommand - \\\\u2029', testEscapedCommand, ['\\u2029'], '\\'\\\\u2029\\'', '\"\\\\u2029\"');\ntest('result.escapedCommand - \\\\u5555', testEscapedCommand, ['\\u5555'], '\\'\\u5555\\'', '\"\\u5555\"');\ntest('result.escapedCommand - \\\\uD800', testEscapedCommand, ['\\uD800'], '\\'\\\\ud800\\'', '\"\\\\ud800\"', '\\'\\uD800\\'', '\"\\uD800\"');\ntest('result.escapedCommand - \\\\uE000', testEscapedCommand, ['\\uE000'], '\\'\\\\ue000\\'', '\"\\\\ue000\"', '\\'\\uE000\\'', '\"\\uE000\"');\ntest('result.escapedCommand - \\\\U1D172', testEscapedCommand, ['\\u{1D172}'], '\\'\\u{1D172}\\'', '\"\\u{1D172}\"');\ntest('result.escapedCommand - \\\\U1D173', testEscapedCommand, ['\\u{1D173}'], '\\'\\\\U1d173\\'', '\"\\\\U1d173\"', '\\'\\u{1D173}\\'', '\"\\u{1D173}\"');\ntest('result.escapedCommand - \\\\U10FFFD', testEscapedCommand, ['\\u{10FFFD}'], '\\'\\\\U10fffd\\'', '\"\\\\U10fffd\"', '\\'\\u{10FFFD}\\'', '\"\\u{10FFFD}\"');\n"
  },
  {
    "path": "test/arguments/fd-options.js",
    "content": "import {PassThrough} from 'node:stream';\nimport {spawn} from 'node:child_process';\nimport process from 'node:process';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio, getStdio} from '../helpers/stdio.js';\nimport {getEarlyErrorSubprocess} from '../helpers/early-error.js';\nimport {assertPipeError} from '../helpers/pipe.js';\n\nsetFixtureDirectory();\n\nconst getMessage = message => Array.isArray(message)\n\t? `\"${message[0]}: ${message[1]}\" option is incompatible`\n\t: message;\n\nconst testPipeError = async (t, {\n\tmessage,\n\tsourceOptions = {},\n\tdestinationOptions = {},\n\tgetSource = () => execa('empty.js', sourceOptions),\n\tgetDestination = () => execa('empty.js', destinationOptions),\n\tisScript = false,\n\tfrom,\n\tto,\n}) => {\n\tconst source = getSource();\n\tconst pipePromise = isScript ? source.pipe({from, to})`empty.js` : source.pipe(getDestination(), {from, to});\n\tawait assertPipeError(t, pipePromise, getMessage(message));\n};\n\nconst testNodeStream = async (t, {\n\tmessage,\n\tsourceOptions = {},\n\tgetSource = () => execa('empty.js', sourceOptions),\n\tfrom,\n\tto,\n\twritable = to !== undefined,\n}) => {\n\tassertNodeStream({\n\t\tt,\n\t\tmessage,\n\t\tgetSource,\n\t\tfrom,\n\t\tto,\n\t\tmethodName: writable ? 'writable' : 'readable',\n\t});\n\tassertNodeStream({\n\t\tt,\n\t\tmessage,\n\t\tgetSource,\n\t\tfrom,\n\t\tto,\n\t\tmethodName: 'duplex',\n\t});\n};\n\nconst assertNodeStream = ({t, message, getSource, from, to, methodName}) => {\n\tconst error = t.throws(() => {\n\t\tgetSource()[methodName]({from, to});\n\t});\n\tt.true(error.message.includes(getMessage(message)));\n};\n\nconst testIterable = async (t, {\n\tmessage,\n\tsourceOptions = {},\n\tgetSource = () => execa('empty.js', sourceOptions),\n\tfrom,\n}) => {\n\tconst error = t.throws(() => {\n\t\tgetSource().iterable({from});\n\t});\n\tt.true(error.message.includes(getMessage(message)));\n};\n\ntest('Must set \"all\" option to \"true\" to use .pipe(\"all\")', testPipeError, {\n\tfrom: 'all',\n\tmessage: '\"all\" option must be true',\n});\ntest('Must set \"all\" option to \"true\" to use .duplex(\"all\")', testNodeStream, {\n\tfrom: 'all',\n\tmessage: '\"all\" option must be true',\n});\ntest('Must set \"all\" option to \"true\" to use .iterable(\"all\")', testIterable, {\n\tfrom: 'all',\n\tmessage: '\"all\" option must be true',\n});\ntest('.pipe() cannot pipe to non-subprocesses', testPipeError, {\n\tgetDestination: () => new PassThrough(),\n\tmessage: 'an Execa subprocess',\n});\ntest('.pipe() cannot pipe to non-Execa subprocesses', testPipeError, {\n\tgetDestination: () => spawn('node', ['--version']),\n\tmessage: 'an Execa subprocess',\n});\ntest('.pipe() \"from\" option cannot be \"stdin\"', testPipeError, {\n\tfrom: 'stdin',\n\tmessage: '\"from\" must not be',\n});\ntest('.duplex() \"from\" option cannot be \"stdin\"', testNodeStream, {\n\tfrom: 'stdin',\n\tmessage: '\"from\" must not be',\n});\ntest('.iterable() \"from\" option cannot be \"stdin\"', testIterable, {\n\tfrom: 'stdin',\n\tmessage: '\"from\" must not be',\n});\ntest('$.pipe() \"from\" option cannot be \"stdin\"', testPipeError, {\n\tfrom: 'stdin',\n\tisScript: true,\n\tmessage: '\"from\" must not be',\n});\ntest('.pipe() \"to\" option cannot be \"stdout\"', testPipeError, {\n\tto: 'stdout',\n\tmessage: '\"to\" must not be',\n});\ntest('.duplex() \"to\" option cannot be \"stdout\"', testNodeStream, {\n\tto: 'stdout',\n\tmessage: '\"to\" must not be',\n});\ntest('$.pipe() \"to\" option cannot be \"stdout\"', testPipeError, {\n\tto: 'stdout',\n\tisScript: true,\n\tmessage: '\"to\" must not be',\n});\ntest('.pipe() \"from\" option cannot be any string', testPipeError, {\n\tfrom: 'other',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.duplex() \"from\" option cannot be any string', testNodeStream, {\n\tfrom: 'other',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.iterable() \"from\" option cannot be any string', testIterable, {\n\tfrom: 'other',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.pipe() \"to\" option cannot be any string', testPipeError, {\n\tto: 'other',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.duplex() \"to\" option cannot be any string', testNodeStream, {\n\tto: 'other',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.pipe() \"from\" option cannot be a number without \"fd\"', testPipeError, {\n\tfrom: '1',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.duplex() \"from\" option cannot be a number without \"fd\"', testNodeStream, {\n\tfrom: '1',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.iterable() \"from\" option cannot be a number without \"fd\"', testIterable, {\n\tfrom: '1',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.pipe() \"to\" option cannot be a number without \"fd\"', testPipeError, {\n\tto: '0',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.duplex() \"to\" option cannot be a number without \"fd\"', testNodeStream, {\n\tto: '0',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.pipe() \"from\" option cannot be just \"fd\"', testPipeError, {\n\tfrom: 'fd',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.duplex() \"from\" option cannot be just \"fd\"', testNodeStream, {\n\tfrom: 'fd',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.iterable() \"from\" option cannot be just \"fd\"', testIterable, {\n\tfrom: 'fd',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.pipe() \"to\" option cannot be just \"fd\"', testPipeError, {\n\tto: 'fd',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.duplex() \"to\" option cannot be just \"fd\"', testNodeStream, {\n\tto: 'fd',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.pipe() \"from\" option cannot be a float', testPipeError, {\n\tfrom: 'fd1.5',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.duplex() \"from\" option cannot be a float', testNodeStream, {\n\tfrom: 'fd1.5',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.iterable() \"from\" option cannot be a float', testIterable, {\n\tfrom: 'fd1.5',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.pipe() \"to\" option cannot be a float', testPipeError, {\n\tto: 'fd1.5',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.duplex() \"to\" option cannot be a float', testNodeStream, {\n\tto: 'fd1.5',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.pipe() \"from\" option cannot be a negative number', testPipeError, {\n\tfrom: 'fd-1',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.duplex() \"from\" option cannot be a negative number', testNodeStream, {\n\tfrom: 'fd-1',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.iterable() \"from\" option cannot be a negative number', testIterable, {\n\tfrom: 'fd-1',\n\tmessage: 'must be \"stdout\", \"stderr\", \"all\"',\n});\ntest('.pipe() \"to\" option cannot be a negative number', testPipeError, {\n\tto: 'fd-1',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.duplex() \"to\" option cannot be a negative number', testNodeStream, {\n\tto: 'fd-1',\n\tmessage: 'must be \"stdin\"',\n});\ntest('.pipe() \"from\" option cannot be a non-existing file descriptor', testPipeError, {\n\tfrom: 'fd3',\n\tmessage: 'file descriptor does not exist',\n});\ntest('.duplex() \"from\" cannot be a non-existing file descriptor', testNodeStream, {\n\tfrom: 'fd3',\n\tmessage: 'file descriptor does not exist',\n});\ntest('.iterable() \"from\" cannot be a non-existing file descriptor', testIterable, {\n\tfrom: 'fd3',\n\tmessage: 'file descriptor does not exist',\n});\ntest('.pipe() \"to\" option cannot be a non-existing file descriptor', testPipeError, {\n\tto: 'fd3',\n\tmessage: 'file descriptor does not exist',\n});\ntest('.duplex() \"to\" cannot be a non-existing file descriptor', testNodeStream, {\n\tto: 'fd3',\n\tmessage: 'file descriptor does not exist',\n});\ntest('.pipe() \"from\" option cannot be an input file descriptor', testPipeError, {\n\tsourceOptions: getStdio(3, new Uint8Array()),\n\tfrom: 'fd3',\n\tmessage: 'must be a readable stream',\n});\ntest('.duplex() \"from\" option cannot be an input file descriptor', testNodeStream, {\n\tsourceOptions: getStdio(3, new Uint8Array()),\n\tfrom: 'fd3',\n\tmessage: 'must be a readable stream',\n});\ntest('.iterable() \"from\" option cannot be an input file descriptor', testIterable, {\n\tsourceOptions: getStdio(3, new Uint8Array()),\n\tfrom: 'fd3',\n\tmessage: 'must be a readable stream',\n});\ntest('.pipe() \"to\" option cannot be an output file descriptor', testPipeError, {\n\tdestinationOptions: fullStdio,\n\tto: 'fd3',\n\tmessage: 'must be a writable stream',\n});\ntest('.duplex() \"to\" option cannot be an output file descriptor', testNodeStream, {\n\tsourceOptions: fullStdio,\n\tto: 'fd3',\n\tmessage: 'must be a writable stream',\n});\ntest('.pipe() \"to\" option cannot be \"all\"', testPipeError, {\n\tdestinationOptions: fullStdio,\n\tto: 'all',\n\tmessage: 'must be a writable stream',\n});\ntest('.duplex() \"to\" option cannot be \"all\"', testNodeStream, {\n\tsourceOptions: fullStdio,\n\tto: 'all',\n\tmessage: 'must be a writable stream',\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .pipe()', testPipeError, {\n\tsourceOptions: {stdout: 'ignore'},\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore'},\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .iterable()', testIterable, {\n\tsourceOptions: {stdout: 'ignore'},\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdin\" option to \"ignore\" to use .pipe()', testPipeError, {\n\tdestinationOptions: {stdin: 'ignore'},\n\tmessage: ['stdin', '\\'ignore\\''],\n});\ntest('Cannot set \"stdin\" option to \"ignore\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdin: 'ignore'},\n\tmessage: ['stdin', '\\'ignore\\''],\n\twritable: true,\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .pipe(1)', testPipeError, {\n\tsourceOptions: {stdout: 'ignore'},\n\tfrom: 'fd1',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .duplex(1)', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore'},\n\tfrom: 'fd1',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .iterable(1)', testIterable, {\n\tsourceOptions: {stdout: 'ignore'},\n\tfrom: 'fd1',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdin\" option to \"ignore\" to use .pipe(0)', testPipeError, {\n\tdestinationOptions: {stdin: 'ignore'},\n\tmessage: ['stdin', '\\'ignore\\''],\n\tto: 'fd0',\n});\ntest('Cannot set \"stdin\" option to \"ignore\" to use .duplex(0)', testNodeStream, {\n\tsourceOptions: {stdin: 'ignore'},\n\tmessage: ['stdin', '\\'ignore\\''],\n\tto: 'fd0',\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .pipe(\"stdout\")', testPipeError, {\n\tsourceOptions: {stdout: 'ignore'},\n\tfrom: 'stdout',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .duplex(\"stdout\")', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore'},\n\tfrom: 'stdout',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"ignore\" to use .iterable(\"stdout\")', testIterable, {\n\tsourceOptions: {stdout: 'ignore'},\n\tfrom: 'stdout',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdin\" option to \"ignore\" to use .pipe(\"stdin\")', testPipeError, {\n\tdestinationOptions: {stdin: 'ignore'},\n\tmessage: ['stdin', '\\'ignore\\''],\n\tto: 'stdin',\n});\ntest('Cannot set \"stdin\" option to \"ignore\" to use .duplex(\"stdin\")', testNodeStream, {\n\tsourceOptions: {stdin: 'ignore'},\n\tmessage: ['stdin', '\\'ignore\\''],\n\tto: 'stdin',\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .pipe()', testPipeError, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .iterable()', testIterable, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .pipe(1)', testPipeError, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'fd1',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .duplex(1)', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'fd1',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .iterable(1)', testIterable, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'fd1',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .pipe(\"stdout\")', testPipeError, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'stdout',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .duplex(\"stdout\")', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'stdout',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .iterable(\"stdout\")', testIterable, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'stdout',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .pipe()', testPipeError, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .iterable()', testIterable, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[0]\" option to \"ignore\" to use .pipe()', testPipeError, {\n\tdestinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},\n\tmessage: ['stdio[0]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[0]\" option to \"ignore\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},\n\tmessage: ['stdio[0]', '\\'ignore\\''],\n\twritable: true,\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .pipe(1)', testPipeError, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tfrom: 'fd1',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .duplex(1)', testNodeStream, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tfrom: 'fd1',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .iterable(1)', testIterable, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tfrom: 'fd1',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[0]\" option to \"ignore\" to use .pipe(0)', testPipeError, {\n\tdestinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},\n\tmessage: ['stdio[0]', '\\'ignore\\''],\n\tto: 'fd0',\n});\ntest('Cannot set \"stdio[0]\" option to \"ignore\" to use .duplex(0)', testNodeStream, {\n\tsourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},\n\tmessage: ['stdio[0]', '\\'ignore\\''],\n\tto: 'fd0',\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .pipe(\"stdout\")', testPipeError, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tfrom: 'stdout',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .duplex(\"stdout\")', testNodeStream, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tfrom: 'stdout',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" option to \"ignore\" to use .iterable(\"stdout\")', testIterable, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'pipe']},\n\tfrom: 'stdout',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[0]\" option to \"ignore\" to use .pipe(\"stdin\")', testPipeError, {\n\tdestinationOptions: {stdio: ['ignore', 'pipe', 'pipe']},\n\tmessage: ['stdio[0]', '\\'ignore\\''],\n\tto: 'stdin',\n});\ntest('Cannot set \"stdio[0]\" option to \"ignore\" to use .duplex(\"stdin\")', testNodeStream, {\n\tsourceOptions: {stdio: ['ignore', 'pipe', 'pipe']},\n\tmessage: ['stdio[0]', '\\'ignore\\''],\n\tto: 'stdin',\n});\ntest('Cannot set \"stderr\" option to \"ignore\" to use .pipe(2)', testPipeError, {\n\tsourceOptions: {stderr: 'ignore'},\n\tfrom: 'fd2',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stderr\" option to \"ignore\" to use .duplex(2)', testNodeStream, {\n\tsourceOptions: {stderr: 'ignore'},\n\tfrom: 'fd2',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stderr\" option to \"ignore\" to use .iterable(2)', testIterable, {\n\tsourceOptions: {stderr: 'ignore'},\n\tfrom: 'fd2',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stderr\" option to \"ignore\" to use .pipe(\"stderr\")', testPipeError, {\n\tsourceOptions: {stderr: 'ignore'},\n\tfrom: 'stderr',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stderr\" option to \"ignore\" to use .duplex(\"stderr\")', testNodeStream, {\n\tsourceOptions: {stderr: 'ignore'},\n\tfrom: 'stderr',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stderr\" option to \"ignore\" to use .iterable(\"stderr\")', testIterable, {\n\tsourceOptions: {stderr: 'ignore'},\n\tfrom: 'stderr',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .pipe(2)', testPipeError, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'fd2',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .duplex(2)', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'fd2',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .iterable(2)', testIterable, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'fd2',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .pipe(\"stderr\")', testPipeError, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'stderr',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .duplex(\"stderr\")', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'stderr',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .iterable(\"stderr\")', testIterable, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore'},\n\tfrom: 'stderr',\n\tmessage: ['stderr', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[2]\" option to \"ignore\" to use .pipe(2)', testPipeError, {\n\tsourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},\n\tfrom: 'fd2',\n\tmessage: ['stdio[2]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[2]\" option to \"ignore\" to use .duplex(2)', testNodeStream, {\n\tsourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},\n\tfrom: 'fd2',\n\tmessage: ['stdio[2]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[2]\" option to \"ignore\" to use .iterable(2)', testIterable, {\n\tsourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},\n\tfrom: 'fd2',\n\tmessage: ['stdio[2]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[2]\" option to \"ignore\" to use .pipe(\"stderr\")', testPipeError, {\n\tsourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},\n\tfrom: 'stderr',\n\tmessage: ['stdio[2]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[2]\" option to \"ignore\" to use .duplex(\"stderr\")', testNodeStream, {\n\tsourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},\n\tfrom: 'stderr',\n\tmessage: ['stdio[2]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[2]\" option to \"ignore\" to use .iterable(\"stderr\")', testIterable, {\n\tsourceOptions: {stdio: ['pipe', 'pipe', 'ignore']},\n\tfrom: 'stderr',\n\tmessage: ['stdio[2]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[3]\" option to \"ignore\" to use .pipe(3)', testPipeError, {\n\tsourceOptions: getStdio(3, 'ignore'),\n\tfrom: 'fd3',\n\tmessage: ['stdio[3]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[3]\" option to \"ignore\" to use .duplex(3)', testNodeStream, {\n\tsourceOptions: getStdio(3, 'ignore'),\n\tfrom: 'fd3',\n\tmessage: ['stdio[3]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[3]\" option to \"ignore\" to use .iterable(3)', testIterable, {\n\tsourceOptions: getStdio(3, 'ignore'),\n\tfrom: 'fd3',\n\tmessage: ['stdio[3]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .pipe(\"all\")', testPipeError, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},\n\tfrom: 'all',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .duplex(\"all\")', testNodeStream, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},\n\tfrom: 'all',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" + \"stderr\" option to \"ignore\" to use .iterable(\"all\")', testIterable, {\n\tsourceOptions: {stdout: 'ignore', stderr: 'ignore', all: true},\n\tfrom: 'all',\n\tmessage: ['stdout', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" + \"stdio[2]\" option to \"ignore\" to use .pipe(\"all\")', testPipeError, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},\n\tfrom: 'all',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" + \"stdio[2]\" option to \"ignore\" to use .duplex(\"all\")', testNodeStream, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},\n\tfrom: 'all',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdio[1]\" + \"stdio[2]\" option to \"ignore\" to use .iterable(\"all\")', testIterable, {\n\tsourceOptions: {stdio: ['pipe', 'ignore', 'ignore'], all: true},\n\tfrom: 'all',\n\tmessage: ['stdio[1]', '\\'ignore\\''],\n});\ntest('Cannot set \"stdout\" option to \"inherit\" to use .pipe()', testPipeError, {\n\tsourceOptions: {stdout: 'inherit'},\n\tmessage: ['stdout', '\\'inherit\\''],\n});\ntest('Cannot set \"stdout\" option to \"inherit\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdout: 'inherit'},\n\tmessage: ['stdout', '\\'inherit\\''],\n});\ntest('Cannot set \"stdout\" option to \"inherit\" to use .iterable()', testIterable, {\n\tsourceOptions: {stdout: 'inherit'},\n\tmessage: ['stdout', '\\'inherit\\''],\n});\ntest('Cannot set \"stdin\" option to \"inherit\" to use .pipe()', testPipeError, {\n\tdestinationOptions: {stdin: 'inherit'},\n\tmessage: ['stdin', '\\'inherit\\''],\n});\ntest('Cannot set \"stdin\" option to \"inherit\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdin: 'inherit'},\n\tmessage: ['stdin', '\\'inherit\\''],\n\twritable: true,\n});\ntest('Cannot set \"stdout\" option to \"ipc\" to use .pipe()', testPipeError, {\n\tsourceOptions: {stdout: 'ipc'},\n\tmessage: ['stdout', '\\'ipc\\''],\n});\ntest('Cannot set \"stdout\" option to \"ipc\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdout: 'ipc'},\n\tmessage: ['stdout', '\\'ipc\\''],\n});\ntest('Cannot set \"stdout\" option to \"ipc\" to use .iterable()', testIterable, {\n\tsourceOptions: {stdout: 'ipc'},\n\tmessage: ['stdout', '\\'ipc\\''],\n});\ntest('Cannot set \"stdin\" option to \"ipc\" to use .pipe()', testPipeError, {\n\tdestinationOptions: {stdin: 'ipc'},\n\tmessage: ['stdin', '\\'ipc\\''],\n});\ntest('Cannot set \"stdin\" option to \"ipc\" to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdin: 'ipc'},\n\tmessage: ['stdin', '\\'ipc\\''],\n\twritable: true,\n});\ntest('Cannot set \"stdout\" option to file descriptors to use .pipe()', testPipeError, {\n\tsourceOptions: {stdout: 1},\n\tmessage: ['stdout', '1'],\n});\ntest('Cannot set \"stdout\" option to file descriptors to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdout: 1},\n\tmessage: ['stdout', '1'],\n});\ntest('Cannot set \"stdout\" option to file descriptors to use .iterable()', testIterable, {\n\tsourceOptions: {stdout: 1},\n\tmessage: ['stdout', '1'],\n});\ntest('Cannot set \"stdin\" option to file descriptors to use .pipe()', testPipeError, {\n\tdestinationOptions: {stdin: 0},\n\tmessage: ['stdin', '0'],\n});\ntest('Cannot set \"stdin\" option to file descriptors to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdin: 0},\n\tmessage: ['stdin', '0'],\n\twritable: true,\n});\ntest('Cannot set \"stdout\" option to Node.js streams to use .pipe()', testPipeError, {\n\tsourceOptions: {stdout: process.stdout},\n\tmessage: ['stdout', 'Stream'],\n});\ntest('Cannot set \"stdout\" option to Node.js streams to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdout: process.stdout},\n\tmessage: ['stdout', 'Stream'],\n});\ntest('Cannot set \"stdout\" option to Node.js streams to use .iterable()', testIterable, {\n\tsourceOptions: {stdout: process.stdout},\n\tmessage: ['stdout', 'Stream'],\n});\ntest('Cannot set \"stdin\" option to Node.js streams to use .pipe()', testPipeError, {\n\tdestinationOptions: {stdin: process.stdin},\n\tmessage: ['stdin', 'Stream'],\n});\ntest('Cannot set \"stdin\" option to Node.js streams to use .duplex()', testNodeStream, {\n\tsourceOptions: {stdin: process.stdin},\n\tmessage: ['stdin', 'Stream'],\n\twritable: true,\n});\ntest('Cannot set \"stdio[3]\" option to Node.js Writable streams to use .pipe()', testPipeError, {\n\tsourceOptions: getStdio(3, process.stdout),\n\tmessage: ['stdio[3]', 'Stream'],\n\tfrom: 'fd3',\n});\ntest('Cannot set \"stdio[3]\" option to Node.js Writable streams to use .duplex()', testNodeStream, {\n\tsourceOptions: getStdio(3, process.stdout),\n\tmessage: ['stdio[3]', 'Stream'],\n\tfrom: 'fd3',\n});\ntest('Cannot set \"stdio[3]\" option to Node.js Writable streams to use .iterable()', testIterable, {\n\tsourceOptions: getStdio(3, process.stdout),\n\tmessage: ['stdio[3]', 'Stream'],\n\tfrom: 'fd3',\n});\ntest('Cannot set \"stdio[3]\" option to Node.js Readable streams to use .pipe()', testPipeError, {\n\tdestinationOptions: getStdio(3, process.stdin),\n\tmessage: ['stdio[3]', 'Stream'],\n\tto: 'fd3',\n});\ntest('Cannot set \"stdio[3]\" option to Node.js Readable streams to use .duplex()', testNodeStream, {\n\tsourceOptions: getStdio(3, process.stdin),\n\tmessage: ['stdio[3]', 'Stream'],\n\tto: 'fd3',\n});\n\ntest('Sets the right error message when the \"all\" option is incompatible - execa.$', async t => {\n\tawait assertPipeError(\n\t\tt,\n\t\texeca('empty.js')\n\t\t\t.pipe({all: false})`stdin.js`\n\t\t\t.pipe(execa('empty.js'), {from: 'all'}),\n\t\t'\"all\" option must be true',\n\t);\n});\n\ntest('Sets the right error message when the \"all\" option is incompatible - execa.execa', async t => {\n\tawait assertPipeError(\n\t\tt,\n\t\texeca('empty.js')\n\t\t\t.pipe(execa('stdin.js', {all: false}))\n\t\t\t.pipe(execa('empty.js'), {from: 'all'}),\n\t\t'\"all\" option must be true',\n\t);\n});\n\ntest('Sets the right error message when the \"all\" option is incompatible - early error', async t => {\n\tawait assertPipeError(\n\t\tt,\n\t\tgetEarlyErrorSubprocess()\n\t\t\t.pipe(execa('stdin.js', {all: false}))\n\t\t\t.pipe(execa('empty.js'), {from: 'all'}),\n\t\t'\"all\" option must be true',\n\t);\n});\n"
  },
  {
    "path": "test/arguments/local.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport {execa, $} from '../../index.js';\nimport {setFixtureDirectory, PATH_KEY} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\nprocess.env.FOO = 'foo';\n\nconst isWindows = process.platform === 'win32';\nconst ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;\n\nconst getPathWithoutLocalDirectory = () => {\n\tconst newPath = process.env[PATH_KEY]\n\t\t.split(path.delimiter)\n\t\t.filter(pathDirectory => !BIN_DIR_REGEXP.test(pathDirectory)).join(path.delimiter);\n\treturn {[PATH_KEY]: newPath};\n};\n\nconst BIN_DIR_REGEXP = /node_modules[\\\\/]\\.bin/;\n\nconst pathWitoutLocalDirectory = getPathWithoutLocalDirectory();\n\ntest('preferLocal: true', async t => {\n\tawait t.notThrowsAsync(execa('ava', ['--version'], {preferLocal: true, env: pathWitoutLocalDirectory}));\n});\n\ntest('preferLocal: false', async t => {\n\tawait t.throwsAsync(execa('ava', ['--version'], {preferLocal: false, env: pathWitoutLocalDirectory}), {message: ENOENT_REGEXP});\n});\n\ntest('preferLocal: undefined', async t => {\n\tawait t.throwsAsync(execa('ava', ['--version'], {env: pathWitoutLocalDirectory}), {message: ENOENT_REGEXP});\n});\n\ntest('preferLocal: undefined with $', async t => {\n\tawait t.notThrowsAsync($('ava', ['--version'], {env: pathWitoutLocalDirectory}));\n});\n\ntest('preferLocal: undefined with $.sync', t => {\n\tt.notThrows(() => $.sync('ava', ['--version'], {env: pathWitoutLocalDirectory}));\n});\n\ntest('preferLocal: undefined with execa.pipe`...`', async t => {\n\tawait t.throwsAsync(() => execa('node', ['--version']).pipe({env: pathWitoutLocalDirectory})`ava --version`);\n});\n\ntest('preferLocal: undefined with $.pipe`...`', async t => {\n\tawait t.notThrows(() => $('node', ['--version']).pipe({env: pathWitoutLocalDirectory})`ava --version`);\n});\n\ntest('preferLocal: undefined with execa.pipe()', async t => {\n\tawait t.throwsAsync(() => execa('node', ['--version']).pipe('ava', ['--version'], {env: pathWitoutLocalDirectory}));\n});\n\ntest('preferLocal: undefined with $.pipe()', async t => {\n\tawait t.notThrows(() => $('node', ['--version']).pipe('ava', ['--version'], {env: pathWitoutLocalDirectory}));\n});\n\ntest('localDir option', async t => {\n\tconst command = isWindows ? 'echo %PATH%' : 'echo $PATH';\n\tconst {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: '/test'});\n\tconst envPaths = stdout.split(path.delimiter);\n\tt.true(envPaths.some(envPath => envPath.endsWith('.bin')));\n});\n\ntest('localDir option can be a URL', async t => {\n\tconst command = isWindows ? 'echo %PATH%' : 'echo $PATH';\n\tconst {stdout} = await execa(command, {shell: true, preferLocal: true, localDir: pathToFileURL('/test')});\n\tconst envPaths = stdout.split(path.delimiter);\n\tt.true(envPaths.some(envPath => envPath.endsWith('.bin')));\n});\n"
  },
  {
    "path": "test/arguments/shell.js",
    "content": "import process from 'node:process';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport which from 'which';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {identity} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\nprocess.env.FOO = 'foo';\n\nconst isWindows = process.platform === 'win32';\n\ntest('can use `options.shell: true`', async t => {\n\tconst {stdout} = await execa('node test/fixtures/noop.js foo', {shell: true});\n\tt.is(stdout, 'foo');\n});\n\nconst testShellPath = async (t, mapPath) => {\n\tconst shellPath = isWindows ? 'cmd.exe' : 'bash';\n\tconst shell = mapPath(await which(shellPath));\n\tconst {stdout} = await execa('node test/fixtures/noop.js foo', {shell});\n\tt.is(stdout, 'foo');\n};\n\ntest('can use `options.shell: string`', testShellPath, identity);\ntest('can use `options.shell: file URL`', testShellPath, pathToFileURL);\n"
  },
  {
    "path": "test/arguments/specific.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testPriorityOrder = async (t, buffer, bufferStdout, bufferStderr, execaMethod) => {\n\tconst {stdout, stderr} = await execaMethod('noop-both.js', {buffer});\n\tt.is(stdout, bufferStdout ? foobarString : undefined);\n\tt.is(stderr, bufferStderr ? foobarString : undefined);\n};\n\ntest('buffer: {stdout, fd1}', testPriorityOrder, {stdout: true, fd1: false}, true, true, execa);\ntest('buffer: {stdout, all}', testPriorityOrder, {stdout: true, all: false}, true, false, execa);\ntest('buffer: {fd1, all}', testPriorityOrder, {fd1: true, all: false}, true, false, execa);\ntest('buffer: {stderr, fd2}', testPriorityOrder, {stderr: true, fd2: false}, true, true, execa);\ntest('buffer: {stderr, all}', testPriorityOrder, {stderr: true, all: false}, false, true, execa);\ntest('buffer: {fd2, all}', testPriorityOrder, {fd2: true, all: false}, false, true, execa);\ntest('buffer: {fd1, stdout}', testPriorityOrder, {fd1: false, stdout: true}, true, true, execa);\ntest('buffer: {all, stdout}', testPriorityOrder, {all: false, stdout: true}, true, false, execa);\ntest('buffer: {all, fd1}', testPriorityOrder, {all: false, fd1: true}, true, false, execa);\ntest('buffer: {fd2, stderr}', testPriorityOrder, {fd2: false, stderr: true}, true, true, execa);\ntest('buffer: {all, stderr}', testPriorityOrder, {all: false, stderr: true}, false, true, execa);\ntest('buffer: {all, fd2}', testPriorityOrder, {all: false, fd2: true}, false, true, execa);\ntest('buffer: {stdout, fd1}, sync', testPriorityOrder, {stdout: true, fd1: false}, true, true, execaSync);\ntest('buffer: {stdout, all}, sync', testPriorityOrder, {stdout: true, all: false}, true, false, execaSync);\ntest('buffer: {fd1, all}, sync', testPriorityOrder, {fd1: true, all: false}, true, false, execaSync);\ntest('buffer: {stderr, fd2}, sync', testPriorityOrder, {stderr: true, fd2: false}, true, true, execaSync);\ntest('buffer: {stderr, all}, sync', testPriorityOrder, {stderr: true, all: false}, false, true, execaSync);\ntest('buffer: {fd2, all}, sync', testPriorityOrder, {fd2: true, all: false}, false, true, execaSync);\ntest('buffer: {fd1, stdout}, sync', testPriorityOrder, {fd1: false, stdout: true}, true, true, execaSync);\ntest('buffer: {all, stdout}, sync', testPriorityOrder, {all: false, stdout: true}, true, false, execaSync);\ntest('buffer: {all, fd1}, sync', testPriorityOrder, {all: false, fd1: true}, true, false, execaSync);\ntest('buffer: {fd2, stderr}, sync', testPriorityOrder, {fd2: false, stderr: true}, true, true, execaSync);\ntest('buffer: {all, stderr}, sync', testPriorityOrder, {all: false, stderr: true}, false, true, execaSync);\ntest('buffer: {all, fd2}, sync', testPriorityOrder, {all: false, fd2: true}, false, true, execaSync);\n"
  },
  {
    "path": "test/convert/concurrent.js",
    "content": "import {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {fullReadableStdio} from '../helpers/stdio.js';\nimport {\n\tfinishedStream,\n\tassertStreamOutput,\n\tassertStreamError,\n\tassertStreamReadError,\n\tassertSubprocessOutput,\n\tassertSubprocessError,\n\tgetReadWriteSubprocess,\n} from '../helpers/convert.js';\n\nsetFixtureDirectory();\n\nconst endStream = async stream => {\n\tstream.end(foobarString);\n\tawait setTimeout(0);\n};\n\n// eslint-disable-next-line max-params\nconst endSameWritable = async (t, stream, secondStream, subprocess, fdNumber) => {\n\tawait endStream(stream);\n\tt.true(subprocess.stdio[fdNumber].writable);\n\n\tawait endStream(secondStream);\n\tt.false(subprocess.stdio[fdNumber].writable);\n};\n\n// eslint-disable-next-line max-params\nconst endDifferentWritable = async (t, stream, secondStream, subprocess, fdNumber = 0, secondFdNumber = 3) => {\n\tawait endStream(stream);\n\tt.false(subprocess.stdio[fdNumber].writable);\n\tt.true(subprocess.stdio[secondFdNumber].writable);\n\n\tawait endStream(secondStream);\n\tt.false(subprocess.stdio[secondFdNumber].writable);\n};\n\nconst testReadableTwice = async (t, fdNumber, from) => {\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString]);\n\tconst stream = subprocess.readable({from});\n\tconst secondStream = subprocess.readable({from});\n\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream),\n\t\tassertStreamOutput(t, secondStream),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess, foobarString, fdNumber);\n};\n\ntest('Can call .readable() twice on same file descriptor', testReadableTwice, 1);\ntest('Can call .readable({from: \"stderr\"}) twice on same file descriptor', testReadableTwice, 2, 'stderr');\n\nconst testWritableTwice = async (t, fdNumber, to, options) => {\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);\n\tconst stream = subprocess.writable({to});\n\tconst secondStream = subprocess.writable({to});\n\n\tawait Promise.all([\n\t\tfinishedStream(stream),\n\t\tfinishedStream(secondStream),\n\t\tendSameWritable(t, stream, secondStream, subprocess, fdNumber),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess, `${foobarString}${foobarString}`);\n};\n\ntest('Can call .writable() twice on same file descriptor', testWritableTwice, 0, undefined, {});\ntest('Can call .writable({to: \"fd3\"}) twice on same file descriptor', testWritableTwice, 3, 'fd3', fullReadableStdio());\n\nconst testDuplexTwice = async (t, fdNumber, to, options) => {\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);\n\tconst stream = subprocess.duplex({to});\n\tconst secondStream = subprocess.duplex({to});\n\n\tconst expectedOutput = `${foobarString}${foobarString}`;\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream, expectedOutput),\n\t\tassertStreamOutput(t, secondStream, expectedOutput),\n\t\tendSameWritable(t, stream, secondStream, subprocess, fdNumber),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n};\n\ntest('Can call .duplex() twice on same file descriptor', testDuplexTwice, 0, undefined, {});\ntest('Can call .duplex({to: \"fd3\"}) twice on same file descriptor', testDuplexTwice, 3, 'fd3', fullReadableStdio());\n\ntest('Can call .duplex() twice on same readable file descriptor but different writable one', async t => {\n\tconst subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.duplex({to: 'fd3'});\n\n\tconst expectedOutput = `${foobarString}${foobarString}`;\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream, expectedOutput),\n\t\tassertStreamOutput(t, secondStream, expectedOutput),\n\t\tendDifferentWritable(t, stream, secondStream, subprocess),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n});\n\ntest('Can call .readable() twice on different file descriptors', async t => {\n\tconst subprocess = execa('noop-both.js', [foobarString]);\n\tconst stream = subprocess.readable();\n\tconst secondStream = subprocess.readable({from: 'stderr'});\n\n\tconst expectedOutput = `${foobarString}\\n`;\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream, expectedOutput),\n\t\tassertStreamOutput(t, secondStream, expectedOutput),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n\tawait assertSubprocessOutput(t, subprocess, foobarString, 2);\n});\n\ntest('Can call .writable() twice on different file descriptors', async t => {\n\tconst subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.writable();\n\tconst secondStream = subprocess.writable({to: 'fd3'});\n\n\tawait Promise.all([\n\t\tfinishedStream(stream),\n\t\tfinishedStream(secondStream),\n\t\tendDifferentWritable(t, stream, secondStream, subprocess),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess, `${foobarString}${foobarString}`);\n});\n\ntest('Can call .duplex() twice on different file descriptors', async t => {\n\tconst subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});\n\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream),\n\t\tassertStreamOutput(t, secondStream),\n\t\tendDifferentWritable(t, stream, secondStream, subprocess),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n\tawait assertSubprocessOutput(t, subprocess, foobarString, 2);\n});\n\ntest('Can call .readable() and .writable()', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.writable();\n\tconst secondStream = subprocess.readable();\n\tstream.end(foobarString);\n\n\tawait Promise.all([\n\t\tfinishedStream(stream),\n\t\tassertStreamOutput(t, secondStream),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('Can call .writable() and .duplex()', async t => {\n\tconst subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.writable({to: 'fd3'});\n\n\tconst expectedOutput = `${foobarString}${foobarString}`;\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream, expectedOutput),\n\t\tfinishedStream(secondStream),\n\t\tendDifferentWritable(t, stream, secondStream, subprocess),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n});\n\ntest('Can call .readable() and .duplex()', async t => {\n\tconst subprocess = execa('stdin-both.js');\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.readable({from: 'stderr'});\n\tstream.end(foobarString);\n\n\tawait Promise.all([\n\t\tassertStreamOutput(t, stream),\n\t\tassertStreamOutput(t, secondStream),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n\tawait assertSubprocessOutput(t, subprocess, foobarString, 2);\n});\n\ntest('Can error one of two .readable() on same file descriptor', async t => {\n\tconst subprocess = execa('noop-fd.js', ['1', foobarString]);\n\tconst stream = subprocess.readable();\n\tconst secondStream = subprocess.readable();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tawait Promise.all([\n\t\tassertStreamReadError(t, stream, cause),\n\t\tassertStreamOutput(t, secondStream),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('Can error both .readable() on same file descriptor', async t => {\n\tconst subprocess = execa('noop-fd.js', ['1', foobarString]);\n\tconst stream = subprocess.readable();\n\tconst secondStream = subprocess.readable();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.destroy(cause);\n\n\tconst [error, secondError] = await Promise.all([\n\t\tassertStreamReadError(t, stream, {cause}),\n\t\tassertStreamReadError(t, secondStream, {cause}),\n\t]);\n\tt.is(error, secondError);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error one of two .readable() on different file descriptors', async t => {\n\tconst subprocess = execa('noop-both.js', [foobarString]);\n\tconst stream = subprocess.readable();\n\tconst secondStream = subprocess.readable({from: 'stderr'});\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tconst [error, secondError] = await Promise.all([\n\t\tassertStreamReadError(t, stream, {cause}),\n\t\tassertStreamReadError(t, secondStream, {cause}),\n\t]);\n\tt.is(error, secondError);\n\tt.is(error.stderr, foobarString);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error both .readable() on different file descriptors', async t => {\n\tconst subprocess = execa('noop-both.js', [foobarString]);\n\tconst stream = subprocess.readable();\n\tconst secondStream = subprocess.readable({from: 'stderr'});\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.destroy(cause);\n\n\tconst [error, secondError] = await Promise.all([\n\t\tassertStreamReadError(t, stream, {cause}),\n\t\tassertStreamReadError(t, secondStream, {cause}),\n\t]);\n\tt.is(error, secondError);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error one of two .writable() on same file descriptor', async t => {\n\tconst subprocess = execa('stdin.js');\n\tconst stream = subprocess.writable();\n\tconst secondStream = subprocess.writable();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.end(foobarString);\n\n\tawait Promise.all([\n\t\tassertStreamError(t, stream, cause),\n\t\tfinishedStream(secondStream),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('Can error both .writable() on same file descriptor', async t => {\n\tconst subprocess = execa('stdin.js');\n\tconst stream = subprocess.writable();\n\tconst secondStream = subprocess.writable();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.destroy(cause);\n\n\tconst [error, secondError] = await Promise.all([\n\t\tassertStreamError(t, stream, {cause}),\n\t\tassertStreamError(t, secondStream, {cause}),\n\t]);\n\tt.is(error, secondError);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error one of two .writable() on different file descriptors', async t => {\n\tconst subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.writable();\n\tconst secondStream = subprocess.writable({to: 'fd3'});\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.end(foobarString);\n\n\tconst [error, secondError] = await Promise.all([\n\t\tassertStreamError(t, stream, {cause}),\n\t\tassertStreamError(t, secondStream, {cause}),\n\t]);\n\tt.is(error, secondError);\n\tt.is(error.stdout, foobarString);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error both .writable() on different file descriptors', async t => {\n\tconst subprocess = execa('stdin-fd-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.writable();\n\tconst secondStream = subprocess.writable({to: 'fd3'});\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.destroy(cause);\n\n\tconst [error, secondError] = await Promise.all([\n\t\tassertStreamError(t, stream, {cause}),\n\t\tassertStreamError(t, secondStream, {cause}),\n\t]);\n\tt.is(error, secondError);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error one of two .duplex() on same file descriptor', async t => {\n\tconst subprocess = execa('stdin.js');\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.duplex();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.end(foobarString);\n\n\tawait Promise.all([\n\t\tassertStreamReadError(t, stream, cause),\n\t\tassertStreamOutput(t, secondStream),\n\t]);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('Can error both .duplex() on same file descriptor', async t => {\n\tconst subprocess = execa('stdin.js');\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.duplex();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.destroy(cause);\n\n\tawait Promise.all([\n\t\tassertStreamReadError(t, stream, cause),\n\t\tassertStreamReadError(t, secondStream, cause),\n\t]);\n\tawait assertSubprocessError(t, subprocess, {cause});\n});\n\ntest('Can error one of two .duplex() on different file descriptors', async t => {\n\tconst subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.end(foobarString);\n\n\tconst [error] = await Promise.all([\n\t\tassertStreamReadError(t, secondStream, {cause}),\n\t\tassertStreamReadError(t, stream, cause),\n\t]);\n\tt.is(error.stderr, foobarString);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('Can error both .duplex() on different file descriptors', async t => {\n\tconst subprocess = execa('stdin-twice-both.js', ['3'], fullReadableStdio());\n\tconst stream = subprocess.duplex();\n\tconst secondStream = subprocess.duplex({from: 'stderr', to: 'fd3'});\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\tsecondStream.destroy(cause);\n\n\tawait Promise.all([\n\t\tassertStreamReadError(t, stream, cause),\n\t\tassertStreamReadError(t, secondStream, cause),\n\t]);\n\tawait assertSubprocessError(t, subprocess, {cause});\n});\n"
  },
  {
    "path": "test/convert/duplex.js",
    "content": "import {\n\tcompose,\n\tReadable,\n\tWritable,\n\tPassThrough,\n} from 'node:stream';\nimport {pipeline} from 'node:stream/promises';\nimport {text} from 'node:stream/consumers';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tfinishedStream,\n\tassertReadableAborted,\n\tassertWritableAborted,\n\tassertProcessNormalExit,\n\tassertStreamOutput,\n\tassertStreamError,\n\tassertStreamReadError,\n\tassertSubprocessOutput,\n\tassertSubprocessError,\n\tassertPromiseError,\n\tgetReadWriteSubprocess,\n} from '../helpers/convert.js';\nimport {foobarString} from '../helpers/input.js';\nimport {majorNodeVersion} from '../helpers/node-version.js';\nimport {prematureClose, fullStdio, fullReadableStdio} from '../helpers/stdio.js';\nimport {defaultHighWaterMark} from '../helpers/stream.js';\n\nsetFixtureDirectory();\n\ntest('.duplex() success', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\n\tt.true(stream instanceof Writable);\n\tt.true(stream.writable);\n\tt.true(stream instanceof Readable);\n\tt.true(stream.readable);\n\n\tstream.end(foobarString);\n\n\tawait assertStreamOutput(t, stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\n// eslint-disable-next-line max-params\nconst testReadableDuplexDefault = async (t, fdNumber, from, options, hasResult) => {\n\tconst subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], options);\n\tconst stream = subprocess.duplex({from});\n\tstream.end(foobarString);\n\n\tawait assertStreamOutput(t, stream, hasResult ? foobarString : '');\n\tawait assertSubprocessOutput(t, subprocess, foobarString, fdNumber);\n};\n\ntest('.duplex() can use stdout', testReadableDuplexDefault, 1, 'stdout', {}, true);\ntest('.duplex() can use stderr', testReadableDuplexDefault, 2, 'stderr', {}, true);\ntest('.duplex() can use output stdio[*]', testReadableDuplexDefault, 3, 'fd3', fullStdio, true);\ntest('.duplex() uses stdout by default', testReadableDuplexDefault, 1, undefined, {}, true);\ntest('.duplex() does not use stderr by default', testReadableDuplexDefault, 2, undefined, {}, false);\ntest('.duplex() does not use stdio[*] by default', testReadableDuplexDefault, 3, undefined, fullStdio, false);\ntest('.duplex() uses stdout even if stderr is \"ignore\"', testReadableDuplexDefault, 1, 'stdout', {stderr: 'ignore'}, true);\ntest('.duplex() uses stderr even if stdout is \"ignore\"', testReadableDuplexDefault, 2, 'stderr', {stdout: 'ignore'}, true);\ntest('.duplex() uses stdout if \"all\" is used', testReadableDuplexDefault, 1, 'all', {all: true}, true);\ntest('.duplex() uses stderr if \"all\" is used', testReadableDuplexDefault, 2, 'all', {all: true}, true);\n\nconst testWritableDuplexDefault = async (t, fdNumber, to, options) => {\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);\n\tconst stream = subprocess.duplex({to});\n\n\tstream.end(foobarString);\n\n\tawait assertStreamOutput(t, stream, foobarString);\n\tawait assertSubprocessOutput(t, subprocess);\n};\n\ntest('.duplex() can use stdin', testWritableDuplexDefault, 0, 'stdin', {});\ntest('.duplex() can use input stdio[*]', testWritableDuplexDefault, 3, 'fd3', fullReadableStdio());\ntest('.duplex() uses stdin by default', testWritableDuplexDefault, 0, undefined, {});\n\ntest('.duplex() abort -> subprocess fail', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\tconst textPromise = text(stream);\n\n\tstream.destroy();\n\n\tconst error = await t.throwsAsync(textPromise);\n\tt.like(error, prematureClose);\n\tassertProcessNormalExit(t, error);\n\tassertWritableAborted(t, subprocess.stdin);\n\tassertReadableAborted(t, subprocess.stdout);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.duplex() error -> subprocess fail', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tconst error = await assertStreamError(t, stream, {cause});\n\tassertProcessNormalExit(t, error);\n\tt.is(subprocess.stdin.errored, cause);\n\tt.is(subprocess.stdout.errored, cause);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.duplex() can be used with Stream.pipeline()', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.duplex();\n\tconst outputStream = new PassThrough();\n\n\tawait pipeline(inputStream, stream, outputStream);\n\n\tawait finishedStream(inputStream);\n\tawait finishedStream(stream);\n\tawait assertStreamOutput(t, outputStream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('.duplex() can error with Stream.pipeline()', async t => {\n\tconst subprocess = execa('stdin-fail.js');\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.duplex();\n\tconst outputStream = new PassThrough();\n\n\tconst error = await t.throwsAsync(pipeline(inputStream, stream, outputStream));\n\tassertProcessNormalExit(t, error, 2);\n\tt.like(error, {stdout: foobarString});\n\n\tawait finishedStream(inputStream);\n\tawait assertStreamError(t, stream, error);\n\tawait assertStreamReadError(t, outputStream, error);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.duplex() can pipe to errored stream with Stream.pipeline()', async t => {\n\tconst subprocess = execa('stdin-fail.js');\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.duplex();\n\tconst outputStream = new PassThrough();\n\n\tconst cause = new Error('test');\n\toutputStream.destroy(cause);\n\n\t// Node 23 does not allow calling `stream.pipeline()` with an already errored stream\n\tif (majorNodeVersion >= 23) {\n\t\toutputStream.on('error', () => {});\n\t\tstream.on('error', () => {});\n\t\tawait t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});\n\t\tstream.end();\n\t} else {\n\t\tawait assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);\n\t\tawait t.throwsAsync(finishedStream(stream));\n\n\t\tawait assertStreamError(t, inputStream, cause);\n\t\tconst error = await assertStreamError(t, stream, cause);\n\t\tawait assertStreamReadError(t, outputStream, cause);\n\t\tawait assertSubprocessError(t, subprocess, {cause: error});\n\t}\n});\n\ntest('.duplex() can be piped to errored stream with Stream.pipeline()', async t => {\n\tconst subprocess = execa('stdin-fail.js');\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.duplex();\n\tconst outputStream = new PassThrough();\n\n\tconst cause = new Error('test');\n\tinputStream.destroy(cause);\n\n\tawait assertPromiseError(t, pipeline(inputStream, stream, outputStream), cause);\n\tawait t.throwsAsync(finishedStream(stream));\n\n\tawait assertStreamError(t, inputStream, cause);\n\tconst error = await assertStreamError(t, stream, cause);\n\tawait assertStreamReadError(t, outputStream, cause);\n\tawait assertSubprocessError(t, subprocess, {cause: error});\n});\n\ntest('.duplex() can be used with Stream.compose()', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.duplex();\n\tconst outputStream = new PassThrough();\n\n\tawait assertStreamOutput(t, compose(inputStream, stream, outputStream));\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('.duplex() has the right highWaterMark', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\tt.is(stream.readableHighWaterMark, defaultHighWaterMark);\n\tt.is(stream.writableHighWaterMark, defaultHighWaterMark);\n\tstream.end();\n\tawait text(stream);\n});\n"
  },
  {
    "path": "test/convert/iterable.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {fullStdio, assertEpipe} from '../helpers/stdio.js';\nimport {\n\tarrayFromAsync,\n\tassertWritableAborted,\n\tassertReadableAborted,\n\tassertProcessNormalExit,\n} from '../helpers/convert.js';\nimport {simpleFull, noNewlinesChunks} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\nconst partialArrayFromAsync = async (asyncIterable, lines = []) => {\n\t// eslint-disable-next-line no-unreachable-loop\n\tfor await (const line of asyncIterable) {\n\t\tlines.push(line);\n\t\tbreak;\n\t}\n\n\treturn lines;\n};\n\nconst errorArrayFromAsync = async (t, cause, asyncIterable, lines = []) => {\n\tconst {value} = await asyncIterable.next();\n\tlines.push(value);\n\tawait asyncIterable.throw(cause);\n};\n\nconst throwsAsync = async (t, asyncIterable, arrayFromAsyncMethod) => {\n\tconst lines = [];\n\tconst error = await t.throwsAsync(arrayFromAsyncMethod(asyncIterable, lines));\n\treturn {error, lines};\n};\n\nconst assertStdoutAbort = (t, subprocess, error, cause) => {\n\tassertProcessNormalExit(t, error, 1);\n\tassertEpipe(t, error.stderr);\n\tassertWritableAborted(t, subprocess.stdin);\n\tt.true(subprocess.stderr.readableEnded);\n\n\tif (cause === undefined) {\n\t\tassertReadableAborted(t, subprocess.stdout);\n\t} else {\n\t\tt.is(subprocess.stdout.errored, cause);\n\t}\n};\n\nconst testSuccess = async (t, fdNumber, from, options = {}) => {\n\tconst lines = await arrayFromAsync(execa('noop-fd.js', [`${fdNumber}`, simpleFull], options).iterable({from}));\n\tt.deepEqual(lines, noNewlinesChunks);\n};\n\ntest('Uses stdout by default', testSuccess, 1, undefined);\ntest('Can iterate successfully on stdout', testSuccess, 1, 'stdout');\ntest('Can iterate successfully on stderr', testSuccess, 2, 'stderr');\ntest('Can iterate successfully on stdio[*]', testSuccess, 3, 'fd3', fullStdio);\n\ntest('Can iterate successfully on all', async t => {\n\tconst lines = await arrayFromAsync(execa('noop-both.js', [simpleFull], {all: true}).iterable({from: 'all'}));\n\tt.deepEqual(lines, [...noNewlinesChunks, ...noNewlinesChunks]);\n});\n\ntest('Can iterate using Symbol.asyncIterator', async t => {\n\tconst lines = await arrayFromAsync(execa('noop-fd.js', ['1', simpleFull]));\n\tt.deepEqual(lines, noNewlinesChunks);\n});\n\nconst assertMultipleCalls = async (t, iterable, iterableTwo) => {\n\tt.not(iterable, iterableTwo);\n\tconst lines = await arrayFromAsync(iterable);\n\tconst linesTwo = await arrayFromAsync(iterableTwo);\n\tt.deepEqual(lines, linesTwo);\n\tt.deepEqual(lines, noNewlinesChunks);\n};\n\ntest('Can be called multiple times', async t => {\n\tconst subprocess = execa('noop-fd.js', ['1', simpleFull]);\n\tconst iterable = subprocess.iterable();\n\tconst iterableTwo = subprocess.iterable();\n\tawait assertMultipleCalls(t, iterable, iterableTwo);\n});\n\ntest('Can be called on different file descriptors', async t => {\n\tconst subprocess = execa('noop-both.js', [simpleFull]);\n\tconst iterable = subprocess.iterable();\n\tconst iterableTwo = subprocess.iterable({from: 'stderr'});\n\tawait assertMultipleCalls(t, iterable, iterableTwo);\n});\n\ntest('Wait for the subprocess exit', async t => {\n\tconst subprocess = execa('noop-delay.js', ['1', simpleFull]);\n\tconst linesPromise = arrayFromAsync(subprocess);\n\tt.is(await Promise.race([linesPromise, subprocess]), await subprocess);\n\tt.deepEqual(await linesPromise, noNewlinesChunks);\n});\n\ntest('Wait for the subprocess exit on iterator.return()', async t => {\n\tconst subprocess = execa('noop-delay.js', ['1', simpleFull]);\n\tconst linesPromise = partialArrayFromAsync(subprocess);\n\tt.is(await Promise.race([linesPromise, subprocess]), await subprocess);\n\tt.deepEqual(await linesPromise, [noNewlinesChunks[0]]);\n});\n\ntest('Wait for the subprocess exit on iterator.throw()', async t => {\n\tconst subprocess = execa('noop-delay.js', ['1', simpleFull]);\n\tconst cause = new Error(foobarString);\n\tconst lines = [];\n\tconst linesPromise = t.throwsAsync(errorArrayFromAsync(t, cause, subprocess.iterable(), lines));\n\tt.is(await Promise.race([linesPromise, subprocess]), await subprocess);\n\tt.deepEqual(lines, [noNewlinesChunks[0]]);\n});\n\ntest('Abort stdout on iterator.return()', async t => {\n\tconst subprocess = execa('noop-repeat.js', ['1', simpleFull]);\n\tconst {error, lines} = await throwsAsync(t, subprocess, partialArrayFromAsync);\n\tt.deepEqual(lines, [noNewlinesChunks[0]]);\n\tassertStdoutAbort(t, subprocess, error);\n\tt.is(error, await t.throwsAsync(subprocess));\n});\n\ntest('Abort stdout on iterator.throw()', async t => {\n\tconst subprocess = execa('noop-repeat.js', ['1', simpleFull]);\n\tconst cause = new Error(foobarString);\n\tconst {error, lines} = await throwsAsync(t, subprocess.iterable(), errorArrayFromAsync.bind(undefined, t, cause));\n\tt.deepEqual(lines, [noNewlinesChunks[0]]);\n\tassertStdoutAbort(t, subprocess, error);\n\tt.is(error, await t.throwsAsync(subprocess));\n});\n\ntest('Propagate subprocess failure', async t => {\n\tconst subprocess = execa('noop-fail.js', ['1', simpleFull]);\n\tconst {error, lines} = await throwsAsync(t, subprocess, arrayFromAsync);\n\tt.is(error, await t.throwsAsync(subprocess));\n\tt.deepEqual(lines, noNewlinesChunks);\n});\n\nconst testStdoutError = async (t, destroyStdout, isAbort, cause) => {\n\tconst subprocess = execa('noop-repeat.js', ['1', simpleFull]);\n\tsubprocess.stdout.once('data', () => {\n\t\tdestroyStdout(subprocess.stdout, cause);\n\t});\n\n\tconst {error} = await throwsAsync(t, subprocess, arrayFromAsync);\n\tt.is(error.cause, cause);\n\tassertStdoutAbort(t, subprocess, error, isAbort ? undefined : cause);\n\tt.is(error, await t.throwsAsync(subprocess));\n};\n\ntest('Propagate stdout abort', testStdoutError, subprocessStdout => subprocessStdout.destroy(), true);\ntest('Propagate stdout error', testStdoutError, (subprocessStdout, cause) => subprocessStdout.destroy(cause), false, new Error(foobarString));\ntest('Propagate stdout \"error\" event', testStdoutError, (subprocessStdout, cause) => subprocessStdout.emit('error', cause), true, new Error(foobarString));\n"
  },
  {
    "path": "test/convert/readable.js",
    "content": "import {once} from 'node:events';\nimport {\n\tcompose,\n\tReadable,\n\tWritable,\n\tPassThrough,\n} from 'node:stream';\nimport {pipeline} from 'node:stream/promises';\nimport {text} from 'node:stream/consumers';\nimport {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tfinishedStream,\n\tassertReadableAborted,\n\tassertWritableAborted,\n\tassertProcessNormalExit,\n\tassertStreamOutput,\n\tassertStreamChunks,\n\tassertStreamError,\n\tassertStreamReadError,\n\tassertSubprocessOutput,\n\tassertSubprocessError,\n\tassertPromiseError,\n\tgetReadableSubprocess,\n\tgetReadWriteSubprocess,\n} from '../helpers/convert.js';\nimport {foobarString, foobarBuffer, foobarObject} from '../helpers/input.js';\nimport {simpleFull} from '../helpers/lines.js';\nimport {majorNodeVersion} from '../helpers/node-version.js';\nimport {prematureClose, fullStdio} from '../helpers/stdio.js';\nimport {outputObjectGenerator, getOutputsAsyncGenerator} from '../helpers/generator.js';\nimport {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';\n\nsetFixtureDirectory();\n\ntest('.readable() success', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\n\tt.false(stream instanceof Writable);\n\tt.is(stream.writable, undefined);\n\tt.true(stream instanceof Readable);\n\tt.true(stream.readable);\n\n\tawait assertStreamOutput(t, stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\n// eslint-disable-next-line max-params\nconst testReadableDefault = async (t, fdNumber, from, options, hasResult) => {\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], options);\n\tconst stream = subprocess.readable({from});\n\n\tawait assertStreamOutput(t, stream, hasResult ? foobarString : '');\n\tawait assertSubprocessOutput(t, subprocess, foobarString, fdNumber);\n};\n\ntest('.readable() can use stdout', testReadableDefault, 1, 'stdout', {}, true);\ntest('.readable() can use stderr', testReadableDefault, 2, 'stderr', {}, true);\ntest('.readable() can use stdio[*]', testReadableDefault, 3, 'fd3', fullStdio, true);\ntest('.readable() uses stdout by default', testReadableDefault, 1, undefined, {}, true);\ntest('.readable() does not use stderr by default', testReadableDefault, 2, undefined, {}, false);\ntest('.readable() does not use stdio[*] by default', testReadableDefault, 3, undefined, fullStdio, false);\ntest('.readable() uses stdout even if stderr is \"ignore\"', testReadableDefault, 1, 'stdout', {stderr: 'ignore'}, true);\ntest('.readable() uses stderr even if stdout is \"ignore\"', testReadableDefault, 2, 'stderr', {stdout: 'ignore'}, true);\ntest('.readable() uses stdout if \"all\" is used', testReadableDefault, 1, 'all', {all: true}, true);\ntest('.readable() uses stderr if \"all\" is used', testReadableDefault, 2, 'all', {all: true}, true);\n\nconst testBuffering = async (t, methodName) => {\n\tconst subprocess = execa('noop-stdin-fd.js', ['1'], {buffer: false});\n\tconst stream = subprocess[methodName]();\n\n\tsubprocess.stdin.write(foobarString);\n\tawait once(subprocess.stdout, 'readable');\n\tsubprocess.stdin.end();\n\n\tawait assertStreamOutput(t, stream);\n};\n\ntest('.readable() buffers until read', testBuffering, 'readable');\ntest('.duplex() buffers until read', testBuffering, 'duplex');\n\ntest('.readable() abort -> subprocess fail', async t => {\n\tconst subprocess = execa('noop-repeat.js');\n\tconst stream = subprocess.readable();\n\n\tstream.destroy();\n\n\tconst error = await t.throwsAsync(text(stream));\n\tassertProcessNormalExit(t, error, 1);\n\tt.true(error.message.includes('EPIPE'));\n\tassertWritableAborted(t, subprocess.stdin);\n\tassertReadableAborted(t, subprocess.stdout);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.readable() error -> subprocess fail', async t => {\n\tconst subprocess = execa('noop-repeat.js');\n\tconst stream = subprocess.readable();\n\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tconst error = await assertStreamReadError(t, stream, {cause});\n\tassertProcessNormalExit(t, error, 1);\n\tt.true(error.message.includes('EPIPE'));\n\tassertWritableAborted(t, subprocess.stdin);\n\tt.is(subprocess.stdout.errored, cause);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\nconst testStdoutAbort = async (t, methodName) => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\tconst stream = subprocess[methodName]();\n\n\tsubprocess.stdout.destroy();\n\n\tawait subprocess.sendMessage(foobarString);\n\tconst [error, message] = await Promise.all([\n\t\tt.throwsAsync(finishedStream(stream)),\n\t\tsubprocess.getOneMessage(),\n\t]);\n\tt.like(error, prematureClose);\n\tt.is(message, foobarString);\n\tassertWritableAborted(t, subprocess.stdin);\n\tassertReadableAborted(t, subprocess.stdout);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessOutput(t, subprocess, '');\n};\n\ntest('subprocess.stdout abort + no more writes -> .readable() error + subprocess success', testStdoutAbort, 'readable');\ntest('subprocess.stdout abort + no more writes -> .duplex() error + subprocess success', testStdoutAbort, 'duplex');\n\nconst testStdoutError = async (t, methodName) => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\tconst stream = subprocess[methodName]();\n\n\tconst cause = new Error(foobarString);\n\tsubprocess.stdout.destroy(cause);\n\n\tawait subprocess.sendMessage(foobarString);\n\tconst [error, message] = await Promise.all([\n\t\tt.throwsAsync(finishedStream(stream)),\n\t\tsubprocess.getOneMessage(),\n\t]);\n\tt.is(message, foobarString);\n\tt.is(error.cause, cause);\n\tassertProcessNormalExit(t, error);\n\tt.is(subprocess.stdout.errored, cause);\n\tt.true(subprocess.stderr.readableEnded);\n\tassertWritableAborted(t, subprocess.stdin);\n\n\tawait assertSubprocessError(t, subprocess, error);\n};\n\ntest('subprocess.stdout error + no more writes -> .readable() error + subprocess fail', testStdoutError, 'readable');\ntest('subprocess.stdout error + no more writes -> .duplex() error + subprocess fail', testStdoutError, 'duplex');\n\nconst testStdinAbortWrites = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\n\tsubprocess.stdout.destroy();\n\tsubprocess.stdin.end(foobarString);\n\n\tconst error = await t.throwsAsync(finishedStream(stream));\n\tassertProcessNormalExit(t, error, 1);\n\tt.true(subprocess.stdin.writableEnded);\n\tassertReadableAborted(t, subprocess.stdout);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n};\n\ntest('subprocess.stdout abort + more writes -> .readable() error + subprocess fail', testStdinAbortWrites, 'readable');\ntest('subprocess.stdout abort + more writes -> .duplex() error + subprocess fail', testStdinAbortWrites, 'duplex');\n\nconst testStdinErrorWrites = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\n\tconst cause = new Error(foobarString);\n\tsubprocess.stdout.destroy(cause);\n\tsubprocess.stdin.end(foobarString);\n\n\tconst error = await assertStreamError(t, stream, {cause});\n\tassertProcessNormalExit(t, error, 1);\n\tt.true(subprocess.stdin.writableEnded);\n\tt.is(subprocess.stdout.errored, cause);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n};\n\ntest('subprocess.stdout error + more writes -> .readable() error + subprocess fail', testStdinErrorWrites, 'readable');\ntest('subprocess.stdout error + more writes -> .duplex() error + subprocess fail', testStdinErrorWrites, 'duplex');\n\ntest('.readable() can be used with Stream.pipeline()', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\tconst outputStream = new PassThrough();\n\n\tawait pipeline(stream, outputStream);\n\n\tawait finishedStream(stream);\n\tawait assertStreamOutput(t, outputStream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('.readable() can error with Stream.pipeline()', async t => {\n\tconst subprocess = execa('noop-fail.js', ['1', foobarString]);\n\tconst stream = subprocess.readable();\n\tconst outputStream = new PassThrough();\n\n\tconst error = await t.throwsAsync(pipeline(stream, outputStream));\n\tassertProcessNormalExit(t, error, 2);\n\tt.like(error, {stdout: foobarString});\n\n\tawait assertStreamError(t, stream, error);\n\tawait assertStreamReadError(t, outputStream, error);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.readable() can pipe to errored stream with Stream.pipeline()', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\tconst outputStream = new PassThrough();\n\n\tconst cause = new Error('test');\n\toutputStream.destroy(cause);\n\n\t// Node 23 does not allow calling `stream.pipeline()` with an already errored stream\n\tif (majorNodeVersion >= 23) {\n\t\toutputStream.on('error', () => {});\n\t\tawait t.throwsAsync(pipeline(stream, outputStream), {code: 'ERR_STREAM_UNABLE_TO_PIPE'});\n\t} else {\n\t\tawait assertPromiseError(t, pipeline(stream, outputStream), cause);\n\t\tawait t.throwsAsync(finishedStream(stream));\n\n\t\tconst error = await assertStreamError(t, stream, cause);\n\t\tawait assertStreamReadError(t, outputStream, cause);\n\t\tawait assertSubprocessError(t, subprocess, {cause: error});\n\t}\n});\n\ntest('.readable() can be used with Stream.compose()', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\tconst outputStream = new PassThrough();\n\n\tawait assertStreamOutput(t, compose(stream, outputStream));\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('.readable() works with objectMode', async t => {\n\tconst subprocess = execa('noop.js', {stdout: outputObjectGenerator()});\n\tconst stream = subprocess.readable();\n\tt.true(stream.readableObjectMode);\n\tt.is(stream.readableHighWaterMark, defaultObjectHighWaterMark);\n\n\tawait assertStreamChunks(t, stream, [foobarObject]);\n\tawait assertSubprocessOutput(t, subprocess, [foobarObject]);\n});\n\ntest('.duplex() works with objectMode and reads', async t => {\n\tconst subprocess = getReadWriteSubprocess({stdout: outputObjectGenerator()});\n\tconst stream = subprocess.duplex();\n\tt.true(stream.readableObjectMode);\n\tt.is(stream.readableHighWaterMark, defaultObjectHighWaterMark);\n\tt.false(stream.writableObjectMode);\n\tt.is(stream.writableHighWaterMark, defaultHighWaterMark);\n\tstream.end(foobarString);\n\n\tawait assertStreamChunks(t, stream, [foobarObject]);\n\tawait assertSubprocessOutput(t, subprocess, [foobarObject]);\n});\n\ntest('.readable() works with default encoding', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\tt.is(stream.readableEncoding, null);\n\n\tawait assertStreamChunks(t, stream, [foobarBuffer]);\n\tawait assertSubprocessOutput(t, subprocess, foobarString);\n});\n\ntest('.duplex() works with default encoding', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\tt.is(stream.readableEncoding, null);\n\tstream.end(foobarString);\n\n\tawait assertStreamChunks(t, stream, [foobarBuffer]);\n\tawait assertSubprocessOutput(t, subprocess, foobarString);\n});\n\ntest('.readable() works with encoding \"utf8\"', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tsubprocess.stdout.setEncoding('utf8');\n\tconst stream = subprocess.readable();\n\tt.is(stream.readableEncoding, 'utf8');\n\n\tawait assertStreamChunks(t, stream, [foobarString]);\n\tawait assertSubprocessOutput(t, subprocess, foobarString);\n});\n\ntest('.duplex() works with encoding \"utf8\"', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tsubprocess.stdout.setEncoding('utf8');\n\tconst stream = subprocess.duplex();\n\tt.is(stream.readableEncoding, 'utf8');\n\tstream.end(foobarBuffer);\n\n\tawait assertStreamChunks(t, stream, [foobarString]);\n\tawait assertSubprocessOutput(t, subprocess, foobarString);\n});\n\ntest('.readable() has the right highWaterMark', async t => {\n\tconst subprocess = execa('noop.js');\n\tconst stream = subprocess.readable();\n\tt.is(stream.readableHighWaterMark, defaultHighWaterMark);\n\tawait text(stream);\n});\n\ntest('.readable() can iterate over lines', async t => {\n\tconst subprocess = execa('noop-fd.js', ['1', simpleFull]);\n\tconst lines = [];\n\tfor await (const line of subprocess.readable({binary: false, preserveNewlines: false})) {\n\t\tlines.push(line);\n\t}\n\n\tconst expectedLines = ['aaa', 'bbb', 'ccc'];\n\tt.deepEqual(lines, expectedLines);\n\tawait assertSubprocessOutput(t, subprocess, simpleFull);\n});\n\ntest('.readable() can wait for data', async t => {\n\tconst subprocess = execa('noop.js', {stdout: getOutputsAsyncGenerator([foobarString, foobarString])(false, true)});\n\tconst stream = subprocess.readable();\n\n\tt.is(stream.read(), null);\n\tawait once(stream, 'readable');\n\tt.is(stream.read().toString(), foobarString);\n\tt.is(stream.read(), null);\n\tawait once(stream, 'readable');\n\tt.is(stream.read().toString(), foobarString);\n\tt.is(stream.read(), null);\n\tawait once(stream, 'readable');\n\tt.is(stream.read(), null);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess, `${foobarString}${foobarString}`);\n});\n\nconst testBufferData = async (t, methodName) => {\n\tconst chunk = '.'.repeat(defaultHighWaterMark).repeat(2);\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\tsubprocess.stdin.end(chunk);\n\n\tawait assertStreamOutput(t, stream, chunk);\n\tawait assertSubprocessOutput(t, subprocess, chunk);\n};\n\ntest('.readable() can buffer data', testBufferData, 'readable');\ntest('.duplex() can buffer data', testBufferData, 'duplex');\n\nconst assertDataEvents = async (t, stream, subprocess) => {\n\tconst [output] = await once(stream, 'data');\n\tt.is(output.toString(), foobarString);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess);\n};\n\ntest('.readable() can be read with \"data\" events', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\n\tawait assertDataEvents(t, stream, subprocess);\n});\n\ntest('.duplex() can be read with \"data\" events', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\tstream.end(foobarString);\n\n\tawait assertDataEvents(t, stream, subprocess);\n});\n\nconst assertPause = async (t, stream, subprocess) => {\n\tconst onceData = once(stream, 'data');\n\tstream.pause();\n\n\tt.is(stream.readableLength, 0);\n\tdo {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait setTimeout(10);\n\t} while (stream.readableLength === 0);\n\n\tt.false(await Promise.race([onceData, false]));\n\n\tstream.resume();\n\tconst [output] = await onceData;\n\tt.is(output.toString(), foobarString);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess);\n};\n\ntest('.readable() can be paused', async t => {\n\tconst subprocess = getReadableSubprocess();\n\tconst stream = subprocess.readable();\n\n\tawait assertPause(t, stream, subprocess);\n});\n\ntest('.duplex() can be paused', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\tstream.end(foobarString);\n\n\tawait assertPause(t, stream, subprocess);\n});\n\n// This feature does not work on Node 18.\n// @todo: remove after dropping support for Node 18.\nif (majorNodeVersion >= 20) {\n\tconst testHighWaterMark = async (t, methodName) => {\n\t\tconst subprocess = execa('stdin.js');\n\t\tconst stream = subprocess[methodName]();\n\n\t\tlet count = 0;\n\t\tconst onPause = once(subprocess.stdout, 'pause');\n\t\tfor (; !subprocess.stdout.isPaused(); count += 1) {\n\t\t\tsubprocess.stdin.write('.');\n\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\tawait Promise.race([onPause, once(subprocess.stdout, 'data')]);\n\t\t}\n\n\t\tconst expectedCount = defaultObjectHighWaterMark + 1;\n\t\tconst expectedOutput = '.'.repeat(expectedCount);\n\t\tt.is(count, expectedCount);\n\t\tsubprocess.stdin.end();\n\t\tawait assertStreamOutput(t, stream, expectedOutput);\n\t\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n\t};\n\n\ttest('.readable() pauses its buffering when too high', testHighWaterMark, 'readable');\n\ttest('.duplex() pauses its buffering when too high', testHighWaterMark, 'duplex');\n}\n\nconst testBigOutput = async (t, methodName) => {\n\tconst bigChunk = '.'.repeat(1e6);\n\tconst subprocess = execa('stdin.js', {input: bigChunk});\n\tconst stream = subprocess[methodName]();\n\n\tawait assertStreamOutput(t, stream, bigChunk);\n\tawait assertSubprocessOutput(t, subprocess, bigChunk);\n};\n\ntest('.readable() with big output', testBigOutput, 'readable');\ntest('.duplex() with big output', testBigOutput, 'duplex');\n"
  },
  {
    "path": "test/convert/shared.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tfinishedStream,\n\tassertWritableAborted,\n\tassertStreamError,\n\tassertSubprocessError,\n\tgetReadWriteSubprocess,\n} from '../helpers/convert.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testSubprocessFail = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\n\tconst cause = new Error(foobarString);\n\tsubprocess.kill(cause);\n\n\tconst error = await assertStreamError(t, stream, {cause});\n\tassertWritableAborted(t, subprocess.stdin);\n\tt.true(subprocess.stdout.readableEnded);\n\tt.true(subprocess.stderr.readableEnded);\n\n\tawait assertSubprocessError(t, subprocess, error);\n};\n\ntest('subprocess fail -> .readable() error', testSubprocessFail, 'readable');\ntest('subprocess fail -> .writable() error', testSubprocessFail, 'writable');\ntest('subprocess fail -> .duplex() error', testSubprocessFail, 'duplex');\n\nconst testErrorEvent = async (t, methodName) => {\n\tconst subprocess = execa('empty.js');\n\tconst stream = subprocess[methodName]();\n\tt.is(stream.listenerCount('error'), 0);\n\tstream.destroy();\n\tawait t.throwsAsync(finishedStream(stream));\n};\n\ntest('.readable() requires listening to \"error\" event', testErrorEvent, 'readable');\ntest('.writable() requires listening to \"error\" event', testErrorEvent, 'writable');\ntest('.duplex() requires listening to \"error\" event', testErrorEvent, 'duplex');\n\nconst testSubprocessError = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\tconst cause = new Error(foobarString);\n\tsubprocess.kill(cause);\n\tawait assertStreamError(t, stream, {cause});\n};\n\ntest('Do not need to await subprocess with .readable()', testSubprocessError, 'readable');\ntest('Do not need to await subprocess with .writable()', testSubprocessError, 'writable');\ntest('Do not need to await subprocess with .duplex()', testSubprocessError, 'duplex');\n"
  },
  {
    "path": "test/convert/writable.js",
    "content": "import {once} from 'node:events';\nimport {compose, Readable, Writable} from 'node:stream';\nimport {pipeline} from 'node:stream/promises';\nimport {text} from 'node:stream/consumers';\nimport {setTimeout, scheduler} from 'node:timers/promises';\nimport {promisify} from 'node:util';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tfinishedStream,\n\tassertWritableAborted,\n\tassertProcessNormalExit,\n\tassertStreamOutput,\n\tassertStreamError,\n\tassertSubprocessOutput,\n\tassertSubprocessError,\n\tassertPromiseError,\n\tgetWritableSubprocess,\n\tgetReadableSubprocess,\n\tgetReadWriteSubprocess,\n} from '../helpers/convert.js';\nimport {\n\tfoobarString,\n\tfoobarBuffer,\n\tfoobarObject,\n\tfoobarObjectString,\n} from '../helpers/input.js';\nimport {prematureClose, fullReadableStdio} from '../helpers/stdio.js';\nimport {\n\tthrowingGenerator,\n\tserializeGenerator,\n\tnoopAsyncGenerator,\n} from '../helpers/generator.js';\nimport {defaultHighWaterMark, defaultObjectHighWaterMark} from '../helpers/stream.js';\n\nsetFixtureDirectory();\n\ntest('.writable() success', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst stream = subprocess.writable();\n\n\tt.true(stream instanceof Writable);\n\tt.true(stream.writable);\n\tt.false(stream instanceof Readable);\n\tt.is(stream.readable, undefined);\n\n\tstream.end(foobarString);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess, foobarString, 2);\n});\n\nconst testWritableDefault = async (t, fdNumber, to, options) => {\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], options);\n\tconst stream = subprocess.writable({to});\n\n\tstream.end(foobarString);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess);\n};\n\ntest('.writable() can use stdin', testWritableDefault, 0, 'stdin', {});\ntest('.writable() can use stdio[*]', testWritableDefault, 3, 'fd3', fullReadableStdio());\ntest('.writable() uses stdin by default', testWritableDefault, 0, undefined, {});\n\ntest('.writable() hangs until ended', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.writable();\n\n\tstream.write(foobarString);\n\tawait setTimeout(1e2);\n\tstream.end();\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('.duplex() hangs until ended', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\n\tstream.write(foobarString);\n\tawait setTimeout(1e2);\n\tstream.end();\n\n\tawait assertStreamOutput(t, stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\nconst testEarlySuccess = async (t, methodName, hasWrites) => {\n\tconst subprocess = hasWrites ? getReadableSubprocess() : execa('empty.js');\n\tconst stream = subprocess[methodName]();\n\n\tconst error = await t.throwsAsync(finishedStream(stream));\n\tt.like(error, prematureClose);\n\tassertWritableAborted(t, subprocess.stdin);\n\tt.true(subprocess.stdout.readableEnded);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessOutput(t, subprocess, hasWrites ? foobarString : '');\n};\n\ntest('subprocess early success with no writes -> .writable() abort', testEarlySuccess, 'writable', false);\ntest('subprocess early success with no writes -> .duplex() abort', testEarlySuccess, 'duplex', false);\ntest('subprocess early success with writes -> .writable() abort', testEarlySuccess, 'writable', true);\ntest('subprocess early success with writes -> .duplex() abort', testEarlySuccess, 'duplex', true);\n\ntest('.writable() abort -> subprocess fail', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst stream = subprocess.writable();\n\n\tstream.destroy();\n\n\tconst error = await t.throwsAsync(finishedStream(stream));\n\tt.like(error, prematureClose);\n\tassertProcessNormalExit(t, error);\n\tassertWritableAborted(t, subprocess.stdin);\n\tt.true(subprocess.stdout.readableEnded);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.writable() error -> subprocess fail', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst stream = subprocess.writable();\n\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tconst error = await assertStreamError(t, stream, {cause});\n\tassertProcessNormalExit(t, error);\n\tt.is(subprocess.stdin.errored, cause);\n\tt.true(subprocess.stdout.readableEnded);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.writable() EPIPE error -> subprocess success', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst stream = subprocess.writable();\n\n\tconst error = new Error(foobarString);\n\terror.code = 'EPIPE';\n\tstream.destroy(error);\n\n\tawait assertStreamError(t, stream, error);\n\tt.is(subprocess.stdin.errored, error);\n\tt.true(subprocess.stdout.readableEnded);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait subprocess;\n});\n\ntest('subprocess.stdin end -> .writable() end + subprocess success', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.writable();\n\n\tsubprocess.stdin.end(foobarString);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('subprocess.stdin end -> .duplex() end + subprocess success', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\n\tsubprocess.stdin.end(foobarString);\n\n\tawait assertStreamOutput(t, stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\nconst testStdinAbort = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\n\tsubprocess.stdin.destroy();\n\n\tconst error = await t.throwsAsync(finishedStream(stream));\n\tt.like(error, prematureClose);\n\tassertProcessNormalExit(t, error);\n\tassertWritableAborted(t, subprocess.stdin);\n\tt.true(subprocess.stdout.readableEnded);\n\tt.true(subprocess.stderr.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n};\n\ntest('subprocess.stdin abort -> .writable() error + subprocess fail', testStdinAbort, 'writable');\ntest('subprocess.stdin abort -> .duplex() error + subprocess fail', testStdinAbort, 'duplex');\n\nconst testStdinError = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]();\n\n\tconst cause = new Error(foobarString);\n\tsubprocess.stdin.destroy(cause);\n\n\tconst error = await assertStreamError(t, stream, {cause});\n\tassertProcessNormalExit(t, error);\n\tt.is(subprocess.stdin.errored, cause);\n\tt.true(subprocess.stderr.readableEnded);\n\tt.true(subprocess.stdout.readableEnded);\n\tawait assertSubprocessError(t, subprocess, error);\n};\n\ntest('subprocess.stdin error -> .writable() error + subprocess fail', testStdinError, 'writable');\ntest('subprocess.stdin error -> .duplex() error + subprocess fail', testStdinError, 'duplex');\n\ntest('.writable() can be used with Stream.pipeline()', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.writable();\n\n\tawait pipeline(inputStream, stream);\n\n\tawait finishedStream(inputStream);\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess, foobarString, 2);\n});\n\ntest('.writable() can error with Stream.pipeline()', async t => {\n\tconst subprocess = execa('noop-stdin-fail.js', ['2']);\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.writable();\n\n\tconst error = await t.throwsAsync(pipeline(inputStream, stream));\n\tassertProcessNormalExit(t, error, 2);\n\tt.is(error.stderr, foobarString);\n\n\tawait finishedStream(inputStream);\n\tawait assertStreamError(t, stream, error);\n\tawait assertSubprocessError(t, subprocess, error);\n});\n\ntest('.writable() can pipe to errored stream with Stream.pipeline()', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.writable();\n\n\tconst cause = new Error('test');\n\tinputStream.destroy(cause);\n\n\tawait assertPromiseError(t, pipeline(inputStream, stream), cause);\n\tawait t.throwsAsync(finishedStream(stream));\n\n\tawait assertStreamError(t, inputStream, cause);\n\tconst error = await assertStreamError(t, stream, cause);\n\tawait assertSubprocessError(t, subprocess, {cause: error});\n});\n\ntest('.writable() can be used with Stream.compose()', async t => {\n\tconst subprocess = getWritableSubprocess();\n\tconst inputStream = Readable.from([foobarString]);\n\tconst stream = subprocess.writable();\n\n\tawait finishedStream(compose(inputStream, stream));\n\tawait assertSubprocessOutput(t, subprocess, foobarString, 2);\n});\n\ntest('.writable() works with objectMode', async t => {\n\tconst subprocess = getReadWriteSubprocess({stdin: serializeGenerator(true, true)});\n\tconst stream = subprocess.writable();\n\tt.true(stream.writableObjectMode);\n\tt.is(stream.writableHighWaterMark, defaultObjectHighWaterMark);\n\tstream.end(foobarObject);\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess, foobarObjectString);\n});\n\ntest('.duplex() works with objectMode and writes', async t => {\n\tconst subprocess = getReadWriteSubprocess({stdin: serializeGenerator(true, true)});\n\tconst stream = subprocess.duplex();\n\tt.false(stream.readableObjectMode);\n\tt.is(stream.readableHighWaterMark, defaultHighWaterMark);\n\tt.true(stream.writableObjectMode);\n\tt.is(stream.writableHighWaterMark, defaultObjectHighWaterMark);\n\tstream.end(foobarObject);\n\n\tawait assertStreamOutput(t, stream, foobarObjectString);\n\tawait assertSubprocessOutput(t, subprocess, foobarObjectString);\n});\n\ntest('.writable() has the right highWaterMark', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.writable();\n\tt.is(stream.writableHighWaterMark, defaultHighWaterMark);\n\tstream.end();\n\tawait finishedStream(stream);\n});\n\nconst writeUntilFull = async (t, stream, subprocess) => {\n\tconst size = stream.writableHighWaterMark / 2;\n\tconst chunk = '.'.repeat(size);\n\n\tt.is(subprocess.stdin.writableLength, 0);\n\tt.is(stream.writableLength, 0);\n\tt.false(subprocess.stdin.writableNeedDrain);\n\tt.false(stream.writableNeedDrain);\n\n\tt.true(stream.write(chunk));\n\tt.is(subprocess.stdin.writableLength, size);\n\tt.is(stream.writableLength, 0);\n\tt.false(subprocess.stdin.writableNeedDrain);\n\tt.false(stream.writableNeedDrain);\n\n\tt.true(stream.write(chunk));\n\tt.is(subprocess.stdin.writableLength, size * 2);\n\tt.is(stream.writableLength, size);\n\tt.true(subprocess.stdin.writableNeedDrain);\n\tt.false(stream.writableNeedDrain);\n\n\tt.false(stream.write(chunk));\n\tt.is(subprocess.stdin.writableLength, size * 2);\n\tt.is(stream.writableLength, size * 2);\n\tt.true(subprocess.stdin.writableNeedDrain);\n\tt.true(stream.writableNeedDrain);\n\n\tawait once(stream, 'drain');\n\tstream.end();\n\n\treturn '.'.repeat(size * 3);\n};\n\ntest('.writable() waits when its buffer is full', async t => {\n\tconst subprocess = getReadWriteSubprocess({stdin: noopAsyncGenerator(false, true)});\n\tconst stream = subprocess.writable();\n\n\tconst expectedOutput = await writeUntilFull(t, stream, subprocess);\n\n\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n});\n\ntest('.duplex() waits when its buffer is full', async t => {\n\tconst subprocess = getReadWriteSubprocess({stdin: noopAsyncGenerator(false, true)});\n\tconst stream = subprocess.duplex();\n\n\tconst expectedOutput = await writeUntilFull(t, stream, subprocess);\n\n\tawait assertStreamOutput(t, stream, expectedOutput);\n\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n});\n\nconst testPropagateError = async (t, methodName) => {\n\tconst cause = new Error(foobarString);\n\tconst subprocess = getReadWriteSubprocess({stdin: throwingGenerator(cause)()});\n\tconst stream = subprocess[methodName]();\n\tstream.end('.');\n\tawait assertStreamError(t, stream, {cause});\n};\n\ntest('.writable() propagates write errors', testPropagateError, 'writable');\ntest('.duplex() propagates write errors', testPropagateError, 'duplex');\n\nconst testWritev = async (t, methodName, waitForStream) => {\n\tconst subprocess = getReadWriteSubprocess({stdin: noopAsyncGenerator()});\n\tconst stream = subprocess[methodName]();\n\n\tconst chunk = '.'.repeat(stream.writableHighWaterMark);\n\tstream.write(chunk);\n\tt.true(stream.writableNeedDrain);\n\n\tconst [writeInOneTick] = await Promise.race([\n\t\tPromise.all([true, promisify(stream.write.bind(stream))(chunk)]),\n\t\tPromise.all([false, scheduler.yield()]),\n\t]);\n\tt.true(writeInOneTick);\n\n\tstream.end();\n\tawait waitForStream(stream);\n};\n\ntest('.writable() can use .writev()', testWritev, 'writable', finishedStream);\ntest('.duplex() can use .writev()', testWritev, 'duplex', text);\n\ntest('.writable() can set encoding', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.writable();\n\n\tstream.end(foobarBuffer.toString('hex'), 'hex');\n\n\tawait finishedStream(stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n\ntest('.duplex() can set encoding', async t => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess.duplex();\n\n\tstream.end(foobarBuffer.toString('hex'), 'hex');\n\n\tawait assertStreamOutput(t, stream);\n\tawait assertSubprocessOutput(t, subprocess);\n});\n"
  },
  {
    "path": "test/fixtures/all-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconsole.log('std\\nout');\nconsole.error('std\\nerr');\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/all.js",
    "content": "#!/usr/bin/env node\nconsole.log('std\\nout');\nconsole.error('std\\nerr');\n"
  },
  {
    "path": "test/fixtures/command with space.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconsole.log(process.argv.slice(2).join('\\n'));\n"
  },
  {
    "path": "test/fixtures/delay.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconst delay = Number(process.argv[2]);\nsetTimeout(() => {}, delay);\n"
  },
  {
    "path": "test/fixtures/detach.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {execa} from '../../index.js';\n\nconst subprocess = execa('forever.js', {detached: true});\nconsole.log(subprocess.pid);\nprocess.exit(0);\n"
  },
  {
    "path": "test/fixtures/echo-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\n\nconsole.log('stdout');\nconsole.error('stderr');\ngetWriteStream(3).write('fd3');\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/echo.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconsole.log(process.argv.slice(2).join('\\n'));\n"
  },
  {
    "path": "test/fixtures/empty.js",
    "content": "#!/usr/bin/env node\n"
  },
  {
    "path": "test/fixtures/environment.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconsole.log(process.env.FOO);\nconsole.log(process.env.BAR);\n"
  },
  {
    "path": "test/fixtures/exit.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.exitCode = Number(process.argv[2]);\n"
  },
  {
    "path": "test/fixtures/fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.exitCode = 2;\n"
  },
  {
    "path": "test/fixtures/forever.js",
    "content": "#!/usr/bin/env node\nsetTimeout(() => {}, 1e8);\n"
  },
  {
    "path": "test/fixtures/graceful-disconnect.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {once} from 'node:events';\nimport {getCancelSignal, sendMessage} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst cancelSignal = await getCancelSignal();\nawait onAbortedSignal(cancelSignal);\nawait Promise.all([\n\tonce(process, 'disconnect'),\n\tsendMessage(cancelSignal.reason),\n]);\n"
  },
  {
    "path": "test/fixtures/graceful-echo.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage, getOneMessage} from 'execa';\n\nawait getCancelSignal();\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/graceful-listener.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\n\nconst id = setTimeout(() => {}, 1e8);\nconst cancelSignal = await getCancelSignal();\n// eslint-disable-next-line unicorn/prefer-add-event-listener\ncancelSignal.onabort = async () => {\n\tawait sendMessage(cancelSignal.reason);\n\tclearTimeout(id);\n};\n\nawait sendMessage('.');\n"
  },
  {
    "path": "test/fixtures/graceful-none.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal} from 'execa';\n\nawait getCancelSignal();\n"
  },
  {
    "path": "test/fixtures/graceful-print.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst cancelSignal = await getCancelSignal();\nawait onAbortedSignal(cancelSignal);\nconsole.log(cancelSignal.reason);\n"
  },
  {
    "path": "test/fixtures/graceful-ref.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal} from 'execa';\n\nconst cancelSignal = await getCancelSignal();\ncancelSignal.addEventListener('abort', () => {});\n"
  },
  {
    "path": "test/fixtures/graceful-send-echo.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, getOneMessage, sendMessage} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst message = await getOneMessage();\nconst cancelSignal = await getCancelSignal();\nawait sendMessage(message);\nawait onAbortedSignal(cancelSignal);\nawait sendMessage(cancelSignal.reason);\n"
  },
  {
    "path": "test/fixtures/graceful-send-fast.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\n\nconst cancelSignal = await getCancelSignal();\nawait sendMessage(cancelSignal.aborted);\n"
  },
  {
    "path": "test/fixtures/graceful-send-print.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst cancelSignal = await getCancelSignal();\nawait sendMessage(cancelSignal.aborted);\nawait onAbortedSignal(cancelSignal);\nconsole.log(cancelSignal.reason);\n"
  },
  {
    "path": "test/fixtures/graceful-send-string.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\nimport {foobarString} from '../helpers/input.js';\n\nawait getCancelSignal();\nawait sendMessage(foobarString);\n"
  },
  {
    "path": "test/fixtures/graceful-send-twice.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst cancelSignal = await getCancelSignal();\nawait sendMessage(cancelSignal.aborted);\nawait onAbortedSignal(cancelSignal);\nawait sendMessage(cancelSignal.reason);\n"
  },
  {
    "path": "test/fixtures/graceful-send.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst cancelSignal = await getCancelSignal();\nawait onAbortedSignal(cancelSignal);\nawait sendMessage(cancelSignal.reason);\n"
  },
  {
    "path": "test/fixtures/graceful-twice.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal, sendMessage} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nawait getCancelSignal();\nconst cancelSignal = await getCancelSignal();\nawait onAbortedSignal(cancelSignal);\nawait sendMessage(cancelSignal.reason);\n"
  },
  {
    "path": "test/fixtures/graceful-wait.js",
    "content": "#!/usr/bin/env node\nimport {getCancelSignal} from 'execa';\nimport {onAbortedSignal} from '../helpers/graceful.js';\n\nconst cancelSignal = await getCancelSignal();\nawait onAbortedSignal(cancelSignal);\n"
  },
  {
    "path": "test/fixtures/hello.cmd",
    "content": "ECHO Hello World\n"
  },
  {
    "path": "test/fixtures/hello.sh",
    "content": "echo Hello World\n"
  },
  {
    "path": "test/fixtures/ipc-any.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport * as execaExports from '../../index.js';\n\nconst methodName = process.argv[2];\nawait execaExports[methodName]();\n"
  },
  {
    "path": "test/fixtures/ipc-disconnect-get.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getOneMessage} from '../../index.js';\n\nprocess.disconnect();\nconsole.log(process.channel);\nawait getOneMessage();\n"
  },
  {
    "path": "test/fixtures/ipc-disconnect.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {once} from 'node:events';\nimport * as execaExports from '../../index.js';\n\nconst methodName = process.argv[2];\n\nif (process.channel !== null) {\n\tawait once(process, 'disconnect');\n}\n\nawait execaExports[methodName]();\n"
  },
  {
    "path": "test/fixtures/ipc-echo-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nawait sendMessage(await getOneMessage());\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/ipc-echo-filter.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {foobarArray} from '../helpers/input.js';\n\nconst message = await getOneMessage({filter: message => message === foobarArray[1]});\nawait sendMessage(message);\n"
  },
  {
    "path": "test/fixtures/ipc-echo-item.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nconst [message] = await getOneMessage();\nawait sendMessage(message);\n"
  },
  {
    "path": "test/fixtures/ipc-echo-twice-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nconst message = await getOneMessage();\nawait sendMessage(message);\nawait sendMessage(message);\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/ipc-echo-twice-wait.js",
    "content": "#!/usr/bin/env node\nimport {setTimeout} from 'node:timers/promises';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nconst message = await getOneMessage();\nawait sendMessage(message);\nconst secondMessage = await getOneMessage();\nawait sendMessage(secondMessage);\nawait setTimeout(1e3);\nawait sendMessage('.');\n"
  },
  {
    "path": "test/fixtures/ipc-echo-twice.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nconst message = await getOneMessage();\nawait sendMessage(message);\nconst secondMessage = await getOneMessage();\nawait sendMessage(secondMessage);\n"
  },
  {
    "path": "test/fixtures/ipc-echo-wait.js",
    "content": "#!/usr/bin/env node\nimport {setTimeout} from 'node:timers/promises';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nawait setTimeout(1e3);\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-echo.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-get-filter-throw.js",
    "content": "#!/usr/bin/env node\nimport {getOneMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait getOneMessage({\n\tfilter() {\n\t\tthrow new Error(foobarString);\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/ipc-get-io-error.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getOneMessage} from '../../index.js';\nimport {mockSendIoError} from '../helpers/ipc.js';\n\nmockSendIoError(process);\nconsole.log(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-get-ref.js",
    "content": "#!/usr/bin/env node\nimport {getOneMessage} from '../../index.js';\n\ngetOneMessage();\n"
  },
  {
    "path": "test/fixtures/ipc-get-send-get.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {alwaysPass} from '../helpers/ipc.js';\n\nconst filter = argv[2] === 'true' ? alwaysPass : undefined;\n\nconst message = await getOneMessage({filter});\nawait Promise.all([\n\tgetOneMessage({filter}),\n\tsendMessage(message),\n]);\n"
  },
  {
    "path": "test/fixtures/ipc-get-unref.js",
    "content": "#!/usr/bin/env node\nimport {getOneMessage} from '../../index.js';\n\ngetOneMessage({reference: false});\n"
  },
  {
    "path": "test/fixtures/ipc-get.js",
    "content": "#!/usr/bin/env node\nimport {getOneMessage} from '../../index.js';\n\nawait getOneMessage();\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-back-serial.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\nimport {alwaysPass, getFirst} from '../helpers/ipc.js';\n\nconst filter = process.argv[2] === 'true' ? alwaysPass : undefined;\n\nawait sendMessage(await getOneMessage({filter}));\n\nconst promise = sendMessage(1);\nprocess.emit('message', '.');\nawait promise;\n\nconst messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 2);\nfor (const message of messages) {\n\t// eslint-disable-next-line no-await-in-loop\n\tawait sendMessage(message);\n}\n\nconst secondPromise = process.argv[3] === 'true'\n\t? getFirst()\n\t: getOneMessage({filter});\nawait sendMessage(await secondPromise);\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-back.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\nimport {alwaysPass, getFirst} from '../helpers/ipc.js';\n\nconst filter = process.argv[2] === 'true' ? alwaysPass : undefined;\n\nawait sendMessage(await getOneMessage({filter}));\n\nconst messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 1);\nawait Promise.all([\n\t...messages.map(message => sendMessage(message)),\n\tprocess.emit('message', '.'),\n]);\n\nconst promise = process.argv[3] === 'true'\n\t? getFirst()\n\t: getOneMessage({filter});\nawait sendMessage(await promise);\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-break.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getEachMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst iterable = getEachMessage();\nawait sendMessage(foobarString);\n\n// eslint-disable-next-line no-unreachable-loop\nfor await (const _ of iterable) {\n\tbreak;\n}\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-error.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getEachMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst echoMessages = async () => {\n\tfor await (const message of getEachMessage()) {\n\t\tif (message === foobarString) {\n\t\t\tbreak;\n\t\t}\n\n\t\tawait sendMessage(message);\n\t}\n};\n\nprocess.on('error', () => {});\n// eslint-disable-next-line unicorn/prefer-top-level-await\nconst promise = echoMessages();\nprocess.emit('error', new Error(foobarString));\nawait promise;\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-io-error.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getEachMessage} from '../../index.js';\nimport {mockSendIoError} from '../helpers/ipc.js';\n\nmockSendIoError(process);\nfor await (const message of getEachMessage()) {\n\tconsole.log(message);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-print.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getEachMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst iterable = getEachMessage();\n\nawait sendMessage(foobarString);\n\nfor await (const message of iterable) {\n\tif (message === foobarString) {\n\t\tbreak;\n\t}\n\n\tprocess.stdout.write(`${message}`);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-ref.js",
    "content": "#!/usr/bin/env node\nimport {getEachMessage} from '../../index.js';\n\ngetEachMessage();\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-send.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getEachMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst iterable = getEachMessage();\nawait sendMessage(foobarString);\n\nfor await (const message of iterable) {\n\tconsole.log(message);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-throw.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getEachMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst iterable = getEachMessage();\nawait sendMessage(foobarString);\n\n// eslint-disable-next-line no-unreachable-loop\nfor await (const message of iterable) {\n\tthrow new Error(message);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-twice.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getEachMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nfor (let index = 0; index < 2; index += 1) {\n\t// Intentionally not awaiting `sendMessage()` to avoid a race condition\n\tsendMessage(foobarString);\n\t// eslint-disable-next-line no-await-in-loop\n\tfor await (const message of getEachMessage()) {\n\t\tif (message === foobarString) {\n\t\t\tbreak;\n\t\t}\n\n\t\tawait sendMessage(`${index}${message}`);\n\t}\n}\n"
  },
  {
    "path": "test/fixtures/ipc-iterate-unref.js",
    "content": "#!/usr/bin/env node\nimport {getEachMessage} from '../../index.js';\n\ngetEachMessage({reference: false});\n"
  },
  {
    "path": "test/fixtures/ipc-iterate.js",
    "content": "#!/usr/bin/env node\nimport {getEachMessage, sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nfor await (const message of getEachMessage()) {\n\tif (message === foobarString) {\n\t\tbreak;\n\t}\n\n\tawait sendMessage(message);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-once-disconnect-get.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getOneMessage} from '../../index.js';\n\nawait getOneMessage();\n\nprocess.once('disconnect', () => {\n\tconsole.log('.');\n});\n\nprocess.send('.');\n"
  },
  {
    "path": "test/fixtures/ipc-once-disconnect-send.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nawait sendMessage('.');\n\nprocess.once('disconnect', () => {\n\tconsole.log('.');\n});\n\nprocess.send('.');\n"
  },
  {
    "path": "test/fixtures/ipc-once-disconnect.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.send('.');\n\nprocess.once('disconnect', () => {\n\tconsole.log('.');\n});\n"
  },
  {
    "path": "test/fixtures/ipc-once-message-get.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getOneMessage} from '../../index.js';\n\nawait getOneMessage();\n\nprocess.once('message', message => {\n\tconsole.log(message);\n});\n\nprocess.send('.');\n"
  },
  {
    "path": "test/fixtures/ipc-once-message-send.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nawait sendMessage('.');\n\nprocess.once('message', message => {\n\tconsole.log(message);\n});\n"
  },
  {
    "path": "test/fixtures/ipc-once-message.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.send('.');\n\nprocess.once('message', message => {\n\tconsole.log(message);\n});\n"
  },
  {
    "path": "test/fixtures/ipc-print-many-each.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {getEachMessage} from '../../index.js';\n\nconst count = Number(argv[2]);\n\nfor (let index = 0; index < count; index += 1) {\n\t// eslint-disable-next-line no-await-in-loop, no-unreachable-loop\n\tfor await (const message of getEachMessage()) {\n\t\tconsole.log(message);\n\t\tbreak;\n\t}\n}\n"
  },
  {
    "path": "test/fixtures/ipc-print-many.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {getOneMessage} from '../../index.js';\nimport {alwaysPass} from '../helpers/ipc.js';\n\nconst count = Number(argv[2]);\nconst filter = argv[3] === 'true' ? alwaysPass : undefined;\n\nfor (let index = 0; index < count; index += 1) {\n\t// eslint-disable-next-line no-await-in-loop\n\tconsole.log(await getOneMessage({filter}));\n}\n"
  },
  {
    "path": "test/fixtures/ipc-process-error.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getOneMessage, sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {alwaysPass} from '../helpers/ipc.js';\n\nprocess.on('error', () => {});\nconst filter = process.argv[2] === 'true' ? alwaysPass : undefined;\nconst promise = getOneMessage({filter});\nprocess.emit('error', new Error(foobarString));\nawait sendMessage(await promise);\n"
  },
  {
    "path": "test/fixtures/ipc-process-send-get.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {foobarString} from '../helpers/input.js';\nimport {getOneMessage} from '../../index.js';\n\nawait getOneMessage();\n\nprocess.send(foobarString, () => {\n\tconsole.log('.');\n});\n"
  },
  {
    "path": "test/fixtures/ipc-process-send-send.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {foobarString} from '../helpers/input.js';\nimport {sendMessage} from '../../index.js';\n\nawait sendMessage('.');\n\nprocess.send(foobarString, () => {\n\tconsole.log('.');\n});\n"
  },
  {
    "path": "test/fixtures/ipc-process-send.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {foobarString} from '../helpers/input.js';\n\nprocess.send(foobarString, () => {\n\tconsole.log('.');\n});\n"
  },
  {
    "path": "test/fixtures/ipc-replay.js",
    "content": "#!/usr/bin/env node\nimport {setTimeout} from 'node:timers/promises';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nawait sendMessage(await getOneMessage());\nawait setTimeout(1e3);\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-send-argv.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nconst message = argv[2];\nawait sendMessage(message);\n"
  },
  {
    "path": "test/fixtures/ipc-send-disconnect.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString);\n\nprocess.disconnect();\n"
  },
  {
    "path": "test/fixtures/ipc-send-echo-strict.js",
    "content": "#!/usr/bin/env node\nimport {setTimeout} from 'node:timers/promises';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nawait sendMessage('.', {strict: true});\nawait setTimeout(10);\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-send-echo-wait.js",
    "content": "#!/usr/bin/env node\nimport {setTimeout} from 'node:timers/promises';\nimport {sendMessage, getOneMessage} from '../../index.js';\n\nawait sendMessage('.');\nawait setTimeout(1e3);\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-send-error.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage} from '../../index.js';\n\nawait sendMessage(0n);\n"
  },
  {
    "path": "test/fixtures/ipc-send-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString);\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/ipc-send-forever.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString);\n\nsetTimeout(() => {}, 1e8);\n"
  },
  {
    "path": "test/fixtures/ipc-send-get.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait Promise.all([\n\tgetOneMessage(),\n\tsendMessage(foobarString),\n]);\n"
  },
  {
    "path": "test/fixtures/ipc-send-io-error.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\nimport {mockSendIoError} from '../helpers/ipc.js';\n\nmockSendIoError(process);\nawait sendMessage('.');\n"
  },
  {
    "path": "test/fixtures/ipc-send-json.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nconst message = JSON.parse(argv[2]);\nawait sendMessage(message);\n"
  },
  {
    "path": "test/fixtures/ipc-send-many.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nconst count = Number(argv[2]);\nawait Promise.all(Array.from({length: count}, (_, index) => sendMessage(index)));\n"
  },
  {
    "path": "test/fixtures/ipc-send-native.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.send('.');\n"
  },
  {
    "path": "test/fixtures/ipc-send-pid.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {execa, sendMessage} from '../../index.js';\n\nconst cleanup = process.argv[2] === 'true';\nconst detached = process.argv[3] === 'true';\nconst subprocess = execa('forever.js', {cleanup, detached});\nawait sendMessage(subprocess.pid);\nawait subprocess;\n"
  },
  {
    "path": "test/fixtures/ipc-send-print.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString);\n\nprocess.stdout.write('.');\n\nawait getOneMessage();\n"
  },
  {
    "path": "test/fixtures/ipc-send-repeat.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nconst count = Number(argv[2]);\nfor (let index = 0; index < count; index += 1) {\n\t// eslint-disable-next-line no-await-in-loop\n\tawait sendMessage(index);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-send-strict-catch.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\ntry {\n\tawait sendMessage(foobarString, {strict: true});\n} catch {\n\tawait sendMessage(foobarString);\n}\n"
  },
  {
    "path": "test/fixtures/ipc-send-strict-get.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString, {strict: true});\nawait sendMessage(await getOneMessage());\n"
  },
  {
    "path": "test/fixtures/ipc-send-strict-listen.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage, getOneMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst [message] = await Promise.all([\n\tgetOneMessage(),\n\tsendMessage(foobarString, {strict: true}),\n]);\nawait sendMessage(message);\n"
  },
  {
    "path": "test/fixtures/ipc-send-strict.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString, {strict: true});\n"
  },
  {
    "path": "test/fixtures/ipc-send-twice.js",
    "content": "#!/usr/bin/env node\nimport {sendMessage} from '../../index.js';\nimport {foobarArray} from '../helpers/input.js';\n\nawait sendMessage(foobarArray[0]);\nawait sendMessage(foobarArray[1]);\n"
  },
  {
    "path": "test/fixtures/ipc-send-wait-print.js",
    "content": "#!/usr/bin/env node\nimport {setTimeout} from 'node:timers/promises';\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nawait sendMessage(foobarString);\nawait setTimeout(100);\nconsole.log('.');\n"
  },
  {
    "path": "test/fixtures/ipc-send.js",
    "content": "#!/usr/bin/env node\nimport {argv} from 'node:process';\nimport {sendMessage} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst message = argv[2] || foobarString;\nawait sendMessage(message);\n"
  },
  {
    "path": "test/fixtures/max-buffer.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\n\nconst fdNumber = Number(process.argv[2]);\nconst bytes = '.'.repeat(Number(process.argv[3] || 1e7));\ngetWriteStream(fdNumber).write(bytes);\n"
  },
  {
    "path": "test/fixtures/nested/custom-event.js",
    "content": "export const getOptions = ({type, eventProperty}) => ({\n\tverbose: (verboseLine, verboseObject) => verboseObject.type === type ? `${verboseObject[eventProperty]}` : undefined,\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-json.js",
    "content": "export const getOptions = ({type}) => ({\n\tverbose: (verboseLine, verboseObject) => verboseObject.type === type ? JSON.stringify(verboseObject) : undefined,\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-object-stdout.js",
    "content": "import {foobarObject} from '../../helpers/input.js';\n\nexport const getOptions = () => ({\n\tverbose: (verboseLine, {type}) => type === 'output' ? verboseLine : undefined,\n\tstdout: {\n\t\t* transform() {\n\t\t\tyield foobarObject;\n\t\t},\n\t\tobjectMode: true,\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-option.js",
    "content": "export const getOptions = ({type, optionName}) => ({\n\tverbose: (verboseLine, verboseObject) => verboseObject.type === type ? `${verboseObject.options[optionName]}` : undefined,\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-print-function.js",
    "content": "export const getOptions = ({type, fdNumber, secondFdNumber}) => ({\n\tverbose: {\n\t\t[fdNumber](verboseLine, verboseObject) {\n\t\t\tif (verboseObject.type === type) {\n\t\t\t\tconsole.warn(verboseLine);\n\t\t\t}\n\t\t},\n\t\t[secondFdNumber]: 'none',\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-print-multiple.js",
    "content": "export const getOptions = ({type, fdNumber, secondFdNumber}) => ({\n\tverbose: {\n\t\t[fdNumber](verboseLine, verboseObject) {\n\t\t\tif (verboseObject.type === type) {\n\t\t\t\tconsole.warn(verboseLine);\n\t\t\t}\n\t\t},\n\t\t[secondFdNumber]() {},\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-print.js",
    "content": "export const getOptions = ({type, fdNumber}) => ({\n\tverbose: setFdSpecific(\n\t\tfdNumber,\n\t\t(verboseLine, verboseObject) => verboseObject.type === type ? verboseLine : undefined,\n\t),\n});\n\nconst setFdSpecific = (fdNumber, option) => fdNumber === undefined\n\t? option\n\t: {[fdNumber]: option};\n"
  },
  {
    "path": "test/fixtures/nested/custom-result.js",
    "content": "export const getOptions = ({type}) => ({\n\tverbose: (verboseLine, verboseObject) => verboseObject.type === type ? JSON.stringify(verboseObject.result) : undefined,\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-return.js",
    "content": "export const getOptions = ({verboseOutput}) => ({\n\tverbose(verboseLine, {type}) {\n\t\treturn type === 'command' ? verboseOutput : undefined;\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-throw.js",
    "content": "export const getOptions = ({type, errorMessage}) => ({\n\tverbose(verboseLine, verboseObject) {\n\t\tif (verboseObject.type === type) {\n\t\t\tthrow new Error(errorMessage);\n\t\t}\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/nested/custom-uppercase.js",
    "content": "export const getOptions = () => ({\n\tverbose(verboseLine, {type}) {\n\t\treturn type === 'command' ? verboseLine.replace('noop', 'NOOP') : undefined;\n\t},\n});\n"
  },
  {
    "path": "test/fixtures/nested/file-url.js",
    "content": "import {pathToFileURL} from 'node:url';\n\nexport const getOptions = ({stdout: {file}}) => ({stdout: pathToFileURL(file)});\n"
  },
  {
    "path": "test/fixtures/nested/generator-big-array.js",
    "content": "import {getOutputGenerator} from '../../helpers/generator.js';\n\nconst bigArray = Array.from({length: 100}, (_, index) => index);\nexport const getOptions = () => ({stdout: getOutputGenerator(bigArray)(true)});\n"
  },
  {
    "path": "test/fixtures/nested/generator-duplex.js",
    "content": "import {uppercaseBufferDuplex} from '../../helpers/duplex.js';\n\nexport const getOptions = () => ({stdout: uppercaseBufferDuplex()});\n"
  },
  {
    "path": "test/fixtures/nested/generator-object.js",
    "content": "import {outputObjectGenerator} from '../../helpers/generator.js';\n\nexport const getOptions = () => ({stdout: outputObjectGenerator()});\n"
  },
  {
    "path": "test/fixtures/nested/generator-string-object.js",
    "content": "import {getOutputGenerator} from '../../helpers/generator.js';\nimport {simpleFull} from '../../helpers/lines.js';\n\nexport const getOptions = () => ({stdout: getOutputGenerator(simpleFull)(true)});\n"
  },
  {
    "path": "test/fixtures/nested/generator-uppercase.js",
    "content": "import {uppercaseGenerator} from '../../helpers/generator.js';\n\nexport const getOptions = () => ({stdout: uppercaseGenerator()});\n"
  },
  {
    "path": "test/fixtures/nested/writable-web.js",
    "content": "export const getOptions = () => ({stdout: new WritableStream()});\n"
  },
  {
    "path": "test/fixtures/nested/writable.js",
    "content": "import process from 'node:process';\n\nexport const getOptions = () => ({stdout: process.stdout});\n"
  },
  {
    "path": "test/fixtures/nested-double.js",
    "content": "#!/usr/bin/env node\nimport {execa, getOneMessage} from '../../index.js';\n\nconst {file, commandArguments, options} = await getOneMessage();\nconst firstArguments = commandArguments.slice(0, -1);\nconst lastArgument = commandArguments.at(-1);\nawait Promise.all([\n\texeca(file, [...firstArguments, lastArgument], options),\n\texeca(file, [...firstArguments, lastArgument.toUpperCase()], options),\n]);\n"
  },
  {
    "path": "test/fixtures/nested-fail.js",
    "content": "#!/usr/bin/env node\nimport {execa, getOneMessage} from '../../index.js';\n\nconst {file, commandArguments, options} = await getOneMessage();\nconst subprocess = execa(file, commandArguments, options);\nsubprocess.kill(new Error(commandArguments[0]));\nawait subprocess;\n"
  },
  {
    "path": "test/fixtures/nested-inherit.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {execa} from '../../index.js';\nimport {generatorsMap} from '../helpers/map.js';\n\nconst type = process.argv[2];\nawait execa('noop-fd.js', ['1'], {stdout: ['inherit', generatorsMap[type].uppercase()]});\n"
  },
  {
    "path": "test/fixtures/nested-multiple-stdin.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {execa, execaSync} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {parseStdioOption} from '../helpers/stdio.js';\n\nconst [stdioOption, isSyncString] = process.argv.slice(2);\nconst stdin = parseStdioOption(stdioOption);\nconst execaMethod = isSyncString === 'true' ? execaSync : execa;\nawait execaMethod('stdin.js', {input: foobarString, stdin, stdout: 'inherit'});\n"
  },
  {
    "path": "test/fixtures/nested-multiple-stdio-output.js",
    "content": "#!/usr/bin/env node\nimport {Buffer} from 'node:buffer';\nimport process from 'node:process';\nimport {execa, execaSync} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getStdio, parseStdioOption} from '../helpers/stdio.js';\nimport {getWriteStream} from '../helpers/fs.js';\n\nconst [stdioOption, fdNumber, outerFdNumber, isSyncString, encoding] = process.argv.slice(2);\nconst stdioValue = parseStdioOption(stdioOption);\nconst execaMethod = isSyncString === 'true' ? execaSync : execa;\nconst {stdio} = await execaMethod('noop-fd.js', [fdNumber, foobarString], {...getStdio(Number(fdNumber), stdioValue), encoding});\ngetWriteStream(Number(outerFdNumber)).write(`nested ${Buffer.from(stdio[fdNumber]).toString()}`);\n"
  },
  {
    "path": "test/fixtures/nested-node.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\nimport {execa, execaNode} from '../../index.js';\n\nconst [fakeExecArgv, execaMethod, nodeOptions, file, ...commandArguments] = process.argv.slice(2);\n\nif (fakeExecArgv !== '') {\n\tprocess.execArgv = [fakeExecArgv];\n}\n\nconst filteredNodeOptions = [nodeOptions].filter(Boolean);\nconst {stdout, stderr} = await (execaMethod === 'execaNode'\n\t? execaNode(file, commandArguments, {nodeOptions: filteredNodeOptions})\n\t: execa(file, commandArguments, {nodeOptions: filteredNodeOptions, node: true}));\nconsole.log(stdout);\ngetWriteStream(3).write(stderr);\n"
  },
  {
    "path": "test/fixtures/nested-pipe-file.js",
    "content": "#!/usr/bin/env node\nimport {execa, getOneMessage} from '../../index.js';\n\nconst {\n\tfile,\n\tcommandArguments = [],\n\toptions: {\n\t\tsourceOptions = {},\n\t\tdestinationFile,\n\t\tdestinationArguments = [],\n\t\tdestinationOptions = {},\n\t},\n} = await getOneMessage();\nawait execa(file, commandArguments, sourceOptions)\n\t.pipe(destinationFile, destinationArguments, destinationOptions);\n"
  },
  {
    "path": "test/fixtures/nested-pipe-script.js",
    "content": "#!/usr/bin/env node\nimport {$, getOneMessage} from '../../index.js';\n\nconst {\n\tfile,\n\tcommandArguments = [],\n\toptions: {\n\t\tsourceOptions = {},\n\t\tdestinationFile,\n\t\tdestinationArguments = [],\n\t\tdestinationOptions = {},\n\t},\n} = await getOneMessage();\nawait $(sourceOptions)`${file} ${commandArguments}`\n\t.pipe(destinationOptions)`${destinationFile} ${destinationArguments}`;\n"
  },
  {
    "path": "test/fixtures/nested-pipe-stream.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {execa, getOneMessage} from '../../index.js';\n\nconst {file, commandArguments, options: {unpipe, ...options}} = await getOneMessage();\nconst subprocess = execa(file, commandArguments, options);\nsubprocess.stdout.pipe(process.stdout);\nif (unpipe) {\n\tsubprocess.stdout.unpipe(process.stdout);\n}\n\nawait subprocess;\n"
  },
  {
    "path": "test/fixtures/nested-pipe-subprocess.js",
    "content": "#!/usr/bin/env node\nimport {execa, getOneMessage} from '../../index.js';\n\nconst {file, commandArguments, options: {unpipe, ...options}} = await getOneMessage();\nconst source = execa(file, commandArguments, options);\nconst destination = execa('stdin.js');\nconst controller = new AbortController();\nconst subprocess = source.pipe(destination, {unpipeSignal: controller.signal});\nif (unpipe) {\n\tcontroller.abort();\n\tdestination.stdin.end();\n}\n\ntry {\n\tawait subprocess;\n} catch {}\n"
  },
  {
    "path": "test/fixtures/nested-pipe-subprocesses.js",
    "content": "#!/usr/bin/env node\nimport {execa, getOneMessage} from '../../index.js';\n\nconst {\n\tfile,\n\tcommandArguments = [],\n\toptions: {\n\t\tsourceOptions = {},\n\t\tdestinationFile,\n\t\tdestinationArguments = [],\n\t\tdestinationOptions = {},\n\t},\n} = await getOneMessage();\nawait execa(file, commandArguments, sourceOptions)\n\t.pipe(execa(destinationFile, destinationArguments, destinationOptions));\n"
  },
  {
    "path": "test/fixtures/nested-pipe-verbose.js",
    "content": "#!/usr/bin/env node\nimport {execa, getOneMessage, sendMessage} from '../../index.js';\nimport {getNestedOptions} from '../helpers/nested.js';\n\nconst {\n\tfile,\n\tcommandArguments = [],\n\toptions: {destinationFile, destinationArguments, ...options},\n\toptionsFixture,\n\toptionsInput,\n} = await getOneMessage();\n\nconst commandOptions = await getNestedOptions(options, optionsFixture, optionsInput);\n\ntry {\n\tconst result = await execa(file, commandArguments, commandOptions)\n\t\t.pipe(destinationFile, destinationArguments, commandOptions);\n\tawait sendMessage(result);\n} catch (error) {\n\tawait sendMessage(error);\n}\n"
  },
  {
    "path": "test/fixtures/nested-stdio.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {execa, execaSync} from '../../index.js';\nimport {parseStdioOption} from '../helpers/stdio.js';\n\nconst [stdioOption, fdNumber, isSyncString, file, ...commandArguments] = process.argv.slice(2);\nconst optionValue = parseStdioOption(stdioOption);\nconst isSync = isSyncString === 'true';\nconst stdio = ['ignore', 'inherit', 'inherit'];\nstdio[fdNumber] = optionValue;\nconst execaMethod = isSync ? execaSync : execa;\nconst returnValue = execaMethod(file, [`${fdNumber}`, ...commandArguments], {stdio});\n\nconst shouldPipe = Array.isArray(optionValue) && optionValue.includes('pipe');\nconst fdReturnValue = returnValue.stdio[fdNumber];\nconst hasPipe = fdReturnValue !== undefined && fdReturnValue !== null;\n\nif (shouldPipe && !hasPipe) {\n\tthrow new Error(`subprocess.stdio[${fdNumber}] is null.`);\n}\n\nif (!shouldPipe && hasPipe) {\n\tthrow new Error(`subprocess.stdio[${fdNumber}] should be null.`);\n}\n\nif (!isSync) {\n\tawait returnValue;\n}\n"
  },
  {
    "path": "test/fixtures/nested-sync-tty.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport tty from 'node:tty';\nimport {execa, execaSync} from '../../index.js';\n\nconst mockIsatty = fdNumber => {\n\ttty.isatty = fdNumberArgument => fdNumber === fdNumberArgument;\n};\n\nconst originalIsatty = tty.isatty;\nconst unmockIsatty = () => {\n\ttty.isatty = originalIsatty;\n};\n\nconst [options, isSync, file, fdNumber, ...commandArguments] = process.argv.slice(2);\nmockIsatty(Number(fdNumber));\n\ntry {\n\tif (isSync === 'true') {\n\t\texecaSync(file, [fdNumber, ...commandArguments], JSON.parse(options));\n\t} else {\n\t\tawait execa(file, [fdNumber, ...commandArguments], JSON.parse(options));\n\t}\n} finally {\n\tunmockIsatty();\n}\n"
  },
  {
    "path": "test/fixtures/nested-write.js",
    "content": "#!/usr/bin/env node\nimport {writeFile} from 'node:fs/promises';\nimport {text} from 'node:stream/consumers';\nimport process from 'node:process';\n\nconst [filePath, bytes] = process.argv.slice(2);\nconst stdinString = await text(process.stdin);\nawait writeFile(filePath, `${stdinString} ${bytes}`);\n"
  },
  {
    "path": "test/fixtures/nested.js",
    "content": "#!/usr/bin/env node\nimport {\n\texeca,\n\texecaSync,\n\tgetOneMessage,\n\tsendMessage,\n} from '../../index.js';\nimport {getNestedOptions} from '../helpers/nested.js';\n\nconst {\n\tisSync,\n\tfile,\n\tcommandArguments,\n\toptions,\n\toptionsFixture,\n\toptionsInput,\n} = await getOneMessage();\n\nconst commandOptions = await getNestedOptions(options, optionsFixture, optionsInput);\n\ntry {\n\tconst result = isSync\n\t\t? execaSync(file, commandArguments, commandOptions)\n\t\t: await execa(file, commandArguments, commandOptions);\n\tawait sendMessage(result);\n} catch (error) {\n\tawait sendMessage(error);\n}\n"
  },
  {
    "path": "test/fixtures/no-await.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {once} from 'node:events';\nimport {execa} from '../../index.js';\n\nconst [options, file, ...commandArguments] = process.argv.slice(2);\nexeca(file, commandArguments, JSON.parse(options));\nconst [error] = await once(process, 'unhandledRejection');\nconsole.log(error.shortMessage);\n"
  },
  {
    "path": "test/fixtures/no-killable.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nconst noop = () => {};\n\nprocess.on('SIGTERM', noop);\nprocess.on('SIGINT', noop);\n\nawait sendMessage('');\nconsole.log('.');\n\nsetTimeout(noop, 1e8);\n"
  },
  {
    "path": "test/fixtures/non-executable.js",
    "content": "#!/usr/bin/env node\n"
  },
  {
    "path": "test/fixtures/noop-132.js",
    "content": "#!/usr/bin/env node\nconsole.log(1);\nconsole.warn(2);\n\nsetTimeout(() => {\n\tconsole.log(3);\n}, 1000);\n"
  },
  {
    "path": "test/fixtures/noop-both-fail-strict.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconst stdoutBytes = process.argv[2];\nconst stderrBytes = process.argv[3];\nprocess.stdout.write(stdoutBytes);\nprocess.stderr.write(stderrBytes);\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/noop-both-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {foobarString} from '../helpers/input.js';\n\nconst bytes = process.argv[2] || foobarString;\nconsole.log(bytes);\nconsole.error(bytes);\nprocess.exitCode = 1;\n"
  },
  {
    "path": "test/fixtures/noop-both.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {foobarString} from '../helpers/input.js';\n\nconst bytes = process.argv[2] || foobarString;\nconst bytesStderr = process.argv[3] || bytes;\nconsole.log(bytes);\nconsole.error(bytesStderr);\n"
  },
  {
    "path": "test/fixtures/noop-continuous.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {setTimeout} from 'node:timers/promises';\n\nconst bytes = process.argv[2];\nfor (const character of bytes) {\n\tconsole.log(character);\n\t// eslint-disable-next-line no-await-in-loop\n\tawait setTimeout(100);\n}\n"
  },
  {
    "path": "test/fixtures/noop-delay.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {setTimeout} from 'node:timers/promises';\nimport {getWriteStream} from '../helpers/fs.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst fdNumber = Number(process.argv[2]);\nconst bytes = process.argv[3] || foobarString;\ngetWriteStream(fdNumber).write(bytes);\nawait setTimeout(100);\n"
  },
  {
    "path": "test/fixtures/noop-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst fdNumber = Number(process.argv[2]);\nconst bytes = process.argv[3] || foobarString;\ngetWriteStream(fdNumber).write(bytes);\nprocess.exitCode = 2;\n"
  },
  {
    "path": "test/fixtures/noop-fd-ipc.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {promisify} from 'node:util';\nimport {sendMessage} from '../../index.js';\nimport {getWriteStream} from '../helpers/fs.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst fdNumber = Number(process.argv[2]);\nconst bytes = process.argv[3] || foobarString;\nconst stream = getWriteStream(fdNumber);\nawait promisify(stream.write.bind(stream))(bytes);\nawait sendMessage('');\n"
  },
  {
    "path": "test/fixtures/noop-fd.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst fdNumber = Number(process.argv[2]);\nconst bytes = process.argv[3] || foobarString;\ngetWriteStream(fdNumber).write(bytes);\n"
  },
  {
    "path": "test/fixtures/noop-forever.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nconst bytes = process.argv[2];\nconsole.log(bytes);\nsetTimeout(() => {}, 1e8);\n"
  },
  {
    "path": "test/fixtures/noop-progressive.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {setTimeout} from 'node:timers/promises';\n\nconst bytes = process.argv[2];\nfor (const character of bytes) {\n\tprocess.stdout.write(character);\n\t// eslint-disable-next-line no-await-in-loop\n\tawait setTimeout(10);\n}\n\nprocess.stdout.write('\\n');\n"
  },
  {
    "path": "test/fixtures/noop-repeat.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\nimport {foobarString} from '../helpers/input.js';\n\nconst fdNumber = Number(process.argv[2]) || 1;\nconst bytes = process.argv[3] || foobarString;\nsetInterval(() => {\n\tgetWriteStream(fdNumber).write(bytes);\n}, 10);\n"
  },
  {
    "path": "test/fixtures/noop-stdin-double.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {text} from 'node:stream/consumers';\n\nconst bytes = process.argv[2];\nconst stdinString = await text(process.stdin);\nconsole.log(`${stdinString} ${bytes}`);\n"
  },
  {
    "path": "test/fixtures/noop-stdin-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {text} from 'node:stream/consumers';\nimport {getWriteStream} from '../helpers/fs.js';\n\nconst fdNumber = Number(process.argv[2]);\nconst stdinString = await text(process.stdin);\ngetWriteStream(fdNumber).write(stdinString);\nprocess.exitCode = 2;\n"
  },
  {
    "path": "test/fixtures/noop-stdin-fd.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getWriteStream} from '../helpers/fs.js';\n\nconst fdNumber = Number(process.argv[2]);\nprocess.stdin.pipe(getWriteStream(fdNumber));\n"
  },
  {
    "path": "test/fixtures/noop-verbose.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {sendMessage} from '../../index.js';\n\nconst bytes = process.argv[2];\nconsole.log(bytes);\n\ntry {\n\tawait sendMessage(bytes);\n} catch {}\n\nprocess.exitCode = 2;\n"
  },
  {
    "path": "test/fixtures/noop.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {foobarString} from '../helpers/input.js';\n\nconst bytes = process.argv[2] || foobarString;\nconsole.log(bytes);\n"
  },
  {
    "path": "test/fixtures/stdin-both.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.stdin.pipe(process.stdout);\nprocess.stdin.pipe(process.stderr);\n"
  },
  {
    "path": "test/fixtures/stdin-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.stdin.pipe(process.stdout);\nprocess.exitCode = 2;\n"
  },
  {
    "path": "test/fixtures/stdin-fd-both.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getReadStream} from '../helpers/fs.js';\n\nconst fdNumber = Number(process.argv[2]);\nprocess.stdin.pipe(process.stdout);\ngetReadStream(fdNumber).pipe(process.stdout);\n"
  },
  {
    "path": "test/fixtures/stdin-fd.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getReadStream} from '../helpers/fs.js';\n\nconst fdNumber = Number(process.argv[2]);\ngetReadStream(fdNumber).pipe(process.stdout);\n"
  },
  {
    "path": "test/fixtures/stdin-script.js",
    "content": "#!/usr/bin/env node\nimport {$} from '../../index.js';\nimport {FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\n\nawait $({stdout: 'inherit'})`node ${`${FIXTURES_DIRECTORY}/stdin.js`}`;\n"
  },
  {
    "path": "test/fixtures/stdin-twice-both.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {getReadStream} from '../helpers/fs.js';\n\nconst fdNumber = Number(process.argv[2]);\n\nprocess.stdin.pipe(process.stdout);\ngetReadStream(fdNumber).pipe(process.stderr);\n"
  },
  {
    "path": "test/fixtures/stdin.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\n\nprocess.stdin.pipe(process.stdout);\n"
  },
  {
    "path": "test/fixtures/verbose-script.js",
    "content": "#!/usr/bin/env node\nimport {$} from '../../index.js';\n\nconst $$ = $({stdio: 'inherit'});\nawait $$`node -e console.error(1)`;\nawait $$({reject: false})`node -e process.exit(2)`;\n"
  },
  {
    "path": "test/fixtures/wait-fail.js",
    "content": "#!/usr/bin/env node\nimport process from 'node:process';\nimport {setTimeout} from 'node:timers/promises';\n\nawait setTimeout(1e3);\nprocess.exitCode = 2;\n"
  },
  {
    "path": "test/fixtures/worker.js",
    "content": "#!/usr/bin/env node\nimport {workerData, parentPort} from 'node:worker_threads';\nimport {spawnParentProcess} from '../helpers/nested.js';\n\ntry {\n\tconst result = await spawnParentProcess(workerData);\n\tparentPort.postMessage(result);\n} catch (error) {\n\tparentPort.postMessage(error);\n}\n"
  },
  {
    "path": "test/helpers/convert.js",
    "content": "import {text} from 'node:stream/consumers';\nimport {finished} from 'node:stream/promises';\nimport getStream from 'get-stream';\nimport isPlainObj from 'is-plain-obj';\nimport {execa} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\n\nexport const arrayFromAsync = async (asyncIterable, lines = []) => {\n\tfor await (const line of asyncIterable) {\n\t\tlines.push(line);\n\t}\n\n\treturn lines;\n};\n\nexport const finishedStream = stream => finished(stream, {cleanup: true});\n\nexport const assertWritableAborted = (t, writable) => {\n\tt.false(writable.writableEnded);\n\tt.is(writable.errored, null);\n\tt.false(writable.writable);\n};\n\nexport const assertReadableAborted = (t, readable) => {\n\tt.false(readable.readableEnded);\n\tt.is(readable.errored, null);\n\tt.false(readable.readable);\n};\n\nexport const assertProcessNormalExit = (t, error, exitCode = 0) => {\n\tt.is(error.exitCode, exitCode);\n\tt.is(error.signal, undefined);\n};\n\nexport const assertStreamOutput = async (t, stream, expectedOutput = foobarString) => {\n\tt.is(await text(stream), expectedOutput);\n};\n\nexport const assertStreamDataEvents = async (t, stream, expectedOutput = foobarString) => {\n\tt.is(await getStream(stream), expectedOutput);\n};\n\nexport const assertIterableChunks = async (t, asyncIterable, expectedChunks) => {\n\tt.deepEqual(await arrayFromAsync(asyncIterable), expectedChunks);\n};\n\nexport const assertStreamChunks = async (t, stream, expectedOutput) => {\n\tt.deepEqual(await stream.toArray(), expectedOutput);\n};\n\nexport const assertSubprocessOutput = async (t, subprocess, expectedOutput = foobarString, fdNumber = 1) => {\n\tconst result = await subprocess;\n\tt.deepEqual(result.stdio[fdNumber], expectedOutput);\n};\n\nexport const assertStreamError = (t, stream, error) => assertPromiseError(t, finishedStream(stream), error);\n\nexport const assertStreamReadError = (t, stream, error) => assertPromiseError(t, text(stream), error);\n\nexport const assertSubprocessError = (t, subprocess, error) => assertPromiseError(t, subprocess, error);\n\nexport const assertPromiseError = async (t, promise, error) => {\n\tconst thrownError = await t.throwsAsync(promise);\n\n\tif (isPlainObj(error) && error.cause !== undefined) {\n\t\tt.is(thrownError.cause, error.cause);\n\t} else {\n\t\tt.is(thrownError, error);\n\t}\n\n\treturn thrownError;\n};\n\nexport const getReadableSubprocess = (output = foobarString, options = {}) => execa('noop-fd.js', ['1', output], options);\n\nexport const getWritableSubprocess = () => execa('noop-stdin-fd.js', ['2']);\n\nexport const getReadWriteSubprocess = options => execa('stdin.js', options);\n"
  },
  {
    "path": "test/helpers/duplex.js",
    "content": "import {Transform} from 'node:stream';\nimport {setTimeout, scheduler} from 'node:timers/promises';\nimport {callbackify} from 'node:util';\nimport {foobarObject, foobarString} from './input.js';\nimport {casedSuffix, prefix, suffix} from './generator.js';\n\nconst getDuplex = (transform, encoding, outerObjectMode) => objectMode => ({\n\ttransform: new Transform({\n\t\ttransform: callbackify(async function (value) {\n\t\t\treturn transform.call(this, value);\n\t\t}),\n\t\tobjectMode,\n\t\tencoding,\n\t}),\n\tobjectMode: outerObjectMode,\n});\n\nexport const addNoopDuplex = (duplex, addNoopTransform, objectMode) => addNoopTransform\n\t? [duplex, noopDuplex(objectMode)]\n\t: [duplex];\n\nexport const noopDuplex = getDuplex(value => value);\n\nexport const serializeDuplex = getDuplex(object => JSON.stringify(object));\n\nexport const getOutputDuplex = (input, outerObjectMode) => getDuplex(() => input, undefined, outerObjectMode);\n\nexport const outputObjectDuplex = () => getOutputDuplex(foobarObject)(true);\n\nexport const getOutputsDuplex = inputs => getDuplex(function () {\n\tfor (const input of inputs) {\n\t\tthis.push(input);\n\t}\n});\n\nexport const noYieldDuplex = getDuplex(() => {});\n\nexport const multipleYieldDuplex = getDuplex(async function (line) {\n\tthis.push(prefix);\n\tawait scheduler.yield();\n\tthis.push(line);\n\tawait scheduler.yield();\n\tthis.push(suffix);\n});\n\nexport const uppercaseEncodingDuplex = (encoding, outerObjectMode) => getDuplex(buffer => buffer.toString().toUpperCase(), encoding, outerObjectMode);\n\nexport const uppercaseBufferDuplex = uppercaseEncodingDuplex();\n\nexport const throwingDuplex = cause => getDuplex(() => {\n\tthrow cause;\n});\n\nexport const appendDuplex = getDuplex(string => `${string}${casedSuffix}`);\n\nexport const timeoutDuplex = timeout => getDuplex(async () => {\n\tawait setTimeout(timeout);\n\treturn foobarString;\n});\n"
  },
  {
    "path": "test/helpers/early-error.js",
    "content": "import {execa, execaSync} from '../../index.js';\n\nexport const earlyErrorOptions = {detached: 'true'};\nexport const getEarlyErrorSubprocess = options => execa('empty.js', {...earlyErrorOptions, ...options});\nexport const earlyErrorOptionsSync = {maxBuffer: false};\nexport const getEarlyErrorSubprocessSync = options => execaSync('empty.js', {...earlyErrorOptionsSync, ...options});\n\nexport const expectedEarlyError = {code: 'ERR_INVALID_ARG_TYPE'};\nexport const expectedEarlyErrorSync = {code: 'ERR_OUT_OF_RANGE'};\n"
  },
  {
    "path": "test/helpers/encoding.js",
    "content": "const textEncoder = new TextEncoder();\n\nexport const multibyteChar = '\\u{1F984}';\nexport const multibyteString = `${multibyteChar}${multibyteChar}`;\nexport const multibyteUint8Array = textEncoder.encode(multibyteString);\nexport const breakingLength = multibyteUint8Array.length * 0.75;\nexport const brokenSymbol = '\\uFFFD';\n"
  },
  {
    "path": "test/helpers/file-path.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\n\nexport const getAbsolutePath = file => ({file});\nexport const getRelativePath = filePath => ({file: path.relative('.', filePath)});\n// Defined as getter so call to toString is not cached\nexport const getDenoNodePath = () => Object.freeze({\n\t__proto__: String.prototype,\n\ttoString() {\n\t\treturn process.execPath;\n\t},\n\tget length() {\n\t\treturn this.toString().length;\n\t},\n});\n"
  },
  {
    "path": "test/helpers/fixtures-directory.js",
    "content": "import path from 'node:path';\nimport process from 'node:process';\nimport {fileURLToPath} from 'node:url';\nimport logProcessErrors from 'log-process-errors';\nimport pathKey from 'path-key';\n\n// Make tests fail if any warning (such as a deprecation warning) is emitted\nlogProcessErrors({\n\tonError(error, event) {\n\t\tif (event === 'warning') {\n\t\t\tthrow error;\n\t\t}\n\t},\n});\n\nexport const PATH_KEY = pathKey();\nexport const FIXTURES_DIRECTORY_URL = new URL('../fixtures/', import.meta.url);\n// @todo: use import.meta.dirname after dropping support for Node <20.11.0\nexport const FIXTURES_DIRECTORY = path.resolve(fileURLToPath(FIXTURES_DIRECTORY_URL));\n\n// Add the fixtures directory to PATH so fixtures can be executed without adding\n// `node`. This is only meant to make writing tests simpler.\nexport const setFixtureDirectory = () => {\n\tprocess.env[PATH_KEY] = FIXTURES_DIRECTORY + path.delimiter + process.env[PATH_KEY];\n};\n\n"
  },
  {
    "path": "test/helpers/fs.js",
    "content": "import {createReadStream, createWriteStream} from 'node:fs';\nimport process from 'node:process';\n\nexport const getReadStream = fdNumber => fdNumber === 0\n\t? process.stdin\n\t: createReadStream(undefined, {fd: fdNumber});\n\nexport const getWriteStream = fdNumber => {\n\tif (fdNumber === 1) {\n\t\treturn process.stdout;\n\t}\n\n\tif (fdNumber === 2) {\n\t\treturn process.stderr;\n\t}\n\n\treturn createWriteStream(undefined, {fd: fdNumber});\n};\n"
  },
  {
    "path": "test/helpers/generator.js",
    "content": "import {\n\tsetImmediate,\n\tsetInterval,\n\tsetTimeout,\n\tscheduler,\n} from 'node:timers/promises';\nimport {foobarObject, foobarString} from './input.js';\n\nconst getGenerator = transform => (objectMode, binary, preserveNewlines) => ({\n\ttransform,\n\tobjectMode,\n\tbinary,\n\tpreserveNewlines,\n});\n\nexport const addNoopGenerator = (transform, addNoopTransform, objectMode, binary) => addNoopTransform\n\t? [transform, noopGenerator(objectMode, binary)]\n\t: [transform];\n\nexport const noopGenerator = getGenerator(function * (value) {\n\tyield value;\n});\n\nexport const noopAsyncGenerator = getGenerator(async function * (value) {\n\tyield value;\n});\n\nexport const serializeGenerator = getGenerator(function * (object) {\n\tyield JSON.stringify(object);\n});\n\nexport const getOutputGenerator = input => getGenerator(function * () {\n\tyield input;\n});\n\nexport const outputObjectGenerator = () => getOutputGenerator(foobarObject)(true);\n\nexport const getOutputAsyncGenerator = input => getGenerator(async function * () {\n\tyield input;\n});\n\nexport const getOutputsGenerator = inputs => getGenerator(function * () {\n\tyield * inputs;\n});\n\nexport const getOutputsAsyncGenerator = inputs => getGenerator(async function * () {\n\tfor (const input of inputs) {\n\t\tyield input;\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait setImmediate();\n\t}\n});\n\nconst noYieldTransform = function * () {};\n\nexport const noYieldGenerator = getGenerator(noYieldTransform);\n\nexport const prefix = '> ';\nexport const suffix = ' <';\n\nexport const multipleYieldGenerator = getGenerator(async function * (line = foobarString) {\n\tyield prefix;\n\tawait scheduler.yield();\n\tyield line;\n\tawait scheduler.yield();\n\tyield suffix;\n});\n\nexport const convertTransformToFinal = (transform, final) => {\n\tif (!final) {\n\t\treturn transform;\n\t}\n\n\tconst generatorOptions = typeof transform === 'function' ? {transform} : transform;\n\treturn ({...generatorOptions, transform: noYieldTransform, final: generatorOptions.transform});\n};\n\nexport const infiniteGenerator = getGenerator(async function * () {\n\tfor await (const value of setInterval(100, foobarString)) {\n\t\tyield value;\n\t}\n});\n\nconst textDecoder = new TextDecoder();\nconst textEncoder = new TextEncoder();\n\nexport const uppercaseBufferGenerator = getGenerator(function * (buffer) {\n\tyield textEncoder.encode(textDecoder.decode(buffer).toUpperCase());\n});\n\nexport const uppercaseGenerator = getGenerator(function * (string) {\n\tyield string.toUpperCase();\n});\n\n// eslint-disable-next-line require-yield\nexport const throwingGenerator = error => getGenerator(function * () {\n\tthrow error;\n});\n\nexport const appendGenerator = getGenerator(function * (string) {\n\tyield `${string}${casedSuffix}`;\n});\n\nexport const appendAsyncGenerator = getGenerator(async function * (string) {\n\tyield `${string}${casedSuffix}`;\n});\n\nexport const casedSuffix = 'k';\n\nexport const resultGenerator = inputs => getGenerator(function * (input) {\n\tinputs.push(input);\n\tyield input;\n});\n\nexport const timeoutGenerator = timeout => getGenerator(async function * () {\n\tawait setTimeout(timeout);\n\tyield foobarString;\n});\n"
  },
  {
    "path": "test/helpers/graceful.js",
    "content": "import {setTimeout} from 'node:timers/promises';\n\n// Combines `util.aborted()` and `events.addAbortListener()`: promise-based and cleaned up with a stop signal\nexport const onAbortedSignal = async signal => {\n\ttry {\n\t\tawait setTimeout(1e8, undefined, {signal});\n\t} catch {}\n};\n"
  },
  {
    "path": "test/helpers/input.js",
    "content": "import {Buffer} from 'node:buffer';\nimport {inspect} from 'node:util';\n\nconst textEncoder = new TextEncoder();\n\nexport const foobarString = 'foobar';\nexport const foobarArray = ['foo', 'bar'];\nexport const foobarUint8Array = textEncoder.encode(foobarString);\nexport const foobarArrayBuffer = foobarUint8Array.buffer;\nexport const foobarUint16Array = new Uint16Array(foobarArrayBuffer);\nexport const foobarBuffer = Buffer.from(foobarString);\nconst foobarUtf16Buffer = Buffer.from(foobarString, 'utf16le');\nexport const foobarUtf16Uint8Array = new Uint8Array(foobarUtf16Buffer);\nexport const foobarDataView = new DataView(foobarArrayBuffer);\nexport const foobarHex = foobarBuffer.toString('hex');\nexport const foobarUppercase = foobarString.toUpperCase();\nexport const foobarUppercaseUint8Array = textEncoder.encode(foobarUppercase);\nexport const foobarUppercaseHex = Buffer.from(foobarUppercase).toString('hex');\nexport const foobarObject = {foo: 'bar'};\nexport const foobarObjectString = JSON.stringify(foobarObject);\nexport const foobarObjectInspect = inspect(foobarObject);\n"
  },
  {
    "path": "test/helpers/ipc.js",
    "content": "import {getEachMessage} from '../../index.js';\nimport {foobarString} from './input.js';\n\n// @todo: replace with Array.fromAsync(subprocess.getEachMessage()) after dropping support for Node <22.0.0\nexport const iterateAllMessages = async subprocess => {\n\tconst messages = [];\n\tfor await (const message of subprocess.getEachMessage()) {\n\t\tmessages.push(message);\n\t}\n\n\treturn messages;\n};\n\nexport const subprocessGetFirst = async subprocess => {\n\tconst [firstMessage] = await iterateAllMessages(subprocess);\n\treturn firstMessage;\n};\n\nexport const getFirst = async () => {\n\t// eslint-disable-next-line no-unreachable-loop\n\tfor await (const message of getEachMessage()) {\n\t\treturn message;\n\t}\n};\n\nexport const subprocessGetOne = (subprocess, options) => subprocess.getOneMessage(options);\n\nexport const alwaysPass = () => true;\n\n// `process.send()` can fail due to I/O errors.\n// However, I/O errors are seldom and hard to trigger predictably.\n// So we mock them.\nexport const mockSendIoError = anyProcess => {\n\tconst error = new Error(foobarString);\n\tanyProcess.send = () => {\n\t\tthrow error;\n\t};\n\n\treturn error;\n};\n"
  },
  {
    "path": "test/helpers/lines.js",
    "content": "import {Buffer} from 'node:buffer';\nimport {execa} from '../../index.js';\n\nconst textEncoder = new TextEncoder();\n\nexport const stringsToUint8Arrays = strings => strings.map(string => stringToUint8Arrays(string, true));\n\nexport const stringToUint8Arrays = (string, isUint8Array) => isUint8Array\n\t? textEncoder.encode(string)\n\t: string;\n\nexport const simpleFull = 'aaa\\nbbb\\nccc';\nexport const simpleChunks = [simpleFull];\nexport const simpleFullUint8Array = textEncoder.encode(simpleFull);\nexport const simpleChunksUint8Array = [simpleFullUint8Array];\nconst simpleFullBuffer = Buffer.from(simpleFull);\nexport const simpleFullHex = simpleFullBuffer.toString('hex');\nexport const simpleChunksBuffer = [simpleFullBuffer];\nexport const simpleFullUtf16Inverted = simpleFullBuffer.toString('utf16le');\nconst simpleFullUtf16Buffer = Buffer.from(simpleFull, 'utf16le');\nexport const simpleFullUtf16Uint8Array = new Uint8Array(simpleFullUtf16Buffer);\nexport const simpleFullEnd = `${simpleFull}\\n`;\nconst simpleFullEndBuffer = Buffer.from(simpleFullEnd);\nexport const simpleFullEndChunks = [simpleFullEnd];\nexport const simpleFullEndUtf16Inverted = simpleFullEndBuffer.toString('utf16le');\nexport const simpleLines = ['aaa\\n', 'bbb\\n', 'ccc'];\nexport const simpleFullEndLines = ['aaa\\n', 'bbb\\n', 'ccc\\n'];\nexport const noNewlinesFull = 'aaabbbccc';\nexport const noNewlinesChunks = ['aaa', 'bbb', 'ccc'];\nexport const complexFull = '\\naaa\\r\\nbbb\\n\\nccc';\nconst complexFullBuffer = Buffer.from(complexFull);\nconst complexFullUtf16Buffer = Buffer.from(complexFull, 'utf16le');\nexport const complexFullUtf16 = complexFullUtf16Buffer.toString();\nexport const complexFullUtf16Uint8Array = new Uint8Array(complexFullUtf16Buffer);\nexport const singleComplexBuffer = [complexFullBuffer];\nexport const singleComplexUtf16Buffer = [complexFullUtf16Buffer];\nexport const singleComplexUint8Array = textEncoder.encode(complexFull);\nexport const singleComplexHex = complexFullBuffer.toString('hex');\nexport const complexChunksEnd = ['\\n', 'aaa\\r\\n', 'bbb\\n', '\\n', 'ccc'];\nexport const complexChunks = ['', 'aaa', 'bbb', '', 'ccc'];\nexport const singleFull = 'aaa';\nexport const singleFullEnd = `${singleFull}\\n`;\n\nexport const getSimpleChunkSubprocessAsync = options => getSimpleChunkSubprocess(execa, options);\nexport const getSimpleChunkSubprocess = (execaMethod, options) => execaMethod('noop-fd.js', ['1', simpleFull], {lines: true, ...options});\n"
  },
  {
    "path": "test/helpers/listeners.js",
    "content": "import process from 'node:process';\n\nexport const assertMaxListeners = t => {\n\tlet warning;\n\tconst captureWarning = warningArgument => {\n\t\twarning = warningArgument;\n\t};\n\n\tprocess.once('warning', captureWarning);\n\treturn () => {\n\t\tt.is(warning, undefined);\n\t\tprocess.removeListener('warning', captureWarning);\n\t};\n};\n"
  },
  {
    "path": "test/helpers/map.js",
    "content": "import {\n\taddNoopGenerator,\n\tnoopGenerator,\n\tserializeGenerator,\n\tuppercaseBufferGenerator,\n\tuppercaseGenerator,\n\tgetOutputGenerator,\n\toutputObjectGenerator,\n\tgetOutputsGenerator,\n\tnoYieldGenerator,\n\tmultipleYieldGenerator,\n\tthrowingGenerator,\n\tappendGenerator,\n\ttimeoutGenerator,\n} from './generator.js';\nimport {\n\taddNoopDuplex,\n\tnoopDuplex,\n\tserializeDuplex,\n\tuppercaseBufferDuplex,\n\tgetOutputDuplex,\n\toutputObjectDuplex,\n\tgetOutputsDuplex,\n\tnoYieldDuplex,\n\tmultipleYieldDuplex,\n\tthrowingDuplex,\n\tappendDuplex,\n\ttimeoutDuplex,\n} from './duplex.js';\nimport {\n\taddNoopWebTransform,\n\tnoopWebTransform,\n\tserializeWebTransform,\n\tuppercaseBufferWebTransform,\n\tgetOutputWebTransform,\n\toutputObjectWebTransform,\n\tgetOutputsWebTransform,\n\tnoYieldWebTransform,\n\tmultipleYieldWebTransform,\n\tthrowingWebTransform,\n\tappendWebTransform,\n\ttimeoutWebTransform,\n} from './web-transform.js';\n\nexport const generatorsMap = {\n\tgenerator: {\n\t\taddNoop: addNoopGenerator,\n\t\tnoop: noopGenerator,\n\t\tserialize: serializeGenerator,\n\t\tuppercaseBuffer: uppercaseBufferGenerator,\n\t\tuppercase: uppercaseGenerator,\n\t\tgetOutput: getOutputGenerator,\n\t\toutputObject: outputObjectGenerator,\n\t\tgetOutputs: getOutputsGenerator,\n\t\tnoYield: noYieldGenerator,\n\t\tmultipleYield: multipleYieldGenerator,\n\t\tthrowing: throwingGenerator,\n\t\tappend: appendGenerator,\n\t\ttimeout: timeoutGenerator,\n\t},\n\tduplex: {\n\t\taddNoop: addNoopDuplex,\n\t\tnoop: noopDuplex,\n\t\tserialize: serializeDuplex,\n\t\tuppercaseBuffer: uppercaseBufferDuplex,\n\t\tuppercase: uppercaseBufferDuplex,\n\t\tgetOutput: getOutputDuplex,\n\t\toutputObject: outputObjectDuplex,\n\t\tgetOutputs: getOutputsDuplex,\n\t\tnoYield: noYieldDuplex,\n\t\tmultipleYield: multipleYieldDuplex,\n\t\tthrowing: throwingDuplex,\n\t\tappend: appendDuplex,\n\t\ttimeout: timeoutDuplex,\n\t},\n\twebTransform: {\n\t\taddNoop: addNoopWebTransform,\n\t\tnoop: noopWebTransform,\n\t\tserialize: serializeWebTransform,\n\t\tuppercaseBuffer: uppercaseBufferWebTransform,\n\t\tuppercase: uppercaseBufferWebTransform,\n\t\tgetOutput: getOutputWebTransform,\n\t\toutputObject: outputObjectWebTransform,\n\t\tgetOutputs: getOutputsWebTransform,\n\t\tnoYield: noYieldWebTransform,\n\t\tmultipleYield: multipleYieldWebTransform,\n\t\tthrowing: throwingWebTransform,\n\t\tappend: appendWebTransform,\n\t\ttimeout: timeoutWebTransform,\n\t},\n};\n"
  },
  {
    "path": "test/helpers/max-buffer.js",
    "content": "import {execa, execaSync} from '../../index.js';\n\nexport const maxBuffer = 10;\n\nexport const assertErrorMessage = (t, shortMessage, {execaMethod = execa, length = maxBuffer, fdNumber = 1, unit = 'characters'} = {}) => {\n\tconst [expectedStreamName, expectedUnit] = execaMethod === execaSync\n\t\t? ['output', 'bytes']\n\t\t: [STREAM_NAMES[fdNumber], unit];\n\tt.true(shortMessage.includes(`${expectedStreamName} was larger than ${length} ${expectedUnit}`));\n};\n\nconst STREAM_NAMES = ['stdin', 'stdout', 'stderr', 'stdio[3]'];\n"
  },
  {
    "path": "test/helpers/nested.js",
    "content": "import {once} from 'node:events';\nimport {Worker} from 'node:worker_threads';\nimport {execa} from '../../index.js';\nimport {FIXTURES_DIRECTORY_URL} from './fixtures-directory.js';\n\nconst WORKER_URL = new URL('worker.js', FIXTURES_DIRECTORY_URL);\nconst NESTED_URL = new URL('nested/', FIXTURES_DIRECTORY_URL);\n\n// Like `execa(file, commandArguments, options)` but spawns inside another parent process.\n// This is useful when testing logic where Execa modifies the global state.\n// For example, when it prints to the console, with the `verbose` option.\n// The parent process calls `execa(options.parentFixture, parentOptions)`\n// When `options.isSync` is `true`, `execaSync()` is called instead.\n// When `options.worker` is `true`, the whole flow happens inside a Worker.\nexport const nestedSubprocess = async (file, commandArguments, options, parentOptions) => {\n\tconst result = await nestedInstance(file, commandArguments, options, parentOptions);\n\tconst nestedResult = result.ipcOutput[0];\n\treturn {...result, nestedResult};\n};\n\nexport const nestedInstance = (file, commandArguments, options, parentOptions) => {\n\t[commandArguments, options = {}, parentOptions = {}] = Array.isArray(commandArguments)\n\t\t? [commandArguments, options, parentOptions]\n\t\t: [[], commandArguments, options];\n\tconst {\n\t\tparentFixture = 'nested.js',\n\t\tworker = false,\n\t\tisSync = false,\n\t\toptionsFixture,\n\t\toptionsInput = {},\n\t\t...otherOptions\n\t} = options;\n\tconst normalizedArguments = {\n\t\tparentFixture,\n\t\tparentOptions,\n\t\tisSync,\n\t\tfile,\n\t\tcommandArguments,\n\t\toptions: otherOptions,\n\t\toptionsFixture,\n\t\toptionsInput,\n\t};\n\treturn worker\n\t\t? spawnWorker(normalizedArguments)\n\t\t: spawnParentProcess(normalizedArguments);\n};\n\nconst spawnWorker = async workerData => {\n\tconst worker = new Worker(WORKER_URL, {workerData});\n\tconst [result] = await once(worker, 'message');\n\tif (result instanceof Error) {\n\t\tthrow result;\n\t}\n\n\treturn result;\n};\n\nexport const spawnParentProcess = ({parentFixture, parentOptions, ...ipcInput}) => execa(parentFixture, {...parentOptions, ipcInput});\n\n// Some subprocess options cannot be serialized between processes.\n// For those, we pass a fixture filename instead, which dynamically creates the options.\nexport const getNestedOptions = async (options, optionsFixture, optionsInput) => {\n\tif (optionsFixture === undefined) {\n\t\treturn options;\n\t}\n\n\tconst {getOptions} = await import(new URL(optionsFixture, NESTED_URL));\n\treturn {...options, ...getOptions({...options, ...optionsInput})};\n};\n"
  },
  {
    "path": "test/helpers/node-version.js",
    "content": "import {version} from 'node:process';\n\nexport const majorNodeVersion = Number(version.split('.')[0].slice(1));\n"
  },
  {
    "path": "test/helpers/override-promise.js",
    "content": "// Can't use `test.before`, because `ava` needs `Promise`.\nconst nativePromise = Promise;\nglobalThis.Promise = class BrokenPromise {\n\tthen() { // eslint-disable-line unicorn/no-thenable\n\t\tthrow new Error('error');\n\t}\n};\n\nexport function restorePromise() {\n\tglobalThis.Promise = nativePromise;\n}\n"
  },
  {
    "path": "test/helpers/parallel.js",
    "content": "import isInCi from 'is-in-ci';\n\nexport const PARALLEL_COUNT = isInCi ? 10 : 100;\n"
  },
  {
    "path": "test/helpers/pipe.js",
    "content": "export const assertPipeError = async (t, pipePromise, message) => {\n\tconst error = await t.throwsAsync(pipePromise);\n\n\tt.is(error.command, 'source.pipe(destination)');\n\tt.is(error.escapedCommand, error.command);\n\n\tt.is(typeof error.cwd, 'string');\n\tt.true(error.failed);\n\tt.false(error.timedOut);\n\tt.false(error.isCanceled);\n\tt.false(error.isTerminated);\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, undefined);\n\tt.is(error.signalDescription, undefined);\n\tt.is(error.stdout, undefined);\n\tt.is(error.stderr, undefined);\n\tt.is(error.all, undefined);\n\tt.deepEqual(error.stdio, Array.from({length: error.stdio.length}));\n\tt.deepEqual(error.pipedFrom, []);\n\n\tt.true(error.shortMessage.includes(`Command failed: ${error.command}`));\n\tt.true(error.shortMessage.includes(error.originalMessage));\n\tt.true(error.message.includes(error.shortMessage));\n\n\tt.true(error.originalMessage.includes(message));\n};\n"
  },
  {
    "path": "test/helpers/run.js",
    "content": "import {execa, execaSync, $} from '../../index.js';\n\nexport const runExeca = (file, options) => execa(file, options);\nexport const runExecaSync = (file, options) => execaSync(file, options);\nexport const runScript = (file, options) => $(options)`${file}`;\nexport const runScriptSync = (file, options) => $(options).sync`${file}`;\n"
  },
  {
    "path": "test/helpers/stdio.js",
    "content": "import process, {platform} from 'node:process';\nimport {noopReadable} from './stream.js';\n\nexport const identity = value => value;\n\nexport const getStdio = (fdNumberOrName, stdioOption, length = 3) => {\n\tif (typeof fdNumberOrName === 'string') {\n\t\treturn {[fdNumberOrName]: stdioOption};\n\t}\n\n\tconst stdio = Array.from({length}).fill('pipe');\n\tstdio[fdNumberOrName] = stdioOption;\n\treturn {stdio};\n};\n\nexport const fullStdio = getStdio(3, 'pipe');\nexport const fullReadableStdio = () => getStdio(3, ['pipe', noopReadable()]);\n\nexport const STANDARD_STREAMS = [process.stdin, process.stdout, process.stderr];\n\nexport const prematureClose = {code: 'ERR_STREAM_PREMATURE_CLOSE'};\n\nconst isWindows = platform === 'win32';\n\nexport const assertEpipe = (t, stderr, fdNumber = 1) => {\n\tif (fdNumber === 1 && !isWindows) {\n\t\tt.true(stderr.includes('EPIPE'));\n\t}\n};\n\nexport const parseStdioOption = stdioOption => {\n\tconst optionValue = JSON.parse(stdioOption);\n\tif (typeof optionValue === 'string' && optionValue in process) {\n\t\treturn process[optionValue];\n\t}\n\n\tif (Array.isArray(optionValue) && typeof optionValue[0] === 'string' && optionValue[0] in process) {\n\t\treturn [process[optionValue[0]], ...optionValue.slice(1)];\n\t}\n\n\treturn optionValue;\n};\n"
  },
  {
    "path": "test/helpers/stream.js",
    "content": "import {\n\tReadable,\n\tWritable,\n\tPassThrough,\n\tgetDefaultHighWaterMark,\n} from 'node:stream';\nimport {foobarString} from './input.js';\n\nexport const noopReadable = () => new Readable({read() {}});\nexport const noopWritable = () => new Writable({write() {}});\nexport const noopDuplex = () => new PassThrough().resume();\nexport const simpleReadable = () => Readable.from([foobarString]);\n\nexport const defaultHighWaterMark = getDefaultHighWaterMark(false);\nexport const defaultObjectHighWaterMark = getDefaultHighWaterMark(true);\n"
  },
  {
    "path": "test/helpers/verbose.js",
    "content": "import {platform} from 'node:process';\nimport {stripVTControlCharacters} from 'node:util';\nimport {replaceSymbols} from 'figures';\nimport {foobarString} from './input.js';\nimport {nestedSubprocess} from './nested.js';\n\nconst isWindows = platform === 'win32';\nexport const QUOTE = isWindows ? '\"' : '\\'';\n\nexport const runErrorSubprocess = async (t, verbose, isSync = false, expectExitCode = true) => {\n\tconst {stderr, nestedResult} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose, isSync});\n\tt.true(nestedResult instanceof Error);\n\tif (expectExitCode) {\n\t\tt.true(stderr.includes('exit code 2'));\n\t}\n\n\treturn stderr;\n};\n\nexport const runWarningSubprocess = async (t, isSync) => {\n\tconst {stderr, nestedResult} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose: 'short', reject: false, isSync});\n\tt.true(nestedResult instanceof Error);\n\tt.true(stderr.includes('exit code 2'));\n\treturn stderr;\n};\n\nexport const runEarlyErrorSubprocess = async (t, isSync) => {\n\tconst {stderr, nestedResult} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short', cwd: true, isSync});\n\tt.true(nestedResult instanceof Error);\n\tt.true(nestedResult.message.startsWith('The \"cwd\" option must'));\n\treturn stderr;\n};\n\nexport const runVerboseSubprocess = ({\n\tisSync = false,\n\ttype,\n\teventProperty,\n\toptionName,\n\terrorMessage,\n\tfdNumber,\n\tsecondFdNumber,\n\toptionsFixture = 'custom-event.js',\n\toutput = '. .',\n\t...options\n}) => nestedSubprocess('noop-verbose.js', [output], {\n\tipc: !isSync,\n\toptionsFixture,\n\toptionsInput: {\n\t\ttype,\n\t\teventProperty,\n\t\toptionName,\n\t\terrorMessage,\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t},\n\tisSync,\n\t...options,\n});\n\nexport const getCommandLine = stderr => getCommandLines(stderr)[0];\nexport const getCommandLines = stderr => getNormalizedLines(stderr).filter(line => isCommandLine(line));\nconst isCommandLine = line => line.includes(' $ ') || line.includes(' | ');\nexport const getOutputLine = stderr => getOutputLines(stderr)[0];\nexport const getOutputLines = stderr => getNormalizedLines(stderr).filter(line => isOutputLine(line));\nconst isOutputLine = line => line.includes(']   ');\nexport const getIpcLine = stderr => getIpcLines(stderr)[0];\nexport const getIpcLines = stderr => getNormalizedLines(stderr).filter(line => isIpcLine(line));\nconst isIpcLine = line => line.includes(' * ');\nexport const getErrorLine = stderr => getErrorLines(stderr)[0];\nexport const getErrorLines = stderr => getNormalizedLines(stderr).filter(line => isErrorLine(line));\nconst isErrorLine = line => (line.includes(' × ') || line.includes(' ‼ ')) && !isCompletionLine(line);\nexport const getCompletionLine = stderr => getCompletionLines(stderr)[0];\nexport const getCompletionLines = stderr => getNormalizedLines(stderr).filter(line => isCompletionLine(line));\nconst isCompletionLine = line => line.includes('(done in');\nexport const getNormalizedLine = stderr => getNormalizedLines(stderr)[0];\nexport const getNormalizedLines = stderr => splitLines(normalizeStderr(stderr));\nconst splitLines = stderr => stderr.split('\\n');\n\nconst normalizeStderr = stderr => replaceSymbols(normalizeDuration(normalizeTimestamp(stripVTControlCharacters(stderr))), {useFallback: true});\nexport const testTimestamp = '[00:00:00.000]';\nconst normalizeTimestamp = stderr => stderr.replaceAll(/^\\[\\d{2}:\\d{2}:\\d{2}.\\d{3}]/gm, testTimestamp);\nconst normalizeDuration = stderr => stderr.replaceAll(/\\(done in [^)]+\\)/g, '(done in 0ms)');\n\nexport const getVerboseOption = (isVerbose, verbose = 'short') => ({verbose: isVerbose ? verbose : 'none'});\n\nexport const stdoutNoneOption = {stdout: 'none'};\nexport const stdoutShortOption = {stdout: 'short'};\nexport const stdoutFullOption = {stdout: 'full'};\nexport const stderrNoneOption = {stderr: 'none'};\nexport const stderrShortOption = {stderr: 'short'};\nexport const stderrFullOption = {stderr: 'full'};\nexport const fd3NoneOption = {fd3: 'none'};\nexport const fd3ShortOption = {fd3: 'short'};\nexport const fd3FullOption = {fd3: 'full'};\nexport const ipcNoneOption = {ipc: 'none'};\nexport const ipcShortOption = {ipc: 'short'};\nexport const ipcFullOption = {ipc: 'full'};\n"
  },
  {
    "path": "test/helpers/wait.js",
    "content": "import {getStdio} from '../helpers/stdio.js';\nimport {noopGenerator} from '../helpers/generator.js';\n\nexport const endOptionStream = ({stream}) => {\n\tstream.end();\n};\n\nexport const destroyOptionStream = ({stream, error}) => {\n\tstream.destroy(error);\n};\n\nexport const destroySubprocessStream = ({subprocess, fdNumber, error}) => {\n\tsubprocess.stdio[fdNumber].destroy(error);\n};\n\nexport const getStreamStdio = (fdNumber, stream, useTransform) =>\n\tgetStdio(fdNumber, [stream, useTransform ? noopGenerator(false) : 'pipe']);\n"
  },
  {
    "path": "test/helpers/web-transform.js",
    "content": "import {setTimeout, scheduler} from 'node:timers/promises';\nimport {foobarObject, foobarString} from './input.js';\nimport {casedSuffix, prefix, suffix} from './generator.js';\n\nconst getWebTransform = transform => objectMode => ({\n\ttransform: new TransformStream({transform}),\n\tobjectMode,\n});\n\nexport const addNoopWebTransform = (webTransform, addNoopTransform, objectMode) => addNoopTransform\n\t? [webTransform, noopWebTransform(objectMode)]\n\t: [webTransform];\n\nexport const noopWebTransform = getWebTransform((value, controller) => {\n\tcontroller.enqueue(value);\n});\n\nexport const serializeWebTransform = getWebTransform((object, controller) => {\n\tcontroller.enqueue(JSON.stringify(object));\n});\n\nexport const getOutputWebTransform = (input, outerObjectMode) => getWebTransform((_, controller) => {\n\tcontroller.enqueue(input);\n}, undefined, outerObjectMode);\n\nexport const outputObjectWebTransform = () => getOutputWebTransform(foobarObject)(true);\n\nexport const getOutputsWebTransform = inputs => getWebTransform((_, controller) => {\n\tfor (const input of inputs) {\n\t\tcontroller.enqueue(input);\n\t}\n});\n\nexport const noYieldWebTransform = getWebTransform(() => {});\n\nexport const multipleYieldWebTransform = getWebTransform(async (line, controller) => {\n\tcontroller.enqueue(prefix);\n\tawait scheduler.yield();\n\tcontroller.enqueue(line);\n\tawait scheduler.yield();\n\tcontroller.enqueue(suffix);\n});\n\nexport const uppercaseBufferWebTransform = getWebTransform((string, controller) => {\n\tcontroller.enqueue(string.toString().toUpperCase());\n});\n\nexport const throwingWebTransform = cause => getWebTransform(() => {\n\tthrow cause;\n});\n\nexport const appendWebTransform = getWebTransform((string, controller) => {\n\tcontroller.enqueue(`${string}${casedSuffix}`);\n});\n\nexport const timeoutWebTransform = timeout => getWebTransform(async (_, controller) => {\n\tawait setTimeout(timeout);\n\tcontroller.enqueue(foobarString);\n});\n"
  },
  {
    "path": "test/io/input-option.js",
    "content": "import {Writable} from 'node:stream';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\trunExeca,\n\trunExecaSync,\n\trunScript,\n\trunScriptSync,\n} from '../helpers/run.js';\nimport {\n\tfoobarUint8Array,\n\tfoobarBuffer,\n\tfoobarArrayBuffer,\n\tfoobarUint16Array,\n\tfoobarDataView,\n} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testInput = async (t, input, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin.js', {input});\n\tt.is(stdout, 'foobar');\n};\n\ntest('input option can be a String', testInput, 'foobar', runExeca);\ntest('input option can be a Uint8Array', testInput, foobarUint8Array, runExeca);\ntest('input option can be a Buffer', testInput, foobarBuffer, runExeca);\ntest('input option can be a String - sync', testInput, 'foobar', runExecaSync);\ntest('input option can be a Uint8Array - sync', testInput, foobarUint8Array, runExecaSync);\ntest('input option can be a Buffer - sync', testInput, foobarBuffer, runExecaSync);\ntest('input option can be used with $', testInput, 'foobar', runScript);\ntest('input option can be used with $.sync', testInput, 'foobar', runScriptSync);\n\nconst testInvalidInput = async (t, input, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', {input});\n\t}, {message: /a string, a Uint8Array/});\n};\n\ntest('input option cannot be an ArrayBuffer', testInvalidInput, foobarArrayBuffer, execa);\ntest('input option cannot be a DataView', testInvalidInput, foobarDataView, execa);\ntest('input option cannot be a Uint16Array', testInvalidInput, foobarUint16Array, execa);\ntest('input option cannot be 0', testInvalidInput, 0, execa);\ntest('input option cannot be false', testInvalidInput, false, execa);\ntest('input option cannot be null', testInvalidInput, null, execa);\ntest('input option cannot be a non-Readable stream', testInvalidInput, new Writable(), execa);\ntest('input option cannot be an ArrayBuffer - sync', testInvalidInput, foobarArrayBuffer, execaSync);\ntest('input option cannot be a DataView - sync', testInvalidInput, foobarDataView, execaSync);\ntest('input option cannot be a Uint16Array - sync', testInvalidInput, foobarUint16Array, execaSync);\ntest('input option cannot be 0 - sync', testInvalidInput, 0, execaSync);\ntest('input option cannot be false - sync', testInvalidInput, false, execaSync);\ntest('input option cannot be null - sync', testInvalidInput, null, execaSync);\ntest('input option cannot be a non-Readable stream - sync', testInvalidInput, new Writable(), execaSync);\n"
  },
  {
    "path": "test/io/input-sync.js",
    "content": "import test from 'ava';\nimport {execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst getFd3InputMessage = type => `not \\`stdio[3]\\`, can be ${type}`;\n\nconst testFd3InputSync = (t, stdioOption, expectedMessage) => {\n\tconst {message} = t.throws(() => {\n\t\texecaSync('empty.js', getStdio(3, stdioOption));\n\t});\n\tt.true(message.includes(expectedMessage));\n};\n\ntest('Cannot use Uint8Array with stdio[*], sync', testFd3InputSync, new Uint8Array(), getFd3InputMessage('a Uint8Array'));\ntest('Cannot use iterable with stdio[*], sync', testFd3InputSync, [[]], getFd3InputMessage('an iterable'));\n"
  },
  {
    "path": "test/io/iterate.js",
    "content": "import {once} from 'node:events';\nimport {getDefaultHighWaterMark} from 'node:stream';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tassertStreamOutput,\n\tassertIterableChunks,\n\tassertStreamChunks,\n\tassertSubprocessOutput,\n\tgetReadableSubprocess,\n\tgetReadWriteSubprocess,\n} from '../helpers/convert.js';\nimport {\n\tstringToUint8Arrays,\n\tsimpleFull,\n\tsimpleChunks,\n\tsimpleChunksBuffer,\n\tsimpleChunksUint8Array,\n\tsimpleLines,\n\tnoNewlinesFull,\n\tcomplexFull,\n\tcomplexFullUtf16,\n\tcomplexFullUtf16Uint8Array,\n\tsingleComplexBuffer,\n\tsingleComplexUtf16Buffer,\n\tsingleComplexUint8Array,\n\tsingleComplexHex,\n\tcomplexChunks,\n\tcomplexChunksEnd,\n} from '../helpers/lines.js';\nimport {outputObjectGenerator, getOutputGenerator} from '../helpers/generator.js';\nimport {foobarString, foobarObject} from '../helpers/input.js';\nimport {\n\tmultibyteChar,\n\tmultibyteUint8Array,\n\tbreakingLength,\n\tbrokenSymbol,\n} from '../helpers/encoding.js';\n\nsetFixtureDirectory();\n\nconst foobarObjectChunks = [foobarObject, foobarObject, foobarObject];\n\nconst getSubprocess = (methodName, output, options) => {\n\tif (methodName !== 'duplex') {\n\t\treturn getReadableSubprocess(output, options);\n\t}\n\n\tconst subprocess = getReadWriteSubprocess(options);\n\tsubprocess.stdin.end(output);\n\treturn subprocess;\n};\n\nconst assertChunks = async (t, streamOrIterable, expectedChunks, methodName) => {\n\tconst assertMethod = methodName === 'iterable' ? assertIterableChunks : assertStreamChunks;\n\tawait assertMethod(t, streamOrIterable, expectedChunks);\n};\n\n// eslint-disable-next-line max-params\nconst testText = async (t, expectedChunks, methodName, binary, preserveNewlines, encoding) => {\n\tconst subprocess = getReadWriteSubprocess({encoding});\n\tconst input = encoding === 'utf16le' ? complexFullUtf16 : complexFull;\n\tsubprocess.stdin.end(input);\n\tconst stream = subprocess[methodName]({binary, preserveNewlines});\n\n\tawait assertChunks(t, stream, expectedChunks, methodName);\n\tconst expectedOutput = encoding === 'hex'\n\t\t? singleComplexHex\n\t\t: stringToUint8Arrays(complexFull, encoding === 'buffer');\n\tawait assertSubprocessOutput(t, subprocess, expectedOutput);\n};\n\ntest('.iterable() can use \"binary: true\"', testText, [singleComplexUint8Array], 'iterable', true, undefined, 'utf8');\ntest('.iterable() can use \"binary: true\" + \"encoding: utf16le\"', testText, [complexFullUtf16Uint8Array], 'iterable', true, undefined, 'utf16le');\ntest('.iterable() can use \"binary: true\" + \"encoding: \"buffer\"', testText, [singleComplexUint8Array], 'iterable', true, undefined, 'buffer');\ntest('.iterable() can use \"binary: true\" + \"encoding: \"hex\"', testText, [singleComplexUint8Array], 'iterable', true, undefined, 'hex');\ntest('.iterable() can use \"binary: undefined\"', testText, complexChunks, 'iterable', undefined, undefined, 'utf8');\ntest('.iterable() can use \"binary: undefined\" + \"encoding: utf16le\"', testText, complexChunks, 'iterable', undefined, undefined, 'utf16le');\ntest('.iterable() can use \"binary: undefined\" + \"encoding: buffer\"', testText, [singleComplexUint8Array], 'iterable', undefined, undefined, 'buffer');\ntest('.iterable() can use \"binary: undefined\" + \"encoding: hex\"', testText, [singleComplexUint8Array], 'iterable', undefined, undefined, 'hex');\ntest('.iterable() can use \"binary: false\"', testText, complexChunks, 'iterable', false, undefined, 'utf8');\ntest('.iterable() can use \"binary: false\" + \"encoding: utf16le\"', testText, complexChunks, 'iterable', false, undefined, 'utf16le');\ntest('.iterable() can use \"binary: false\" + \"encoding: buffer\"', testText, [singleComplexUint8Array], 'iterable', false, undefined, 'buffer');\ntest('.iterable() can use \"binary: false\" + \"encoding: hex\"', testText, [singleComplexUint8Array], 'iterable', false, undefined, 'hex');\ntest('.iterable() can use \"binary: false\" + \"preserveNewlines: true\"', testText, complexChunksEnd, 'iterable', false, true, 'utf8');\ntest('.iterable() can use \"binary: false\" + \"preserveNewlines: false\"', testText, complexChunks, 'iterable', false, false, 'utf8');\ntest('.readable() can use \"binary: true\"', testText, singleComplexBuffer, 'readable', true, undefined, 'utf8');\ntest('.readable() can use \"binary: true\" + \"encoding: utf16le\"', testText, singleComplexUtf16Buffer, 'readable', true, undefined, 'utf16le');\ntest('.readable() can use \"binary: true\" + \"encoding: buffer\"', testText, singleComplexBuffer, 'readable', true, undefined, 'buffer');\ntest('.readable() can use \"binary: true\" + \"encoding: hex\"', testText, singleComplexBuffer, 'readable', true, undefined, 'hex');\ntest('.readable() can use \"binary: undefined\"', testText, singleComplexBuffer, 'readable', undefined, undefined, 'utf8');\ntest('.readable() can use \"binary: undefined\" + \"encoding: utf16le\"', testText, singleComplexUtf16Buffer, 'readable', undefined, undefined, 'utf16le');\ntest('.readable() can use \"binary: undefined\" + \"encoding: buffer\"', testText, singleComplexBuffer, 'readable', undefined, undefined, 'buffer');\ntest('.readable() can use \"binary: undefined\" + \"encoding: hex\"', testText, singleComplexBuffer, 'readable', undefined, undefined, 'hex');\ntest('.readable() can use \"binary: false\"', testText, complexChunksEnd, 'readable', false, undefined, 'utf8');\ntest('.readable() can use \"binary: false\" + \"encoding: utf16le\"', testText, complexChunksEnd, 'readable', false, undefined, 'utf16le');\ntest('.readable() can use \"binary: false\" + \"encoding: buffer\"', testText, singleComplexBuffer, 'readable', false, undefined, 'buffer');\ntest('.readable() can use \"binary: false\" + \"encoding: hex\"', testText, singleComplexBuffer, 'readable', false, undefined, 'hex');\ntest('.readable() can use \"binary: false\" + \"preserveNewlines: true\"', testText, complexChunksEnd, 'readable', false, true, 'utf8');\ntest('.readable() can use \"binary: false\" + \"preserveNewlines: false\"', testText, complexChunks, 'readable', false, false, 'utf8');\ntest('.duplex() can use \"binary: true\"', testText, singleComplexBuffer, 'duplex', true, undefined, 'utf8');\ntest('.duplex() can use \"binary: true\" + \"encoding: utf16le\"', testText, singleComplexUtf16Buffer, 'duplex', true, undefined, 'utf16le');\ntest('.duplex() can use \"binary: true\" + \"encoding: buffer\"', testText, singleComplexBuffer, 'duplex', true, undefined, 'buffer');\ntest('.duplex() can use \"binary: true\" + \"encoding: hex\"', testText, singleComplexBuffer, 'duplex', true, undefined, 'hex');\ntest('.duplex() can use \"binary: undefined\"', testText, singleComplexBuffer, 'duplex', undefined, undefined, 'utf8');\ntest('.duplex() can use \"binary: undefined\" + \"encoding: utf16le\"', testText, singleComplexUtf16Buffer, 'duplex', undefined, undefined, 'utf16le');\ntest('.duplex() can use \"binary: undefined\" + \"encoding: \"buffer\"', testText, singleComplexBuffer, 'duplex', undefined, undefined, 'buffer');\ntest('.duplex() can use \"binary: undefined\" + \"encoding: \"hex\"', testText, singleComplexBuffer, 'duplex', undefined, undefined, 'hex');\ntest('.duplex() can use \"binary: false\"', testText, complexChunksEnd, 'duplex', false, undefined, 'utf8');\ntest('.duplex() can use \"binary: false\" + \"encoding: utf16le\"', testText, complexChunksEnd, 'duplex', false, undefined, 'utf16le');\ntest('.duplex() can use \"binary: false\" + \"encoding: buffer\"', testText, singleComplexBuffer, 'duplex', false, undefined, 'buffer');\ntest('.duplex() can use \"binary: false\" + \"encoding: hex\"', testText, singleComplexBuffer, 'duplex', false, undefined, 'hex');\ntest('.duplex() can use \"binary: false\" + \"preserveNewlines: true\"', testText, complexChunksEnd, 'duplex', false, true, 'utf8');\ntest('.duplex() can use \"binary: false\" + \"preserveNewlines: false\"', testText, complexChunks, 'duplex', false, false, 'utf8');\n\nconst testTextOutput = async (t, expectedOutput, methodName, preserveNewlines) => {\n\tconst subprocess = getSubprocess(methodName, complexFull);\n\tconst stream = subprocess[methodName]({binary: false, preserveNewlines});\n\n\tawait assertStreamOutput(t, stream, expectedOutput);\n\tawait assertSubprocessOutput(t, subprocess, complexFull);\n};\n\ntest('.readable() \"binary: false\" keeps output as is', testTextOutput, complexFull, 'readable', undefined);\ntest('.readable() \"binary: false\" + \"preserveNewlines: true\" keeps output as is', testTextOutput, complexFull, 'readable', true);\ntest('.readable() \"binary: false\" + \"preserveNewlines: false\" removes all newlines', testTextOutput, noNewlinesFull, 'readable', false);\ntest('.duplex() \"binary: false\" keeps output as is', testTextOutput, complexFull, 'duplex', undefined);\ntest('.duplex() \"binary: false\" + \"preserveNewlines: true\" keeps output as is', testTextOutput, complexFull, 'duplex', true);\ntest('.duplex() \"binary: false\" + \"preserveNewlines: false\" removes all newlines', testTextOutput, noNewlinesFull, 'duplex', false);\n\n// eslint-disable-next-line max-params\nconst testObjectMode = async (t, expectedChunks, methodName, encoding, initialObjectMode, finalObjectMode, binary, options) => {\n\tconst subprocess = getSubprocess(methodName, simpleFull, options);\n\tif (encoding !== null) {\n\t\tsubprocess.stdout.setEncoding(encoding);\n\t}\n\n\tt.is(subprocess.stdout.readableEncoding, encoding);\n\tt.is(subprocess.stdout.readableObjectMode, initialObjectMode);\n\tt.is(subprocess.stdout.readableHighWaterMark, getDefaultHighWaterMark(initialObjectMode));\n\n\tconst stream = subprocess[methodName]({binary, preserveNewlines: true});\n\n\tif (methodName !== 'iterable') {\n\t\tt.is(stream.readableEncoding, encoding);\n\t\tt.is(stream.readableObjectMode, finalObjectMode);\n\t\tt.is(stream.readableHighWaterMark, getDefaultHighWaterMark(finalObjectMode));\n\t}\n\n\tt.is(subprocess.stdout.readableEncoding, encoding);\n\tt.is(subprocess.stdout.readableObjectMode, initialObjectMode);\n\tt.is(subprocess.stdout.readableHighWaterMark, getDefaultHighWaterMark(initialObjectMode));\n\n\tawait assertChunks(t, stream, expectedChunks, methodName);\n\tawait subprocess;\n};\n\ntest('.iterable() uses Uint8Arrays with \"binary: true\"', testObjectMode, simpleChunksUint8Array, 'iterable', null, false, false, true);\ntest('.iterable() uses Uint8Arrays with \"binary: true\" and .setEncoding(\"utf8\")', testObjectMode, simpleChunksUint8Array, 'iterable', 'utf8', false, false, true);\ntest('.iterable() uses Uint8Arrays with \"binary: true\", .setEncoding(\"utf8\") and \"encoding: buffer\"', testObjectMode, simpleChunksUint8Array, 'iterable', 'utf8', false, false, true, {encoding: 'buffer'});\ntest('.iterable() uses strings in objectMode with \"binary: true\" and object transforms', testObjectMode, foobarObjectChunks, 'iterable', null, true, true, true, {stdout: outputObjectGenerator()});\ntest('.iterable() uses strings in objectMode with \"binary: false\"', testObjectMode, simpleLines, 'iterable', null, false, true, false);\ntest('.iterable() uses strings in objectMode with \"binary: false\" and .setEncoding(\"utf8\")', testObjectMode, simpleLines, 'iterable', 'utf8', false, true, false);\ntest('.iterable() uses Uint8Arrays in objectMode with \"binary: false\", .setEncoding(\"utf8\") and \"encoding: buffer\"', testObjectMode, simpleChunksUint8Array, 'iterable', 'utf8', false, true, false, {encoding: 'buffer'});\ntest('.iterable() uses strings in objectMode with \"binary: false\" and object transforms', testObjectMode, foobarObjectChunks, 'iterable', null, true, true, false, {stdout: outputObjectGenerator()});\ntest('.readable() uses Buffers with \"binary: true\"', testObjectMode, simpleChunksBuffer, 'readable', null, false, false, true);\ntest('.readable() uses strings with \"binary: true\" and .setEncoding(\"utf8\")', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, true);\ntest('.readable() uses strings with \"binary: true\", .setEncoding(\"utf8\") and \"encoding: buffer\"', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, true, {encoding: 'buffer'});\ntest('.readable() uses strings in objectMode with \"binary: true\" and object transforms', testObjectMode, foobarObjectChunks, 'readable', null, true, true, true, {stdout: outputObjectGenerator()});\ntest('.readable() uses strings in objectMode with \"binary: false\"', testObjectMode, simpleLines, 'readable', null, false, true, false);\ntest('.readable() uses strings in objectMode with \"binary: false\" and .setEncoding(\"utf8\")', testObjectMode, simpleLines, 'readable', 'utf8', false, true, false);\ntest('.readable() uses strings in objectMode with \"binary: false\", .setEncoding(\"utf8\") and \"encoding: buffer\"', testObjectMode, simpleChunks, 'readable', 'utf8', false, false, false, {encoding: 'buffer'});\ntest('.readable() uses strings in objectMode with \"binary: false\" and object transforms', testObjectMode, foobarObjectChunks, 'readable', null, true, true, false, {stdout: outputObjectGenerator()});\ntest('.duplex() uses Buffers with \"binary: true\"', testObjectMode, simpleChunksBuffer, 'duplex', null, false, false, true);\ntest('.duplex() uses strings with \"binary: true\" and .setEncoding(\"utf8\")', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, true);\ntest('.duplex() uses strings with \"binary: true\", .setEncoding(\"utf8\") and \"encoding: buffer\"', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, true, {encoding: 'buffer'});\ntest('.duplex() uses strings in objectMode with \"binary: true\" and object transforms', testObjectMode, foobarObjectChunks, 'duplex', null, true, true, true, {stdout: outputObjectGenerator()});\ntest('.duplex() uses strings in objectMode with \"binary: false\"', testObjectMode, simpleLines, 'duplex', null, false, true, false);\ntest('.duplex() uses strings in objectMode with \"binary: false\" and .setEncoding(\"utf8\")', testObjectMode, simpleLines, 'duplex', 'utf8', false, true, false);\ntest('.duplex() uses strings in objectMode with \"binary: false\", .setEncoding(\"utf8\") and \"encoding: buffer\"', testObjectMode, simpleChunks, 'duplex', 'utf8', false, false, false, {encoding: 'buffer'});\ntest('.duplex() uses strings in objectMode with \"binary: false\" and object transforms', testObjectMode, foobarObjectChunks, 'duplex', null, true, true, false, {stdout: outputObjectGenerator()});\n\nconst testObjectSplit = async (t, methodName) => {\n\tconst subprocess = getSubprocess(methodName, foobarString, {stdout: getOutputGenerator(simpleFull)(true)});\n\tconst stream = subprocess[methodName]({binary: false});\n\tawait assertChunks(t, stream, [simpleFull], methodName);\n\tawait subprocess;\n};\n\ntest('.iterable() \"binary: false\" does not split lines of strings produced by object transforms', testObjectSplit, 'iterable');\ntest('.readable() \"binary: false\" does not split lines of strings produced by object transforms', testObjectSplit, 'readable');\ntest('.duplex() \"binary: false\" does not split lines of strings produced by object transforms', testObjectSplit, 'duplex');\n\nconst testMultibyteCharacters = async (t, methodName) => {\n\tconst subprocess = getReadWriteSubprocess();\n\tconst stream = subprocess[methodName]({binary: false});\n\tconst assertPromise = assertChunks(t, stream, [`${multibyteChar}${brokenSymbol}`], methodName);\n\tsubprocess.stdin.write(multibyteUint8Array.slice(0, breakingLength));\n\tawait once(subprocess.stdout, 'data');\n\tsubprocess.stdin.end();\n\tawait assertPromise;\n};\n\ntest('.iterable() \"binary: false\" handles partial multibyte characters', testMultibyteCharacters, 'iterable');\ntest('.readable() \"binary: false\" handles partial multibyte characters', testMultibyteCharacters, 'readable');\ntest('.duplex() \"binary: false\" handles partial multibyte characters', testMultibyteCharacters, 'duplex');\n"
  },
  {
    "path": "test/io/max-buffer.js",
    "content": "import {Buffer} from 'node:buffer';\nimport test from 'ava';\nimport getStream from 'get-stream';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {getEarlyErrorSubprocess} from '../helpers/early-error.js';\nimport {maxBuffer, assertErrorMessage} from '../helpers/max-buffer.js';\nimport {foobarArray} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst maxBufferMessage = {message: /maxBuffer exceeded/};\nconst maxBufferCodeSync = {code: 'ENOBUFS'};\n\nconst runMaxBuffer = async (t, execaMethod, fdNumber, options) => {\n\tconst error = execaMethod === execa\n\t\t? await t.throwsAsync(getMaxBufferSubprocess(execaMethod, fdNumber, options), maxBufferMessage)\n\t\t: t.throws(() => {\n\t\t\tgetMaxBufferSubprocess(execaMethod, fdNumber, options);\n\t\t}, maxBufferCodeSync);\n\tt.true(error.isMaxBuffer);\n\tt.is(error.maxBufferInfo, undefined);\n\treturn error;\n};\n\nconst getMaxBufferSubprocess = (execaMethod, fdNumber, {length = maxBuffer, ...options} = {}) =>\n\texecaMethod('max-buffer.js', [`${fdNumber}`, `${length + 1}`], {...fullStdio, maxBuffer, ...options});\n\nconst getExpectedOutput = (length = maxBuffer) => '.'.repeat(length);\n\nconst testMaxBufferSuccess = async (t, execaMethod, fdNumber, all) => {\n\tconst {isMaxBuffer} = await getMaxBufferSubprocess(execaMethod, fdNumber, {all, length: maxBuffer - 1});\n\tt.false(isMaxBuffer);\n};\n\ntest('maxBuffer does not affect stdout if too high', testMaxBufferSuccess, execa, 1, false);\ntest('maxBuffer does not affect stderr if too high', testMaxBufferSuccess, execa, 2, false);\ntest('maxBuffer does not affect stdio[*] if too high', testMaxBufferSuccess, execa, 3, false);\ntest('maxBuffer does not affect all if too high', testMaxBufferSuccess, execa, 1, true);\ntest('maxBuffer does not affect stdout if too high, sync', testMaxBufferSuccess, execaSync, 1, false);\ntest('maxBuffer does not affect stderr if too high, sync', testMaxBufferSuccess, execaSync, 2, false);\ntest('maxBuffer does not affect stdio[*] if too high, sync', testMaxBufferSuccess, execaSync, 3, false);\ntest('maxBuffer does not affect all if too high, sync', testMaxBufferSuccess, execaSync, 1, true);\n\nconst testGracefulExit = async (t, fixtureName, expectedExitCode) => {\n\tconst {isMaxBuffer, shortMessage, exitCode, signal, stdout} = await t.throwsAsync(\n\t\texeca(fixtureName, ['1', '.'.repeat(maxBuffer + 1)], {maxBuffer}),\n\t\tmaxBufferMessage,\n\t);\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage);\n\tt.is(exitCode, expectedExitCode);\n\tt.is(signal, undefined);\n\tt.is(stdout, getExpectedOutput());\n};\n\ntest('maxBuffer terminates stream gracefully, more writes', testGracefulExit, 'noop-repeat.js', 1);\ntest('maxBuffer terminates stream gracefully, no more writes', testGracefulExit, 'noop-fd.js', 0);\n\nconst testGracefulExitSync = (t, fixtureName) => {\n\tconst {isMaxBuffer, shortMessage, exitCode, signal, stdout} = t.throws(() => {\n\t\texecaSync(fixtureName, ['1', '.'.repeat(maxBuffer + 1)], {maxBuffer, killSignal: 'SIGINT'});\n\t}, maxBufferCodeSync);\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage, {execaMethod: execaSync});\n\tt.is(exitCode, undefined);\n\tt.is(signal, 'SIGINT');\n\tt.is(stdout, getExpectedOutput());\n};\n\ntest('maxBuffer terminate stream with killSignal, more writes, sync', testGracefulExitSync, 'noop-repeat.js');\ntest('maxBuffer terminate stream with killSignal, no more writes, sync', testGracefulExitSync, 'noop-fd.js');\n\nconst testMaxBufferLimit = async (t, execaMethod, fdNumber, all) => {\n\tconst length = all && execaMethod === execa ? maxBuffer * 2 : maxBuffer;\n\tconst {shortMessage, all: allOutput, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {all, length});\n\tassertErrorMessage(t, shortMessage, {execaMethod, fdNumber});\n\tt.is(all ? allOutput : stdio[fdNumber], getExpectedOutput(length));\n};\n\ntest('maxBuffer truncates stdout', testMaxBufferLimit, execa, 1, false);\ntest('maxBuffer truncates stderr', testMaxBufferLimit, execa, 2, false);\ntest('maxBuffer truncates stdio[*]', testMaxBufferLimit, execa, 3, false);\ntest('maxBuffer truncates all', testMaxBufferLimit, execa, 1, true);\ntest('maxBuffer truncates stdout, sync', testMaxBufferLimit, execaSync, 1, false);\ntest('maxBuffer truncates stderr, sync', testMaxBufferLimit, execaSync, 2, false);\ntest('maxBuffer truncates stdio[*], sync', testMaxBufferLimit, execaSync, 3, false);\ntest('maxBuffer truncates all, sync', testMaxBufferLimit, execaSync, 1, true);\n\nconst MAX_BUFFER_DEFAULT = 1e8;\n\nconst testMaxBufferDefault = async (t, execaMethod, fdNumber, maxBuffer) => {\n\tconst length = MAX_BUFFER_DEFAULT;\n\tconst {shortMessage, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {length: MAX_BUFFER_DEFAULT + 1, maxBuffer});\n\tassertErrorMessage(t, shortMessage, {execaMethod, fdNumber, length});\n\tt.is(stdio[fdNumber], getExpectedOutput(length));\n};\n\ntest('maxBuffer has a default value with stdout', testMaxBufferDefault, execa, 1, undefined);\ntest('maxBuffer has a default value with stderr', testMaxBufferDefault, execa, 2, undefined);\ntest('maxBuffer has a default value with stdio[*]', testMaxBufferDefault, execa, 3, undefined);\ntest('maxBuffer has a default value with stdout, sync', testMaxBufferDefault, execaSync, 1, undefined);\ntest('maxBuffer has a default value with stderr, sync', testMaxBufferDefault, execaSync, 2, undefined);\ntest('maxBuffer has a default value with stdio[*], sync', testMaxBufferDefault, execaSync, 3, undefined);\ntest('maxBuffer has a default value with stdout with fd-specific options', testMaxBufferDefault, execa, 1, {stderr: 1e9});\ntest('maxBuffer has a default value with stderr with fd-specific options', testMaxBufferDefault, execa, 2, {stdout: 1e9});\ntest('maxBuffer has a default value with stdio[*] with fd-specific options', testMaxBufferDefault, execa, 3, {stdout: 1e9});\ntest('maxBuffer has a default value with stdout with empty fd-specific options', testMaxBufferDefault, execa, 1, {});\n\nconst testFdSpecific = async (t, fdNumber, fdName, execaMethod) => {\n\tconst length = 1;\n\tconst {shortMessage, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {maxBuffer: {[fdName]: length}});\n\tassertErrorMessage(t, shortMessage, {execaMethod, fdNumber, length});\n\tt.is(stdio[fdNumber], getExpectedOutput(length));\n};\n\ntest('maxBuffer truncates file descriptors with fd-specific options, stdout', testFdSpecific, 1, 'stdout', execa);\ntest('maxBuffer truncates file descriptors with fd-specific options, fd1', testFdSpecific, 1, 'fd1', execa);\ntest('maxBuffer truncates file descriptors with fd-specific options, stderr', testFdSpecific, 2, 'stderr', execa);\ntest('maxBuffer truncates file descriptors with fd-specific options, fd2', testFdSpecific, 2, 'fd2', execa);\ntest('maxBuffer truncates file descriptors with fd-specific options, stdout, all', testFdSpecific, 1, 'all', execa);\ntest('maxBuffer truncates file descriptors with fd-specific options, stderr, all', testFdSpecific, 2, 'all', execa);\ntest('maxBuffer truncates file descriptors with fd-specific options, fd3', testFdSpecific, 3, 'fd3', execa);\ntest('maxBuffer.stdout is used for stdout with fd-specific options, stdout, sync', testFdSpecific, 1, 'stdout', execaSync);\n\ntest('maxBuffer does not affect other file descriptors with fd-specific options', async t => {\n\tconst {isMaxBuffer} = await getMaxBufferSubprocess(execa, 2, {maxBuffer: {stdout: 1}});\n\tt.false(isMaxBuffer);\n});\n\ntest('maxBuffer.stdout is used for other file descriptors with fd-specific options, sync', async t => {\n\tconst length = 1;\n\tconst {shortMessage, stderr} = await runMaxBuffer(t, execaSync, 2, {maxBuffer: {stdout: length}});\n\tassertErrorMessage(t, shortMessage, {execaMethod: execaSync, fdNumber: 2, length});\n\tt.is(stderr, getExpectedOutput(length));\n});\n\nconst testAll = async (t, shouldFail) => {\n\tconst difference = shouldFail ? 0 : 1;\n\tconst maxBufferStdout = 2;\n\tconst maxBufferStderr = 4 - difference;\n\tconst {isMaxBuffer, shortMessage, stdout, stderr, all} = await execa(\n\t\t'noop-both.js',\n\t\t['\\n'.repeat(maxBufferStdout - 1), '\\n'.repeat(maxBufferStderr - difference)],\n\t\t{\n\t\t\tmaxBuffer: {stdout: maxBufferStdout, stderr: maxBufferStderr},\n\t\t\tall: true,\n\t\t\tstripFinalNewline: false,\n\t\t\treject: false,\n\t\t},\n\t);\n\tt.is(isMaxBuffer, shouldFail);\n\tif (shouldFail) {\n\t\tassertErrorMessage(t, shortMessage, {fdNumber: 2, length: maxBufferStderr});\n\t}\n\n\tt.is(stdout, '\\n'.repeat(maxBufferStdout));\n\tt.is(stderr, '\\n'.repeat(maxBufferStderr));\n\tt.is(all, '\\n'.repeat(maxBufferStdout + maxBufferStderr));\n};\n\ntest('maxBuffer.stdout can differ from maxBuffer.stderr, combined with all, below threshold', testAll, false);\ntest('maxBuffer.stdout can differ from maxBuffer.stderr, combined with all, above threshold', testAll, true);\n\nconst testInvalidFd = async (t, fdName, execaMethod) => {\n\tconst {message} = t.throws(() => {\n\t\texecaMethod('empty.js', {maxBuffer: {[fdName]: 0}});\n\t});\n\tt.true(message.includes(`\"maxBuffer.${fdName}\" is invalid`));\n};\n\ntest('maxBuffer.stdin is invalid', testInvalidFd, 'stdin', execa);\ntest('maxBuffer.fd0 is invalid', testInvalidFd, 'fd0', execa);\ntest('maxBuffer.other is invalid', testInvalidFd, 'other', execa);\ntest('maxBuffer.fd10 is invalid', testInvalidFd, 'fd10', execa);\ntest('maxBuffer.stdin is invalid, sync', testInvalidFd, 'stdin', execaSync);\ntest('maxBuffer.fd0 is invalid, sync', testInvalidFd, 'fd0', execaSync);\ntest('maxBuffer.other is invalid, sync', testInvalidFd, 'other', execaSync);\ntest('maxBuffer.fd10 is invalid, sync', testInvalidFd, 'fd10', execaSync);\n\nconst testMaxBufferEncoding = async (t, execaMethod, fdNumber) => {\n\tconst {shortMessage, stdio} = await runMaxBuffer(t, execaMethod, fdNumber, {encoding: 'buffer'});\n\tassertErrorMessage(t, shortMessage, {execaMethod, fdNumber, unit: 'bytes'});\n\tconst stream = stdio[fdNumber];\n\tt.true(stream instanceof Uint8Array);\n\tt.is(Buffer.from(stream).toString(), getExpectedOutput());\n};\n\ntest('maxBuffer works with encoding buffer and stdout', testMaxBufferEncoding, execa, 1);\ntest('maxBuffer works with encoding buffer and stderr', testMaxBufferEncoding, execa, 2);\ntest('maxBuffer works with encoding buffer and stdio[*]', testMaxBufferEncoding, execa, 3);\ntest('maxBuffer works with encoding buffer and stdout, sync', testMaxBufferEncoding, execaSync, 1);\ntest('maxBuffer works with encoding buffer and stderr, sync', testMaxBufferEncoding, execaSync, 2);\ntest('maxBuffer works with encoding buffer and stdio[*], sync', testMaxBufferEncoding, execaSync, 3);\n\nconst testMaxBufferHex = async (t, fdNumber) => {\n\tconst length = maxBuffer / 2;\n\tconst {shortMessage, stdio} = await runMaxBuffer(t, execa, fdNumber, {length, encoding: 'hex'});\n\tassertErrorMessage(t, shortMessage, {fdNumber});\n\tt.is(stdio[fdNumber], Buffer.from(getExpectedOutput(length)).toString('hex'));\n};\n\ntest('maxBuffer works with other encodings and stdout', testMaxBufferHex, 1);\ntest('maxBuffer works with other encodings and stderr', testMaxBufferHex, 2);\ntest('maxBuffer works with other encodings and stdio[*]', testMaxBufferHex, 3);\n\nconst testMaxBufferHexSync = async (t, fdNumber) => {\n\tconst length = maxBuffer / 2;\n\tconst {isMaxBuffer, stdio} = await getMaxBufferSubprocess(execaSync, fdNumber, {length, encoding: 'hex'});\n\tt.false(isMaxBuffer);\n\tt.is(stdio[fdNumber], Buffer.from(getExpectedOutput(length + 1)).toString('hex'));\n};\n\ntest('maxBuffer ignores other encodings and stdout, sync', testMaxBufferHexSync, 1);\ntest('maxBuffer ignores other encodings and stderr, sync', testMaxBufferHexSync, 2);\ntest('maxBuffer ignores other encodings and stdio[*], sync', testMaxBufferHexSync, 3);\n\nconst testNoMaxBuffer = async (t, fdNumber, buffer) => {\n\tconst subprocess = getMaxBufferSubprocess(execa, fdNumber, {buffer});\n\tconst [{isMaxBuffer, stdio}, output] = await Promise.all([\n\t\tsubprocess,\n\t\tgetStream(subprocess.stdio[fdNumber]),\n\t]);\n\tt.false(isMaxBuffer);\n\tt.is(stdio[fdNumber], undefined);\n\tt.is(output, getExpectedOutput(maxBuffer + 1));\n};\n\ntest('do not buffer stdout when `buffer` set to `false`', testNoMaxBuffer, 1, false);\ntest('do not buffer stdout when `buffer` set to `false`, fd-specific', testNoMaxBuffer, 1, {stdout: false});\ntest('do not buffer stderr when `buffer` set to `false`', testNoMaxBuffer, 2, false);\ntest('do not buffer stderr when `buffer` set to `false`, fd-specific', testNoMaxBuffer, 2, {stderr: false});\ntest('do not buffer stdio[*] when `buffer` set to `false`', testNoMaxBuffer, 3, false);\ntest('do not buffer stdio[*] when `buffer` set to `false`, fd-specific', testNoMaxBuffer, 3, {fd3: false});\n\nconst testNoMaxBufferSync = (t, fdNumber, buffer) => {\n\tconst {isMaxBuffer, stdio} = getMaxBufferSubprocess(execaSync, fdNumber, {buffer});\n\tt.false(isMaxBuffer);\n\tt.is(stdio[fdNumber], undefined);\n};\n\n// @todo: add tests for fd3 once the following Node.js bug is fixed.\n// https://github.com/nodejs/node/issues/52422\ntest('do not buffer stdout when `buffer` set to `false`, sync', testNoMaxBufferSync, 1, false);\ntest('do not buffer stdout when `buffer` set to `false`, fd-specific, sync', testNoMaxBufferSync, 1, {stdout: false});\ntest('do not buffer stderr when `buffer` set to `false`, sync', testNoMaxBufferSync, 2, false);\ntest('do not buffer stderr when `buffer` set to `false`, fd-specific, sync', testNoMaxBufferSync, 2, {stderr: false});\n\nconst testMaxBufferAbort = async (t, fdNumber) => {\n\tconst subprocess = getMaxBufferSubprocess(execa, fdNumber);\n\tconst [{isMaxBuffer, shortMessage}] = await Promise.all([\n\t\tt.throwsAsync(subprocess, maxBufferMessage),\n\t\tt.throwsAsync(getStream(subprocess.stdio[fdNumber]), {code: 'ERR_STREAM_PREMATURE_CLOSE'}),\n\t]);\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage, {execaMethod: execa, fdNumber});\n};\n\ntest('abort stream when hitting maxBuffer with stdout', testMaxBufferAbort, 1);\ntest('abort stream when hitting maxBuffer with stderr', testMaxBufferAbort, 2);\ntest('abort stream when hitting maxBuffer with stdio[*]', testMaxBufferAbort, 3);\n\ntest('error.isMaxBuffer is false on early errors', async t => {\n\tconst {failed, isMaxBuffer} = await getEarlyErrorSubprocess({reject: false, maxBuffer: 1});\n\tt.true(failed);\n\tt.false(isMaxBuffer);\n});\n\ntest('maxBuffer works with result.ipcOutput', async t => {\n\tconst {\n\t\tisMaxBuffer,\n\t\tshortMessage,\n\t\tmessage,\n\t\tstderr,\n\t\tipcOutput,\n\t} = await t.throwsAsync(execa('ipc-send-twice.js', {ipc: true, maxBuffer: {ipc: 1}}));\n\tt.true(isMaxBuffer);\n\tt.is(shortMessage, 'Command\\'s IPC output was larger than 1 messages: ipc-send-twice.js\\nmaxBuffer exceeded');\n\tt.true(message.endsWith(`\\n\\n${foobarArray[0]}`));\n\tt.is(stderr, '');\n\tt.deepEqual(ipcOutput, [foobarArray[0]]);\n});\n\ntest('maxBuffer is ignored with result.ipcOutput if buffer is false', async t => {\n\tconst {ipcOutput} = await execa('ipc-send-twice.js', {ipc: true, maxBuffer: {ipc: 1}, buffer: false});\n\tt.deepEqual(ipcOutput, []);\n});\n"
  },
  {
    "path": "test/io/output-async.js",
    "content": "import {once, defaultMaxListeners} from 'node:events';\nimport process from 'node:process';\nimport {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {STANDARD_STREAMS} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {assertMaxListeners} from '../helpers/listeners.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst getStandardStreamListeners = stream => Object.fromEntries(stream.eventNames().map(eventName => [eventName, stream.listeners(eventName)]));\nconst getStandardStreamsListeners = () => STANDARD_STREAMS.map(stream => getStandardStreamListeners(stream));\n\nconst getComplexStdio = isMultiple => ({\n\tstdin: ['pipe', 'inherit', ...(isMultiple ? [0, process.stdin] : [])],\n\tstdout: ['pipe', 'inherit', ...(isMultiple ? [1, process.stdout] : [])],\n\tstderr: ['pipe', 'inherit', ...(isMultiple ? [2, process.stderr] : [])],\n});\n\nconst onStdinRemoveListener = () => once(process.stdin, 'removeListener');\n\nconst testListenersCleanup = async (t, isMultiple) => {\n\tconst streamsPreviousListeners = getStandardStreamsListeners();\n\tconst subprocess = execa('empty.js', getComplexStdio(isMultiple));\n\tt.notDeepEqual(getStandardStreamsListeners(), streamsPreviousListeners);\n\tawait Promise.all([subprocess, onStdinRemoveListener()]);\n\tif (isMultiple) {\n\t\tawait onStdinRemoveListener();\n\t}\n\n\tfor (const [fdNumber, streamNewListeners] of Object.entries(getStandardStreamsListeners())) {\n\t\tconst defaultListeners = Object.fromEntries(Reflect.ownKeys(streamNewListeners).map(eventName => [eventName, []]));\n\t\tt.deepEqual(streamNewListeners, {...defaultListeners, ...streamsPreviousListeners[fdNumber]});\n\t}\n};\n\ntest.serial('process.std* listeners are cleaned up on success with a single input', testListenersCleanup, false);\ntest.serial('process.std* listeners are cleaned up on success with multiple inputs', testListenersCleanup, true);\n\ntest.serial('Can spawn many subprocesses in parallel', async t => {\n\tconst results = await Promise.all(\n\t\tArray.from({length: PARALLEL_COUNT}, () => execa('noop.js', [foobarString])),\n\t);\n\tt.true(results.every(({stdout}) => stdout === foobarString));\n});\n\nconst testMaxListeners = async (t, isMultiple, maxListenersCount) => {\n\tconst checkMaxListeners = assertMaxListeners(t);\n\n\tfor (const standardStream of STANDARD_STREAMS) {\n\t\tstandardStream.setMaxListeners(maxListenersCount);\n\t}\n\n\ttry {\n\t\tconst results = await Promise.all(\n\t\t\tArray.from({length: PARALLEL_COUNT}, () => execa('empty.js', getComplexStdio(isMultiple))),\n\t\t);\n\t\tt.true(results.every(({exitCode}) => exitCode === 0));\n\t} finally {\n\t\tawait setImmediate();\n\t\tawait setImmediate();\n\t\tcheckMaxListeners();\n\n\t\tfor (const standardStream of STANDARD_STREAMS) {\n\t\t\tt.is(standardStream.getMaxListeners(), maxListenersCount);\n\t\t\tstandardStream.setMaxListeners(defaultMaxListeners);\n\t\t}\n\t}\n};\n\ntest.serial('No warning with maxListeners 1 and [\"pipe\", \"inherit\"]', testMaxListeners, false, 1);\ntest.serial('No warning with maxListeners default and [\"pipe\", \"inherit\"]', testMaxListeners, false, defaultMaxListeners);\ntest.serial('No warning with maxListeners 100 and [\"pipe\", \"inherit\"]', testMaxListeners, false, 100);\ntest.serial('No warning with maxListeners Infinity and [\"pipe\", \"inherit\"]', testMaxListeners, false, Number.POSITIVE_INFINITY);\ntest.serial('No warning with maxListeners 0 and [\"pipe\", \"inherit\"]', testMaxListeners, false, 0);\ntest.serial('No warning with maxListeners 1 and [\"pipe\", \"inherit\"], multiple inputs', testMaxListeners, true, 1);\ntest.serial('No warning with maxListeners default and [\"pipe\", \"inherit\"], multiple inputs', testMaxListeners, true, defaultMaxListeners);\ntest.serial('No warning with maxListeners 100 and [\"pipe\", \"inherit\"], multiple inputs', testMaxListeners, true, 100);\ntest.serial('No warning with maxListeners Infinity and [\"pipe\", \"inherit\"], multiple inputs', testMaxListeners, true, Number.POSITIVE_INFINITY);\ntest.serial('No warning with maxListeners 0 and [\"pipe\", \"inherit\"], multiple inputs', testMaxListeners, true, 0);\n"
  },
  {
    "path": "test/io/output-sync.js",
    "content": "import test from 'ava';\nimport {execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {throwingGenerator} from '../helpers/generator.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\ntest('Handles errors with stdout generator, sync', t => {\n\tconst cause = new Error(foobarString);\n\tconst error = t.throws(() => {\n\t\texecaSync('noop.js', {stdout: throwingGenerator(cause)()});\n\t});\n\tt.is(error.cause, cause);\n});\n\ntest('Handles errors with stdout generator, spawn failure, sync', t => {\n\tconst cause = new Error(foobarString);\n\tconst error = t.throws(() => {\n\t\texecaSync('noop.js', {cwd: 'does_not_exist', stdout: throwingGenerator(cause)()});\n\t});\n\tt.true(error.failed);\n\tt.is(error.cause.code, 'ENOENT');\n});\n\ntest('Handles errors with stdout generator, subprocess failure, sync', t => {\n\tconst cause = new Error(foobarString);\n\tconst error = t.throws(() => {\n\t\texecaSync('noop-fail.js', ['1'], {stdout: throwingGenerator(cause)()});\n\t});\n\tt.true(error.failed);\n\tt.is(error.cause, cause);\n});\n"
  },
  {
    "path": "test/io/pipeline.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {getStdio, STANDARD_STREAMS} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getEarlyErrorSubprocess, expectedEarlyError} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testDestroyStandard = async (t, fdNumber) => {\n\tconst subprocess = execa('forever.js', {...getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe']), timeout: 1});\n\tawait t.throwsAsync(subprocess, {message: /timed out/});\n\tt.false(STANDARD_STREAMS[fdNumber].destroyed);\n};\n\ntest('Does not destroy process.stdin on subprocess errors', testDestroyStandard, 0);\ntest('Does not destroy process.stdout on subprocess errors', testDestroyStandard, 1);\ntest('Does not destroy process.stderr on subprocess errors', testDestroyStandard, 2);\n\nconst testDestroyStandardSpawn = async (t, fdNumber) => {\n\tconst error = await t.throwsAsync(getEarlyErrorSubprocess(getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe'])));\n\tt.like(error, expectedEarlyError);\n\tt.false(STANDARD_STREAMS[fdNumber].destroyed);\n};\n\ntest('Does not destroy process.stdin on subprocess early errors', testDestroyStandardSpawn, 0);\ntest('Does not destroy process.stdout on subprocess early errors', testDestroyStandardSpawn, 1);\ntest('Does not destroy process.stderr on subprocess early errors', testDestroyStandardSpawn, 2);\n\nconst testDestroyStandardStream = async (t, fdNumber) => {\n\tconst subprocess = execa('forever.js', getStdio(fdNumber, [STANDARD_STREAMS[fdNumber], 'pipe']));\n\tconst cause = new Error('test');\n\tsubprocess.stdio[fdNumber].destroy(cause);\n\tsubprocess.kill();\n\tt.like(await t.throwsAsync(subprocess), {cause});\n\tt.false(STANDARD_STREAMS[fdNumber].destroyed);\n};\n\ntest('Does not destroy process.stdin on stream subprocess errors', testDestroyStandardStream, 0);\ntest('Does not destroy process.stdout on stream subprocess errors', testDestroyStandardStream, 1);\ntest('Does not destroy process.stderr on stream subprocess errors', testDestroyStandardStream, 2);\n"
  },
  {
    "path": "test/io/strip-newline.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {noopGenerator} from '../helpers/generator.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testStripFinalNewline = async (t, fdNumber, stripFinalNewline, shouldStrip, execaMethod) => {\n\tconst {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, `${foobarString}\\n`], {...fullStdio, stripFinalNewline});\n\tt.is(stdio[fdNumber], `${foobarString}${shouldStrip ? '' : '\\n'}`);\n};\n\ntest('stripFinalNewline: default with stdout', testStripFinalNewline, 1, undefined, true, execa);\ntest('stripFinalNewline: true with stdout', testStripFinalNewline, 1, true, true, execa);\ntest('stripFinalNewline: false with stdout', testStripFinalNewline, 1, false, false, execa);\ntest('stripFinalNewline: default with stderr', testStripFinalNewline, 2, undefined, true, execa);\ntest('stripFinalNewline: true with stderr', testStripFinalNewline, 2, true, true, execa);\ntest('stripFinalNewline: false with stderr', testStripFinalNewline, 2, false, false, execa);\ntest('stripFinalNewline: default with stdio[*]', testStripFinalNewline, 3, undefined, true, execa);\ntest('stripFinalNewline: true with stdio[*]', testStripFinalNewline, 3, true, true, execa);\ntest('stripFinalNewline: false with stdio[*]', testStripFinalNewline, 3, false, false, execa);\ntest('stripFinalNewline: default with stdout, fd-specific', testStripFinalNewline, 1, {}, true, execa);\ntest('stripFinalNewline: true with stdout, fd-specific', testStripFinalNewline, 1, {stdout: true}, true, execa);\ntest('stripFinalNewline: false with stdout, fd-specific', testStripFinalNewline, 1, {stdout: false}, false, execa);\ntest('stripFinalNewline: default with stderr, fd-specific', testStripFinalNewline, 2, {}, true, execa);\ntest('stripFinalNewline: true with stderr, fd-specific', testStripFinalNewline, 2, {stderr: true}, true, execa);\ntest('stripFinalNewline: false with stderr, fd-specific', testStripFinalNewline, 2, {stderr: false}, false, execa);\ntest('stripFinalNewline: default with stdio[*], fd-specific', testStripFinalNewline, 3, {}, true, execa);\ntest('stripFinalNewline: true with stdio[*], fd-specific', testStripFinalNewline, 3, {fd3: true}, true, execa);\ntest('stripFinalNewline: false with stdio[*], fd-specific', testStripFinalNewline, 3, {fd3: false}, false, execa);\ntest('stripFinalNewline: default with stdout, sync', testStripFinalNewline, 1, undefined, true, execaSync);\ntest('stripFinalNewline: true with stdout, sync', testStripFinalNewline, 1, true, true, execaSync);\ntest('stripFinalNewline: false with stdout, sync', testStripFinalNewline, 1, false, false, execaSync);\ntest('stripFinalNewline: default with stderr, sync', testStripFinalNewline, 2, undefined, true, execaSync);\ntest('stripFinalNewline: true with stderr, sync', testStripFinalNewline, 2, true, true, execaSync);\ntest('stripFinalNewline: false with stderr, sync', testStripFinalNewline, 2, false, false, execaSync);\ntest('stripFinalNewline: default with stdio[*], sync', testStripFinalNewline, 3, undefined, true, execaSync);\ntest('stripFinalNewline: true with stdio[*], sync', testStripFinalNewline, 3, true, true, execaSync);\ntest('stripFinalNewline: false with stdio[*], sync', testStripFinalNewline, 3, false, false, execaSync);\ntest('stripFinalNewline: default with stdout, fd-specific, sync', testStripFinalNewline, 1, {}, true, execaSync);\ntest('stripFinalNewline: true with stdout, fd-specific, sync', testStripFinalNewline, 1, {stdout: true}, true, execaSync);\ntest('stripFinalNewline: false with stdout, fd-specific, sync', testStripFinalNewline, 1, {stdout: false}, false, execaSync);\ntest('stripFinalNewline: default with stderr, fd-specific, sync', testStripFinalNewline, 2, {}, true, execaSync);\ntest('stripFinalNewline: true with stderr, fd-specific, sync', testStripFinalNewline, 2, {stderr: true}, true, execaSync);\ntest('stripFinalNewline: false with stderr, fd-specific, sync', testStripFinalNewline, 2, {stderr: false}, false, execaSync);\ntest('stripFinalNewline: default with stdio[*], fd-specific, sync', testStripFinalNewline, 3, {}, true, execaSync);\ntest('stripFinalNewline: true with stdio[*], fd-specific, sync', testStripFinalNewline, 3, {fd3: true}, true, execaSync);\ntest('stripFinalNewline: false with stdio[*], fd-specific, sync', testStripFinalNewline, 3, {fd3: false}, false, execaSync);\n\ntest('stripFinalNewline is not used in objectMode', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', `${foobarString}\\n`], {stripFinalNewline: true, stdout: noopGenerator(true, false, true)});\n\tt.deepEqual(stdout, [`${foobarString}\\n`]);\n});\n"
  },
  {
    "path": "test/ipc/buffer-messages.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarArray} from '../helpers/input.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst testResultIpc = async (t, options) => {\n\tconst {ipcOutput} = await execa('ipc-send-twice.js', {...options, ipc: true});\n\tt.deepEqual(ipcOutput, foobarArray);\n};\n\ntest('Sets result.ipcOutput', testResultIpc, {});\ntest('Sets result.ipcOutput, fd-specific buffer', testResultIpc, {buffer: {stdout: false}});\n\nconst testResultNoBuffer = async (t, options) => {\n\tconst {ipcOutput} = await execa('ipc-send.js', {...options, ipc: true});\n\tt.deepEqual(ipcOutput, []);\n};\n\ntest('Sets empty result.ipcOutput if buffer is false', testResultNoBuffer, {buffer: false});\ntest('Sets empty result.ipcOutput if buffer is false, fd-specific buffer', testResultNoBuffer, {buffer: {ipc: false}});\n\ntest('Can use IPC methods when buffer is false', async t => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true, buffer: false});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Sets empty result.ipcOutput if ipc is false', async t => {\n\tconst {ipcOutput} = await execa('empty.js');\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Sets empty result.ipcOutput, sync', t => {\n\tconst {ipcOutput} = execaSync('empty.js');\n\tt.deepEqual(ipcOutput, []);\n});\n\nconst testErrorIpc = async (t, options) => {\n\tconst {ipcOutput} = await t.throwsAsync(execa('ipc-send-fail.js', {...options, ipc: true}));\n\tt.deepEqual(ipcOutput, [foobarString]);\n};\n\ntest('Sets error.ipcOutput', testErrorIpc, {});\ntest('Sets error.ipcOutput, fd-specific buffer', testErrorIpc, {buffer: {stdout: false}});\n\nconst testErrorNoBuffer = async (t, options) => {\n\tconst {ipcOutput} = await t.throwsAsync(execa('ipc-send-fail.js', {...options, ipc: true}));\n\tt.deepEqual(ipcOutput, []);\n};\n\ntest('Sets empty error.ipcOutput if buffer is false', testErrorNoBuffer, {buffer: false});\ntest('Sets empty error.ipcOutput if buffer is false, fd-specific buffer', testErrorNoBuffer, {buffer: {ipc: false}});\n\ntest('Sets empty error.ipcOutput if ipc is false', async t => {\n\tconst {ipcOutput} = await t.throwsAsync(execa('fail.js'));\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Sets empty error.ipcOutput, sync', t => {\n\tconst {ipcOutput} = t.throws(() => execaSync('fail.js'));\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest.serial('Can retrieve initial IPC messages under heavy load', async t => {\n\tawait Promise.all(\n\t\tArray.from({length: PARALLEL_COUNT}, async (_, index) => {\n\t\t\tconst {ipcOutput} = await execa('ipc-send-argv.js', [`${index}`], {ipc: true});\n\t\t\tt.deepEqual(ipcOutput, [`${index}`]);\n\t\t}),\n\t);\n});\n"
  },
  {
    "path": "test/ipc/forward.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarArray} from '../helpers/input.js';\nimport {iterateAllMessages, alwaysPass} from '../helpers/ipc.js';\n\nsetFixtureDirectory();\n\nconst testParentErrorOne = async (t, filter, buffer) => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true, buffer});\n\n\tconst promise = subprocess.getOneMessage({filter});\n\tconst cause = new Error(foobarString);\n\tsubprocess.emit('error', cause);\n\tt.is(await promise, foobarString);\n\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.exitCode, undefined);\n\tt.false(error.isTerminated);\n\tt.is(error.cause, cause);\n\tif (buffer) {\n\t\tt.deepEqual(error.ipcOutput, [foobarString]);\n\t}\n};\n\ntest('\"error\" event does not interrupt subprocess.getOneMessage(), buffer false', testParentErrorOne, undefined, false);\ntest('\"error\" event does not interrupt subprocess.getOneMessage(), buffer true', testParentErrorOne, undefined, true);\ntest('\"error\" event does not interrupt subprocess.getOneMessage(), buffer false, filter', testParentErrorOne, alwaysPass, false);\ntest('\"error\" event does not interrupt subprocess.getOneMessage(), buffer true, filter', testParentErrorOne, alwaysPass, true);\n\nconst testSubprocessErrorOne = async (t, filter, buffer) => {\n\tconst subprocess = execa('ipc-process-error.js', [`${filter}`], {ipc: true, buffer});\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tif (buffer) {\n\t\tt.deepEqual(ipcOutput, [foobarString]);\n\t}\n};\n\ntest('\"error\" event does not interrupt exports.getOneMessage(), buffer false', testSubprocessErrorOne, false, false);\ntest('\"error\" event does not interrupt exports.getOneMessage(), buffer true', testSubprocessErrorOne, false, true);\ntest('\"error\" event does not interrupt exports.getOneMessage(), buffer false, filter', testSubprocessErrorOne, true, false);\ntest('\"error\" event does not interrupt exports.getOneMessage(), buffer true, filter', testSubprocessErrorOne, true, true);\n\nconst testParentErrorEach = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send-twice.js', {ipc: true, buffer});\n\n\tconst promise = iterateAllMessages(subprocess);\n\tconst cause = new Error(foobarString);\n\tsubprocess.emit('error', cause);\n\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error, await t.throwsAsync(promise));\n\tt.is(error.exitCode, undefined);\n\tt.false(error.isTerminated);\n\tt.is(error.cause, cause);\n\tif (buffer) {\n\t\tt.deepEqual(error.ipcOutput, foobarArray);\n\t}\n};\n\ntest('\"error\" event does not interrupt subprocess.getEachMessage(), buffer false', testParentErrorEach, false);\ntest('\"error\" event does not interrupt subprocess.getEachMessage(), buffer true', testParentErrorEach, true);\n\nconst testSubprocessErrorEach = async (t, filter, buffer) => {\n\tconst subprocess = execa('ipc-iterate-error.js', [`${filter}`], {ipc: true, buffer});\n\tawait subprocess.sendMessage('.');\n\tt.is(await subprocess.getOneMessage(), '.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tif (buffer) {\n\t\tt.deepEqual(ipcOutput, ['.']);\n\t}\n};\n\ntest('\"error\" event does not interrupt exports.getEachMessage(), buffer false', testSubprocessErrorEach, 'ipc-iterate-error.js', false);\ntest('\"error\" event does not interrupt exports.getEachMessage(), buffer true', testSubprocessErrorEach, 'ipc-iterate-error.js', true);\n\ntest('\"error\" event does not interrupt result.ipcOutput', async t => {\n\tconst subprocess = execa('ipc-echo-twice.js', {ipcInput: foobarString});\n\n\tconst cause = new Error(foobarString);\n\tsubprocess.emit('error', cause);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.exitCode, undefined);\n\tt.false(error.isTerminated);\n\tt.is(error.cause, cause);\n\tt.deepEqual(error.ipcOutput, [foobarString, foobarString]);\n});\n"
  },
  {
    "path": "test/ipc/get-each.js",
    "content": "import {scheduler} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarArray} from '../helpers/input.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\nimport {iterateAllMessages} from '../helpers/ipc.js';\n\nsetFixtureDirectory();\n\ntest('Can iterate over IPC messages', async t => {\n\tlet count = 0;\n\tconst subprocess = execa('ipc-send-twice.js', {ipc: true});\n\tfor await (const message of subprocess.getEachMessage()) {\n\t\tt.is(message, foobarArray[count++]);\n\t}\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, foobarArray);\n});\n\ntest('Can iterate over IPC messages in subprocess', async t => {\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true});\n\n\tawait subprocess.sendMessage('.');\n\tawait subprocess.sendMessage('.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.', '.']);\n});\n\ntest('subprocess.getEachMessage() can be called twice at the same time', async t => {\n\tconst subprocess = execa('ipc-send-twice.js', {ipc: true});\n\tt.deepEqual(\n\t\tawait Promise.all([iterateAllMessages(subprocess), iterateAllMessages(subprocess)]),\n\t\t[foobarArray, foobarArray],\n\t);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, foobarArray);\n});\n\nconst iterateAndBreak = async (t, subprocess) => {\n\t// eslint-disable-next-line no-unreachable-loop\n\tfor await (const message of subprocess.getEachMessage()) {\n\t\tt.is(message, foobarString);\n\t\tbreak;\n\t}\n};\n\ntest('Breaking in subprocess.getEachMessage() disconnects', async t => {\n\tconst subprocess = execa('ipc-iterate-send.js', {ipc: true});\n\tawait iterateAndBreak(t, subprocess);\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Breaking from subprocess.getEachMessage() awaits the subprocess', async t => {\n\tconst subprocess = execa('ipc-send-wait-print.js', {ipc: true});\n\tawait iterateAndBreak(t, subprocess);\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n\tt.is(stdout, '.');\n});\n\ntest('Breaking from exports.getEachMessage() disconnects', async t => {\n\tconst subprocess = execa('ipc-iterate-break.js', {ipc: true});\n\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage(foobarString);\n\tconst ipcError = await t.throwsAsync(subprocess.getOneMessage());\n\tt.true(ipcError.message.includes('subprocess.getOneMessage() could not complete'));\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\nconst iterateAndThrow = async (t, subprocess, cause) => {\n\t// eslint-disable-next-line no-unreachable-loop\n\tfor await (const message of subprocess.getEachMessage()) {\n\t\tt.is(message, foobarString);\n\t\tthrow cause;\n\t}\n};\n\ntest('Throwing from subprocess.getEachMessage() disconnects', async t => {\n\tconst subprocess = execa('ipc-iterate-send.js', {ipc: true});\n\n\tconst cause = new Error(foobarString);\n\tt.is(await t.throwsAsync(iterateAndThrow(t, subprocess, cause)), cause);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Throwing from subprocess.getEachMessage() awaits the subprocess', async t => {\n\tconst subprocess = execa('ipc-send-wait-print.js', {ipc: true});\n\tconst cause = new Error(foobarString);\n\tt.is(await t.throwsAsync(iterateAndThrow(t, subprocess, cause)), cause);\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n\tt.is(stdout, '.');\n});\n\ntest('Throwing from exports.getEachMessage() disconnects', async t => {\n\tconst subprocess = execa('ipc-iterate-throw.js', {ipc: true});\n\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage(foobarString);\n\tconst ipcError = await t.throwsAsync(subprocess.getOneMessage());\n\tt.true(ipcError.message.includes('subprocess.getOneMessage() could not complete'));\n\n\tconst {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(message.includes(`Error: ${foobarString}`));\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest.serial('Can send many messages at once with exports.getEachMessage()', async t => {\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true});\n\tawait Promise.all(Array.from({length: PARALLEL_COUNT}, (_, index) => subprocess.sendMessage(index)));\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, Array.from({length: PARALLEL_COUNT}, (_, index) => index));\n});\n\ntest('subprocess.getOneMessage() can be called multiple times in a row, buffer true', async t => {\n\tconst subprocess = execa('ipc-print-many-each.js', [`${PARALLEL_COUNT}`], {ipc: true});\n\tconst indexes = Array.from({length: PARALLEL_COUNT}, (_, index) => `${index}`);\n\tawait Promise.all(indexes.map(index => subprocess.sendMessage(index)));\n\n\tconst {stdout} = await subprocess;\n\tconst expectedOutput = indexes.join('\\n');\n\tt.is(stdout, expectedOutput);\n});\n\ntest('Disconnecting in the current process stops exports.getEachMessage()', async t => {\n\tconst subprocess = execa('ipc-iterate-print.js', {ipc: true});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage('.');\n\tsubprocess.disconnect();\n\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, '.');\n});\n\ntest('Disconnecting in the subprocess stops subprocess.getEachMessage()', async t => {\n\tconst subprocess = execa('ipc-send-disconnect.js', {ipc: true});\n\tfor await (const message of subprocess.getEachMessage()) {\n\t\tt.is(message, foobarString);\n\t}\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Exiting the subprocess stops subprocess.getEachMessage()', async t => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true});\n\tfor await (const message of subprocess.getEachMessage()) {\n\t\tt.is(message, foobarString);\n\t}\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\nconst testCleanupListeners = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true, buffer});\n\n\tt.is(subprocess.listenerCount('message'), 1);\n\tt.is(subprocess.listenerCount('disconnect'), 1);\n\n\tconst promise = iterateAllMessages(subprocess);\n\tt.is(subprocess.listenerCount('message'), 1);\n\tt.is(subprocess.listenerCount('disconnect'), 1);\n\tt.deepEqual(await promise, [foobarString]);\n\n\tt.is(subprocess.listenerCount('message'), 0);\n\tt.is(subprocess.listenerCount('disconnect'), 0);\n};\n\ntest('Cleans up subprocess.getEachMessage() listeners, buffer false', testCleanupListeners, false);\ntest('Cleans up subprocess.getEachMessage() listeners, buffer true', testCleanupListeners, true);\n\nconst sendContinuousMessages = async subprocess => {\n\twhile (subprocess.connected) {\n\t\tfor (let index = 0; index < 10; index += 1) {\n\t\t\tsubprocess.emit('message', foobarString);\n\t\t}\n\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait scheduler.yield();\n\t}\n};\n\ntest.serial('Handles buffered messages when disconnecting', async t => {\n\tconst subprocess = execa('ipc-send-fail.js', {ipc: true, buffer: false});\n\n\tconst promise = subprocess.getOneMessage();\n\tsubprocess.emit('message', foobarString);\n\tt.is(await promise, foobarString);\n\tsendContinuousMessages(subprocess);\n\n\tconst {exitCode, isTerminated, ipcOutput} = await t.throwsAsync(iterateAllMessages(subprocess));\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.deepEqual(ipcOutput, []);\n});\n"
  },
  {
    "path": "test/ipc/get-one.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarArray} from '../helpers/input.js';\nimport {alwaysPass} from '../helpers/ipc.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\ntest('subprocess.getOneMessage() can filter messages', async t => {\n\tconst subprocess = execa('ipc-send-twice.js', {ipc: true});\n\tconst message = await subprocess.getOneMessage({filter: message => message === foobarArray[1]});\n\tt.is(message, foobarArray[1]);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, foobarArray);\n});\n\ntest('exports.getOneMessage() can filter messages', async t => {\n\tconst subprocess = execa('ipc-echo-filter.js', {ipc: true});\n\tawait subprocess.sendMessage(foobarArray[0]);\n\tawait subprocess.sendMessage(foobarArray[1]);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarArray[1]]);\n});\n\ntest('Throwing from subprocess.getOneMessage() filter disconnects', async t => {\n\tconst subprocess = execa('ipc-send-get.js', {ipc: true});\n\tconst error = new Error(foobarString);\n\tt.is(await t.throwsAsync(subprocess.getOneMessage({\n\t\tfilter() {\n\t\t\tthrow error;\n\t\t},\n\t})), error);\n\n\tconst {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(message.includes('Error: getOneMessage() could not complete'));\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Throwing from exports.getOneMessage() filter disconnects', async t => {\n\tconst subprocess = execa('ipc-get-filter-throw.js', {ipcInput: 0});\n\tawait t.throwsAsync(subprocess.getOneMessage(), {\n\t\tmessage: /subprocess.getOneMessage\\(\\) could not complete/,\n\t});\n\n\tconst {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(message.includes(`Error: ${foobarString}`));\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest.serial('Can retrieve initial IPC messages under heavy load', async t => {\n\tawait Promise.all(\n\t\tArray.from({length: PARALLEL_COUNT}, async (_, index) => {\n\t\t\tconst subprocess = execa('ipc-send-argv.js', [`${index}`], {ipc: true, buffer: false});\n\t\t\tt.is(await subprocess.getOneMessage(), `${index}`);\n\t\t\tawait subprocess;\n\t\t}),\n\t);\n});\n\nconst testTwice = async (t, buffer, filter) => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true, buffer});\n\tt.deepEqual(\n\t\tawait Promise.all([subprocess.getOneMessage({filter}), subprocess.getOneMessage({filter})]),\n\t\t[foobarString, foobarString],\n\t);\n\tawait subprocess;\n};\n\ntest('subprocess.getOneMessage() can be called twice at the same time, buffer false', testTwice, false, undefined);\ntest('subprocess.getOneMessage() can be called twice at the same time, buffer true', testTwice, true, undefined);\ntest('subprocess.getOneMessage() can be called twice at the same time, buffer false, filter', testTwice, false, alwaysPass);\ntest('subprocess.getOneMessage() can be called twice at the same time, buffer true, filter', testTwice, true, alwaysPass);\n\nconst testCleanupListeners = async (t, buffer, filter) => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true, buffer});\n\n\tt.is(subprocess.listenerCount('message'), 1);\n\tt.is(subprocess.listenerCount('disconnect'), 1);\n\n\tconst promise = subprocess.getOneMessage({filter});\n\tt.is(subprocess.listenerCount('message'), 1);\n\tt.is(subprocess.listenerCount('disconnect'), 1);\n\n\tt.is(await promise, foobarString);\n\tawait subprocess;\n\n\tt.is(subprocess.listenerCount('message'), 0);\n\tt.is(subprocess.listenerCount('disconnect'), 0);\n};\n\ntest('Cleans up subprocess.getOneMessage() listeners, buffer false', testCleanupListeners, false, undefined);\ntest('Cleans up subprocess.getOneMessage() listeners, buffer true', testCleanupListeners, true, undefined);\ntest('Cleans up subprocess.getOneMessage() listeners, buffer false, filter', testCleanupListeners, false, alwaysPass);\ntest('Cleans up subprocess.getOneMessage() listeners, buffer true, filter', testCleanupListeners, true, alwaysPass);\n\nconst testParentDisconnect = async (t, buffer, filter) => {\n\tconst subprocess = execa('ipc-get-send-get.js', [`${filter}`], {ipc: true, buffer});\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tsubprocess.disconnect();\n\n\tconst {exitCode, isTerminated, message} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tif (buffer) {\n\t\tt.true(message.includes('Error: getOneMessage() could not complete'));\n\t}\n};\n\ntest('subprocess.disconnect() interrupts exports.getOneMessage(), buffer false', testParentDisconnect, false, false);\ntest('subprocess.disconnect() interrupts exports.getOneMessage(), buffer true', testParentDisconnect, true, false);\ntest('subprocess.disconnect() interrupts exports.getOneMessage(), buffer false, filter', testParentDisconnect, false, true);\ntest('subprocess.disconnect() interrupts exports.getOneMessage(), buffer true, filter', testParentDisconnect, true, false);\n\nconst testSubprocessDisconnect = async (t, buffer, filter) => {\n\tconst subprocess = execa('empty.js', {ipc: true, buffer});\n\tconst {message} = await t.throwsAsync(subprocess.getOneMessage({filter}));\n\tt.true(message.includes('subprocess.getOneMessage() could not complete'));\n\tawait subprocess;\n};\n\ntest('Subprocess exit interrupts subprocess.getOneMessage(), buffer false', testSubprocessDisconnect, false, undefined);\ntest('Subprocess exit interrupts subprocess.getOneMessage(), buffer true', testSubprocessDisconnect, true, undefined);\ntest('Subprocess exit interrupts subprocess.getOneMessage(), buffer false, filter', testSubprocessDisconnect, false, alwaysPass);\ntest('Subprocess exit interrupts subprocess.getOneMessage(), buffer true, filter', testSubprocessDisconnect, true, alwaysPass);\n"
  },
  {
    "path": "test/ipc/graceful.js",
    "content": "import {getEventListeners} from 'node:events';\nimport {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\ntest('Graceful cancelSignal can be already aborted', async t => {\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(execa('graceful-send.js', {cancelSignal: AbortSignal.abort(foobarString), gracefulCancel: true, forceKillAfterDelay: false}));\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Graceful cancelSignal can be aborted', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-send-twice.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tt.false(await subprocess.getOneMessage());\n\tcontroller.abort(foobarString);\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [false, foobarString]);\n});\n\ntest('Graceful cancelSignal can be never aborted', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-send-fast.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tt.false(await subprocess.getOneMessage());\n\tawait subprocess;\n});\n\ntest('Graceful cancelSignal can be already aborted but not used', async t => {\n\tconst subprocess = execa('ipc-send-get.js', {cancelSignal: AbortSignal.abort(foobarString), gracefulCancel: true, forceKillAfterDelay: false});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait setTimeout(1e3);\n\tawait subprocess.sendMessage('.');\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Graceful cancelSignal can be aborted but not used', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('ipc-send-get.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tcontroller.abort(foobarString);\n\tawait setTimeout(1e3);\n\tawait subprocess.sendMessage(foobarString);\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Graceful cancelSignal can be never aborted nor used', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('empty.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tt.is(getEventListeners(controller.signal, 'abort').length, 1);\n\tawait subprocess;\n\tt.is(getEventListeners(controller.signal, 'abort').length, 0);\n});\n\ntest('Graceful cancelSignal can be aborted twice', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-send-twice.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tt.false(await subprocess.getOneMessage());\n\tcontroller.abort(foobarString);\n\tcontroller.abort('.');\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [false, foobarString]);\n});\n\ntest('Graceful cancelSignal cannot be manually aborted after disconnection', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('empty.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tsubprocess.disconnect();\n\tcontroller.abort(foobarString);\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput, originalMessage} = await t.throwsAsync(subprocess);\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, []);\n\tt.is(originalMessage, '`cancelSignal`\\'s `controller.abort()` cannot be used: the subprocess has already exited or disconnected.');\n});\n\ntest('Graceful cancelSignal can disconnect after being manually aborted', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-disconnect.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tcontroller.abort(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tsubprocess.disconnect();\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Graceful cancelSignal is automatically aborted on disconnection', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-send-print.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tt.false(await subprocess.getOneMessage());\n\tsubprocess.disconnect();\n\tconst {isCanceled, isGracefullyCanceled, ipcOutput, stdout} = await subprocess;\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.deepEqual(ipcOutput, [false]);\n\tt.true(stdout.includes('Error: `cancelSignal` aborted: the parent process disconnected.'));\n});\n\ntest('getCancelSignal() aborts if already disconnected', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-print.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tsubprocess.disconnect();\n\tconst {isCanceled, isGracefullyCanceled, ipcOutput, stdout} = await subprocess;\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.deepEqual(ipcOutput, []);\n\tt.true(stdout.includes('Error: `cancelSignal` aborted: the parent process disconnected.'));\n});\n\ntest('getCancelSignal() fails if no IPC', async t => {\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput, stderr} = await t.throwsAsync(execa('graceful-none.js'));\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 1);\n\tt.deepEqual(ipcOutput, []);\n\tt.true(stderr.includes('Error: `getCancelSignal()` cannot be used without setting the `cancelSignal` subprocess option.'));\n});\n\ntest.serial('getCancelSignal() hangs if cancelSignal without gracefulCancel', async t => {\n\tconst controller = new AbortController();\n\tconst {timedOut, isCanceled, isGracefullyCanceled, signal, ipcOutput} = await t.throwsAsync(execa('graceful-wait.js', {ipc: true, cancelSignal: controller.signal, timeout: 1e3}));\n\tt.true(timedOut);\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.is(signal, 'SIGTERM');\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Subprocess cancelSignal does not keep subprocess alive', async t => {\n\tconst controller = new AbortController();\n\tconst {ipcOutput} = await execa('graceful-ref.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Subprocess can send a message right away', async t => {\n\tconst controller = new AbortController();\n\tconst {ipcOutput} = await execa('graceful-send-string.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Subprocess can receive a message right away', async t => {\n\tconst controller = new AbortController();\n\tconst {ipcOutput} = await execa('graceful-echo.js', {cancelSignal: controller.signal, gracefulCancel: true, ipcInput: foobarString});\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('getCancelSignal() can be called twice', async t => {\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(execa('graceful-twice.js', {cancelSignal: AbortSignal.abort(foobarString), gracefulCancel: true, forceKillAfterDelay: false}));\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Graceful cancelSignal can use cancelSignal.onabort', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-listener.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tcontroller.abort(foobarString);\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, ['.', foobarString]);\n});\n\ntest('Graceful cancelSignal abort reason cannot be directly received', async t => {\n\tconst subprocess = execa('graceful-send-echo.js', {cancelSignal: AbortSignal.abort(foobarString), gracefulCancel: true, forceKillAfterDelay: false});\n\tawait setTimeout(0);\n\tawait subprocess.sendMessage('.');\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, ['.', foobarString]);\n});\n\ntest('error.isGracefullyCanceled is always false with execaSync()', t => {\n\tconst {isCanceled, isGracefullyCanceled} = execaSync('empty.js');\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n"
  },
  {
    "path": "test/ipc/incoming.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {alwaysPass} from '../helpers/ipc.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst testSeriesParent = async (t, buffer, filter) => {\n\tconst subprocess = execa('ipc-send-many.js', [`${PARALLEL_COUNT}`], {ipc: true, buffer});\n\n\tfor (let index = 0; index < PARALLEL_COUNT; index += 1) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tt.is(await subprocess.getOneMessage({filter}), index);\n\t}\n\n\tconst {ipcOutput} = await subprocess;\n\tif (buffer) {\n\t\tt.deepEqual(ipcOutput, Array.from({length: PARALLEL_COUNT}, (_, index) => index));\n\t}\n};\n\ntest('subprocess.getOneMessage() can be called multiple times in a row, buffer false', testSeriesParent, false, undefined);\ntest('subprocess.getOneMessage() can be called multiple times in a row, buffer true', testSeriesParent, true, undefined);\ntest('subprocess.getOneMessage() can be called multiple times in a row, buffer false, filter', testSeriesParent, false, alwaysPass);\ntest('subprocess.getOneMessage() can be called multiple times in a row, buffer true, filter', testSeriesParent, true, alwaysPass);\n\nconst testSeriesSubprocess = async (t, filter) => {\n\tconst subprocess = execa('ipc-print-many.js', [`${PARALLEL_COUNT}`, `${filter}`], {ipc: true});\n\tconst indexes = Array.from({length: PARALLEL_COUNT}, (_, index) => `${index}`);\n\tawait Promise.all(indexes.map(index => subprocess.sendMessage(index)));\n\n\tconst {stdout} = await subprocess;\n\tconst expectedOutput = indexes.join('\\n');\n\tt.is(stdout, expectedOutput);\n};\n\ntest('exports.getOneMessage() can be called multiple times in a row', testSeriesSubprocess, false);\ntest('exports.getOneMessage() can be called multiple times in a row, filter', testSeriesSubprocess, true);\n\ntest('Can iterate multiple times over IPC messages in subprocess', async t => {\n\tconst subprocess = execa('ipc-iterate-twice.js', {ipc: true});\n\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage('.');\n\tt.is(await subprocess.getOneMessage(), '0.');\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage('.');\n\tt.is(await subprocess.getOneMessage(), '1.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString, '0.', foobarString, '1.']);\n});\n"
  },
  {
    "path": "test/ipc/ipc-input.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testSuccess = async (t, options) => {\n\tconst {ipcOutput} = await execa('ipc-echo.js', {ipcInput: foobarString, ...options});\n\tt.deepEqual(ipcOutput, [foobarString]);\n};\n\ntest('Sends a message with the \"ipcInput\" option, ipc undefined', testSuccess, {});\ntest('Sends a message with the \"ipcInput\" option, ipc true', testSuccess, {ipc: true});\n\ntest('Cannot use the \"ipcInput\" option with \"ipc\" false', t => {\n\tt.throws(() => {\n\t\texeca('empty.js', {ipcInput: foobarString, ipc: false});\n\t}, {message: /unless the `ipc` option is `true`/});\n});\n\ntest('Cannot use the \"ipcInput\" option with execaSync()', t => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', {ipcInput: foobarString});\n\t}, {message: /The \"ipcInput\" option cannot be used with synchronous/});\n});\n\ntest('Invalid \"ipcInput\" option v8 format', t => {\n\tconst {message, cause} = t.throws(() => {\n\t\texeca('empty.js', {ipcInput() {}});\n\t});\n\tt.is(message, 'The `ipcInput` option is not serializable with a structured clone.');\n\tt.is(cause.message, 'ipcInput() {} could not be cloned.');\n});\n\ntest('Invalid \"ipcInput\" option JSON format', t => {\n\tconst {message, cause} = t.throws(() => {\n\t\texeca('empty.js', {ipcInput: 0n, serialization: 'json'});\n\t});\n\tt.is(message, 'The `ipcInput` option is not serializable with JSON.');\n\tt.is(cause.message, 'Do not know how to serialize a BigInt');\n});\n\ntest('Handles \"ipcInput\" option during sending', async t => {\n\tconst {message, cause} = await t.throwsAsync(execa('empty.js', {ipcInput: 0n}));\n\tt.true(message.includes('subprocess.sendMessage()\\'s argument type is invalid: the message cannot be serialized: 0.'));\n\tt.true(cause.cause.message.includes('The \"message\" argument must be one of type string'));\n});\n\ntest.serial('Can use \"ipcInput\" option even if the subprocess is not listening to messages', async t => {\n\tconst {ipcOutput} = await execa('empty.js', {ipcInput: foobarString});\n\tt.deepEqual(ipcOutput, []);\n});\n"
  },
  {
    "path": "test/ipc/outgoing.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {alwaysPass, subprocessGetOne, subprocessGetFirst} from '../helpers/ipc.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst testSendHoldParent = async (t, getMessage, buffer, filter) => {\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true, buffer});\n\n\tawait subprocess.sendMessage(0);\n\tt.is(await subprocess.getOneMessage({filter}), 0);\n\n\tconst messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 1);\n\tawait Promise.all([\n\t\t...messages.map(message => subprocess.sendMessage(message)),\n\t\tsubprocess.sendMessage(foobarString),\n\t\tsubprocess.emit('message', '.'),\n\t]);\n\tt.is(await getMessage(subprocess, {filter}), '.');\n\n\tconst {ipcOutput} = await subprocess;\n\tif (buffer) {\n\t\tconst expectedOutput = [0, '.', ...messages];\n\t\tt.deepEqual(ipcOutput, expectedOutput);\n\t}\n};\n\ntest('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', testSendHoldParent, subprocessGetOne, false, undefined);\ntest('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', testSendHoldParent, subprocessGetOne, true, undefined);\ntest('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParent, subprocessGetOne, false, alwaysPass);\ntest('Multiple parallel subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParent, subprocessGetOne, true, alwaysPass);\ntest('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', testSendHoldParent, subprocessGetFirst, false, undefined);\ntest('Multiple parallel subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', testSendHoldParent, subprocessGetFirst, true, undefined);\n\nconst testSendHoldSubprocess = async (t, filter, isGetEach) => {\n\tconst {ipcOutput} = await execa('ipc-iterate-back.js', [`${filter}`, `${isGetEach}`], {ipcInput: 0});\n\tconst expectedOutput = [...Array.from({length: PARALLEL_COUNT + 1}, (_, index) => index), '.'];\n\tt.deepEqual(ipcOutput, expectedOutput);\n};\n\ntest('Multiple parallel exports.sendMessage() + exports.getOneMessage()', testSendHoldSubprocess, false, false);\ntest('Multiple parallel exports.sendMessage() + exports.getOneMessage(), filter', testSendHoldSubprocess, true, false);\ntest('Multiple parallel exports.sendMessage() + exports.getEachMessage()', testSendHoldSubprocess, false, true);\n\nconst testSendHoldParentSerial = async (t, getMessage, buffer, filter) => {\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true, buffer});\n\n\tawait subprocess.sendMessage(0);\n\tt.is(await subprocess.getOneMessage({filter}), 0);\n\n\tconst promise = subprocess.sendMessage(1);\n\tsubprocess.emit('message', '.');\n\tawait promise;\n\n\tconst messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index + 2);\n\tfor (const message of messages) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait subprocess.sendMessage(message);\n\t}\n\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tif (buffer) {\n\t\tconst expectedOutput = [0, '.', 1, ...messages];\n\t\tt.deepEqual(ipcOutput, expectedOutput);\n\t}\n};\n\ntest('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false', testSendHoldParentSerial, subprocessGetOne, false, undefined);\ntest('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true', testSendHoldParentSerial, subprocessGetOne, true, undefined);\ntest('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer false, filter', testSendHoldParentSerial, subprocessGetOne, false, alwaysPass);\ntest('Multiple serial subprocess.sendMessage() + subprocess.getOneMessage(), buffer true, filter', testSendHoldParentSerial, subprocessGetOne, true, alwaysPass);\ntest('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer false', testSendHoldParentSerial, subprocessGetFirst, false, undefined);\ntest('Multiple serial subprocess.sendMessage() + subprocess.getEachMessage(), buffer true', testSendHoldParentSerial, subprocessGetFirst, true, undefined);\n\nconst testSendHoldSubprocessSerial = async (t, filter, isGetEach) => {\n\tconst {ipcOutput} = await execa('ipc-iterate-back-serial.js', [`${filter}`, `${isGetEach}`], {ipcInput: 0});\n\tconst expectedOutput = [...Array.from({length: PARALLEL_COUNT + 2}, (_, index) => index), '.'];\n\tt.deepEqual(ipcOutput, expectedOutput);\n};\n\ntest('Multiple serial exports.sendMessage() + exports.getOneMessage()', testSendHoldSubprocessSerial, false, false);\ntest('Multiple serial exports.sendMessage() + exports.getOneMessage(), filter', testSendHoldSubprocessSerial, true, false);\ntest('Multiple serial exports.sendMessage() + exports.getEachMessage()', testSendHoldSubprocessSerial, false, true);\n"
  },
  {
    "path": "test/ipc/pending.js",
    "content": "import {once} from 'node:events';\nimport {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testBufferInitial = async (t, buffer) => {\n\tconst subprocess = execa('ipc-echo-wait.js', {buffer, ipcInput: foobarString});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString] : []);\n};\n\ntest('Buffers initial message to subprocess, buffer false', testBufferInitial, false);\ntest('Buffers initial message to subprocess, buffer true', testBufferInitial, true);\n\nconst testBufferInitialSend = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send-echo-wait.js', {buffer, ipcInput: foobarString});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? ['.', foobarString] : []);\n};\n\ntest('sendMessage() does not empty the initial message buffering, buffer false', testBufferInitialSend, false);\ntest('sendMessage() does not empty the initial message buffering, buffer true', testBufferInitialSend, true);\n\nconst testBufferInitialStrict = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send-echo-strict.js', {buffer, ipcInput: foobarString});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tawait setTimeout(1e3);\n\tconst promise = subprocess.getOneMessage();\n\tawait subprocess.sendMessage('..');\n\tt.is(await promise, '..');\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? ['.', '..'] : []);\n};\n\ntest('sendMessage() with \"strict\" empties the initial message buffering, buffer false', testBufferInitialStrict, false);\ntest('sendMessage() with \"strict\" empties the initial message buffering, buffer true', testBufferInitialStrict, true);\n\nconst testNoBufferInitial = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send-print.js', {ipc: true, buffer});\n\tconst [chunk] = await once(subprocess.stdout, 'data');\n\tt.is(chunk.toString(), '.');\n\tawait setTimeout(1e3);\n\tt.is(await Promise.race([setTimeout(0), subprocess.getOneMessage()]), undefined);\n\tawait subprocess.sendMessage('.');\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString] : []);\n};\n\ntest.serial('Does not buffer initial message to current process, buffer false', testNoBufferInitial, false);\ntest.serial('Does not buffer initial message to current process, buffer true', testNoBufferInitial, true);\n\nconst testReplay = async (t, buffer) => {\n\tconst subprocess = execa('ipc-replay.js', {buffer, ipcInput: foobarString});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess.sendMessage('.');\n\tawait setTimeout(2e3);\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString, foobarString] : []);\n};\n\ntest.serial('Does not replay missed messages in subprocess, buffer false', testReplay, false);\ntest.serial('Does not replay missed messages in subprocess, buffer true', testReplay, true);\n\nconst testFastSend = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send-native.js', {ipc: true, buffer});\n\tt.is(await subprocess.getOneMessage(), '.');\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? ['.'] : []);\n};\n\ntest('Subprocess can send messages right away, buffer false', testFastSend, false);\ntest('Subprocess can send messages right away, buffer true', testFastSend, true);\n"
  },
  {
    "path": "test/ipc/reference.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst testReference = async (t, fixtureName) => {\n\tconst {timedOut} = await t.throwsAsync(execa(fixtureName, {ipc: true, timeout: 1e3}));\n\tt.true(timedOut);\n};\n\ntest('exports.getOneMessage() keeps the subprocess alive', testReference, 'ipc-get-ref.js');\ntest('exports.getEachMessage() keeps the subprocess alive', testReference, 'ipc-iterate-ref.js');\n\nconst testUnreference = async (t, fixtureName) => {\n\tconst {ipcOutput} = await execa(fixtureName, {ipc: true});\n\tt.deepEqual(ipcOutput, []);\n};\n\ntest('exports.getOneMessage() does not keep the subprocess alive, reference false', testUnreference, 'ipc-get-unref.js');\ntest('exports.getEachMessage() does not keep the subprocess alive, reference false', testUnreference, 'ipc-iterate-unref.js');\n\ntest('exports.sendMessage() keeps the subprocess alive', async t => {\n\tconst {ipcOutput} = await execa('ipc-send-repeat.js', [`${PARALLEL_COUNT}`], {ipc: true});\n\tconst expectedOutput = Array.from({length: PARALLEL_COUNT}, (_, index) => index);\n\tt.deepEqual(ipcOutput, expectedOutput);\n});\n\ntest('process.send() keeps the subprocess alive', async t => {\n\tconst {ipcOutput, stdout} = await execa('ipc-process-send.js', {ipc: true});\n\tt.deepEqual(ipcOutput, [foobarString]);\n\tt.is(stdout, '.');\n});\n\ntest('process.send() keeps the subprocess alive, after getOneMessage()', async t => {\n\tconst {ipcOutput, stdout} = await execa('ipc-process-send-get.js', {ipcInput: 0});\n\tt.deepEqual(ipcOutput, [foobarString]);\n\tt.is(stdout, '.');\n});\n\ntest('process.send() keeps the subprocess alive, after sendMessage()', async t => {\n\tconst {ipcOutput, stdout} = await execa('ipc-process-send-send.js', {ipc: true});\n\tt.deepEqual(ipcOutput, ['.', foobarString]);\n\tt.is(stdout, '.');\n});\n\ntest('process.once(\"message\") keeps the subprocess alive', async t => {\n\tconst subprocess = execa('ipc-once-message.js', {ipc: true});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.']);\n\tt.is(stdout, foobarString);\n});\n\ntest('process.once(\"message\") keeps the subprocess alive, after sendMessage()', async t => {\n\tconst subprocess = execa('ipc-once-message-send.js', {ipc: true});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.']);\n\tt.is(stdout, foobarString);\n});\n\ntest('process.once(\"message\") keeps the subprocess alive, after getOneMessage()', async t => {\n\tconst subprocess = execa('ipc-once-message-get.js', {ipc: true});\n\tawait subprocess.sendMessage('.');\n\tt.is(await subprocess.getOneMessage(), '.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.']);\n\tt.is(stdout, foobarString);\n});\n\ntest('process.once(\"disconnect\") keeps the subprocess alive', async t => {\n\tconst subprocess = execa('ipc-once-disconnect.js', {ipc: true});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tsubprocess.disconnect();\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.']);\n\tt.is(stdout, '.');\n});\n\ntest('process.once(\"disconnect\") keeps the subprocess alive, after sendMessage()', async t => {\n\tconst subprocess = execa('ipc-once-disconnect-send.js', {ipc: true});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tt.is(await subprocess.getOneMessage(), '.');\n\tsubprocess.disconnect();\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.', '.']);\n\tt.is(stdout, '.');\n});\n\ntest('process.once(\"disconnect\") does not keep the subprocess alive, after getOneMessage()', async t => {\n\tconst subprocess = execa('ipc-once-disconnect-get.js', {ipc: true});\n\tawait subprocess.sendMessage('.');\n\tt.is(await subprocess.getOneMessage(), '.');\n\tsubprocess.disconnect();\n\n\tconst {ipcOutput, stdout} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.']);\n\tt.is(stdout, '.');\n});\n\ntest('Can call subprocess.disconnect() right away', async t => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true});\n\tsubprocess.disconnect();\n\tt.is(subprocess.channel, null);\n\n\tawait t.throwsAsync(subprocess.getOneMessage(), {\n\t\tmessage: /subprocess.getOneMessage\\(\\) could not complete/,\n\t});\n\tawait t.throwsAsync(subprocess, {\n\t\tmessage: /Error: sendMessage\\(\\) cannot be used/,\n\t});\n});\n\ntest('Can call process.disconnect() right away', async t => {\n\tconst {stdout, stderr} = await t.throwsAsync(execa('ipc-disconnect-get.js', {ipc: true}));\n\tt.is(stdout, 'null');\n\tt.true(stderr.includes('Error: getOneMessage() cannot be used'));\n});\n"
  },
  {
    "path": "test/ipc/send.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\nimport {mockSendIoError} from '../helpers/ipc.js';\n\nsetFixtureDirectory();\n\ntest('Can exchange IPC messages', async t => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tawait subprocess;\n});\n\ntest.serial('Can exchange IPC messages under heavy load', async t => {\n\tawait Promise.all(\n\t\tArray.from({length: PARALLEL_COUNT}, async (_, index) => {\n\t\t\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\t\t\tawait subprocess.sendMessage(index);\n\t\t\tt.is(await subprocess.getOneMessage(), index);\n\t\t\tawait subprocess;\n\t\t}),\n\t);\n});\n\ntest('The \"serialization\" option defaults to \"advanced\"', async t => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\tawait subprocess.sendMessage([0n]);\n\tconst message = await subprocess.getOneMessage();\n\tt.is(message[0], 0n);\n\tawait subprocess;\n});\n\ntest('Can use \"serialization: json\" option', async t => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true, serialization: 'json'});\n\tconst date = new Date();\n\tawait subprocess.sendMessage(date);\n\tt.is(await subprocess.getOneMessage(), date.toJSON());\n\tawait subprocess;\n});\n\ntest('Validates JSON payload with serialization: \"json\"', async t => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true, serialization: 'json'});\n\tawait t.throwsAsync(subprocess.sendMessage([0n]), {message: /serialize a BigInt/});\n\tawait t.throwsAsync(subprocess);\n});\n\nconst BIG_PAYLOAD_SIZE = '.'.repeat(1e6);\n\ntest('Handles backpressure', async t => {\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true});\n\tawait subprocess.sendMessage(BIG_PAYLOAD_SIZE);\n\tt.true(subprocess.send(foobarString));\n\tt.is(await subprocess.getOneMessage(), BIG_PAYLOAD_SIZE);\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [BIG_PAYLOAD_SIZE]);\n});\n\ntest('Disconnects IPC on exports.sendMessage() error', async t => {\n\tconst subprocess = execa('ipc-get-send-get.js', ['false'], {ipc: true});\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {message, cause} = await t.throwsAsync(subprocess.sendMessage(0n));\n\tt.is(message, 'subprocess.sendMessage()\\'s argument type is invalid: the message cannot be serialized: 0.');\n\tt.true(cause.message.includes('The \"message\" argument must be one of type string'));\n\n\tconst {exitCode, isTerminated, stderr} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: getOneMessage() could not complete'));\n});\n\ntest('Disconnects IPC on subprocess.sendMessage() error', async t => {\n\tconst subprocess = execa('ipc-send-error.js', {ipc: true});\n\tconst ipcError = await t.throwsAsync(subprocess.getOneMessage());\n\tt.true(ipcError.message.includes('subprocess.getOneMessage() could not complete'));\n\n\tconst {exitCode, isTerminated, stderr} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage()\\'s argument type is invalid: the message cannot be serialized: 0.'));\n\tt.true(stderr.includes('The \"message\" argument must be one of type string'));\n});\n\n// EPIPE happens based on timing conditions, so we must repeat it until it happens\nconst findEpipeError = async t => {\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tconst error = await t.throwsAsync(getEpipeError());\n\t\tif (error.cause?.code === 'EPIPE') {\n\t\t\treturn error;\n\t\t}\n\t}\n};\n\nconst getEpipeError = async () => {\n\tconst subprocess = execa('delay.js', ['0'], {ipc: true});\n\t// eslint-disable-next-line no-constant-condition\n\twhile (true) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait subprocess.sendMessage('.');\n\t}\n};\n\ntest.serial('Can send messages while the subprocess is closing', async t => {\n\tconst {message} = await findEpipeError(t);\n\tt.is(message, 'subprocess.sendMessage() cannot be used: the subprocess is disconnecting.');\n});\n\ntest('subprocess.sendMessage() handles I/O errors', async t => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\tconst error = mockSendIoError(subprocess);\n\tt.is(await t.throwsAsync(subprocess.sendMessage('.')), error);\n\n\tconst {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(message.includes('Error: getOneMessage()'));\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Does not hold message events on I/O errors', async t => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true});\n\tconst error = mockSendIoError(subprocess);\n\tconst promise = subprocess.sendMessage('.');\n\tsubprocess.emit('message', '.');\n\tt.is(await t.throwsAsync(promise), error);\n\n\tconst {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(message.includes('Error: getOneMessage()'));\n\tt.deepEqual(ipcOutput, ['.']);\n});\n\ntest('exports.sendMessage() handles I/O errors', async t => {\n\tconst {exitCode, isTerminated, message, ipcOutput} = await t.throwsAsync(execa('ipc-send-io-error.js', {ipc: true}));\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(message.includes(`Error: ${foobarString}`));\n\tt.deepEqual(ipcOutput, []);\n});\n"
  },
  {
    "path": "test/ipc/strict.js",
    "content": "import {once} from 'node:events';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {assertMaxListeners} from '../helpers/listeners.js';\nimport {subprocessGetOne, subprocessGetFirst, mockSendIoError} from '../helpers/ipc.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst testStrictSuccessParentOne = async (t, buffer) => {\n\tconst subprocess = execa('ipc-echo.js', {ipc: true, buffer});\n\tawait subprocess.sendMessage(foobarString, {strict: true});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString] : []);\n};\n\ntest('subprocess.sendMessage() \"strict\" succeeds if the subprocess uses exports.getOneMessage(), buffer false', testStrictSuccessParentOne, false);\ntest('subprocess.sendMessage() \"strict\" succeeds if the subprocess uses exports.getOneMessage(), buffer true', testStrictSuccessParentOne, true);\n\nconst testStrictSuccessParentEach = async (t, buffer) => {\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true, buffer});\n\tawait subprocess.sendMessage('.', {strict: true});\n\tt.is(await subprocess.getOneMessage(), '.');\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? ['.'] : []);\n};\n\ntest('subprocess.sendMessage() \"strict\" succeeds if the subprocess uses exports.getEachMessage(), buffer false', testStrictSuccessParentEach, false);\ntest('subprocess.sendMessage() \"strict\" succeeds if the subprocess uses exports.getEachMessage(), buffer true', testStrictSuccessParentEach, true);\n\nconst testStrictMissingParent = async (t, buffer) => {\n\tconst subprocess = execa('ipc-echo-twice.js', {ipcInput: foobarString, buffer});\n\tconst promise = subprocess.getOneMessage();\n\tconst secondPromise = subprocess.sendMessage(foobarString, {strict: true});\n\tconst {message} = await t.throwsAsync(subprocess.sendMessage(foobarString, {strict: true}));\n\tt.is(message, 'subprocess.sendMessage() failed: the subprocess is not listening to incoming messages.');\n\tt.is(await promise, foobarString);\n\tawait secondPromise;\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString, foobarString] : []);\n};\n\ntest('subprocess.sendMessage() \"strict\" fails if the subprocess is not listening, buffer false', testStrictMissingParent, false);\ntest('subprocess.sendMessage() \"strict\" fails if the subprocess is not listening, buffer true', testStrictMissingParent, true);\n\nconst testStrictExit = async (t, buffer) => {\n\tconst subprocess = execa('ipc-send.js', {ipc: true, buffer});\n\tconst {message} = await t.throwsAsync(subprocess.sendMessage(foobarString, {strict: true}));\n\tt.is(message, 'subprocess.sendMessage() failed: the subprocess exited without listening to incoming messages.');\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString] : []);\n};\n\ntest('subprocess.sendMessage() \"strict\" fails if the subprocess exits, buffer false', testStrictExit, false);\ntest('subprocess.sendMessage() \"strict\" fails if the subprocess exits, buffer true', testStrictExit, true);\n\nconst testStrictSuccessSubprocess = async (t, getMessage, buffer) => {\n\tconst subprocess = execa('ipc-send-strict.js', {ipc: true, buffer});\n\tt.is(await getMessage(subprocess), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, buffer ? [foobarString] : []);\n};\n\ntest('exports.sendMessage() \"strict\" succeeds if the current process uses subprocess.getOneMessage(), buffer false', testStrictSuccessSubprocess, subprocessGetOne, false);\ntest('exports.sendMessage() \"strict\" succeeds if the current process uses subprocess.getOneMessage(), buffer true', testStrictSuccessSubprocess, subprocessGetOne, true);\ntest('exports.sendMessage() \"strict\" succeeds if the current process uses subprocess.getEachMessage(), buffer false', testStrictSuccessSubprocess, subprocessGetFirst, false);\ntest('exports.sendMessage() \"strict\" succeeds if the current process uses subprocess.getEachMessage(), buffer true', testStrictSuccessSubprocess, subprocessGetFirst, true);\n\ntest('exports.sendMessage() \"strict\" succeeds if the current process uses result.ipcOutput', async t => {\n\tconst {ipcOutput} = await execa('ipc-send-strict.js', {ipc: true});\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('exports.sendMessage() \"strict\" fails if the current process is not listening, buffer false', async t => {\n\tconst {exitCode, isTerminated, stderr, ipcOutput} = await t.throwsAsync(execa('ipc-send-strict.js', {ipc: true, buffer: {ipc: false}}));\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage() failed: the parent process is not listening to incoming messages.'));\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest.serial('Multiple subprocess.sendMessage() \"strict\" at once', async t => {\n\tconst checkMaxListeners = assertMaxListeners(t);\n\n\tconst subprocess = execa('ipc-iterate.js', {ipc: true});\n\tconst messages = Array.from({length: PARALLEL_COUNT}, (_, index) => index);\n\tawait Promise.all(messages.map(message => subprocess.sendMessage(message, {strict: true})));\n\tawait subprocess.sendMessage(foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, messages);\n\n\tcheckMaxListeners();\n});\n\ntest('subprocess.sendMessage() \"strict\" fails if the subprocess uses once()', async t => {\n\tconst subprocess = execa('ipc-once-message.js', {ipc: true});\n\tconst {message} = await t.throwsAsync(subprocess.sendMessage(foobarString, {strict: true}));\n\tt.is(message, 'subprocess.sendMessage() failed: the subprocess exited without listening to incoming messages.');\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, ['.']);\n});\n\ntest('exports.sendMessage() \"strict\" fails if the current process uses once() and buffer false', async t => {\n\tconst subprocess = execa('ipc-send-strict.js', {ipc: true, buffer: {ipc: false}});\n\tconst [message] = await once(subprocess, 'message');\n\tt.deepEqual(message, {\n\t\tid: 0n,\n\t\ttype: 'execa:ipc:request',\n\t\tmessage: foobarString,\n\t\thasListeners: false,\n\t});\n\n\tconst {exitCode, isTerminated, stderr, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage() failed: the parent process is not listening to incoming messages.'));\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('subprocess.sendMessage() \"strict\" failure disconnects', async t => {\n\tconst subprocess = execa('ipc-echo-twice-wait.js', {ipcInput: foobarString});\n\tconst promise = subprocess.getOneMessage();\n\tconst secondPromise = subprocess.sendMessage(foobarString, {strict: true});\n\tconst {message} = await t.throwsAsync(subprocess.sendMessage(foobarString, {strict: true}));\n\tt.is(message, 'subprocess.sendMessage() failed: the subprocess is not listening to incoming messages.');\n\tt.is(await promise, foobarString);\n\tawait secondPromise;\n\n\tconst {exitCode, isTerminated, stderr, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage() cannot be used: the parent process has already exited or disconnected.'));\n\tt.deepEqual(ipcOutput, [foobarString, foobarString]);\n});\n\ntest('exports.sendMessage() \"strict\" failure disconnects', async t => {\n\tconst {exitCode, isTerminated, stderr, ipcOutput} = await t.throwsAsync(execa('ipc-send-strict-catch.js', {ipc: true, buffer: {ipc: false}}));\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage() cannot be used: the parent process has already exited or disconnected.'));\n\tt.deepEqual(ipcOutput, []);\n});\n\nconst testIoErrorParent = async (t, getMessage) => {\n\tconst subprocess = execa('ipc-send-strict.js', {ipc: true});\n\tconst cause = mockSendIoError(subprocess);\n\tconst error = await t.throwsAsync(getMessage(subprocess));\n\tt.true(error.message.includes('subprocess.sendMessage() failed when sending an acknowledgment response to the subprocess.'));\n\tt.is(getMessage === subprocessGetOne ? error.cause : error.cause.cause, cause);\n\n\tconst {exitCode, isTerminated, stderr, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage() failed: the parent process exited without listening to incoming messages.'));\n\tt.deepEqual(ipcOutput, []);\n};\n\ntest('subprocess.getOneMessage() acknowledgment I/O error', testIoErrorParent, subprocessGetOne);\ntest('subprocess.getEachMessage() acknowledgment I/O error', testIoErrorParent, subprocessGetFirst);\n\nconst testIoErrorSubprocess = async (t, fixtureName) => {\n\tconst subprocess = execa(fixtureName, {ipc: true});\n\tconst {message} = await t.throwsAsync(subprocess.sendMessage(foobarString, {strict: true}));\n\tt.is(message, 'subprocess.sendMessage() failed: the subprocess exited without listening to incoming messages.');\n\n\tconst {exitCode, isTerminated, stdout, stderr, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.is(stdout, '');\n\tt.true(stderr.includes('Error: sendMessage() failed when sending an acknowledgment response to the parent process.'));\n\tt.true(stderr.includes(`Error: ${foobarString}`));\n\tt.deepEqual(ipcOutput, []);\n};\n\ntest('exports.getOneMessage() acknowledgment I/O error', testIoErrorSubprocess, 'ipc-get-io-error.js');\ntest('exports.getEachMessage() acknowledgment I/O error', testIoErrorSubprocess, 'ipc-iterate-io-error.js');\n\ntest('Opposite sendMessage() \"strict\", buffer true', async t => {\n\tconst subprocess = execa('ipc-send-strict-get.js', {ipc: true});\n\tawait subprocess.sendMessage(foobarString, {strict: true});\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString, foobarString]);\n});\n\ntest('Opposite sendMessage() \"strict\", current process listening, buffer false', async t => {\n\tconst subprocess = execa('ipc-send-strict-get.js', {ipc: true, buffer: {ipc: false}});\n\tconst [message] = await Promise.all([\n\t\tsubprocess.getOneMessage(),\n\t\tsubprocess.sendMessage(foobarString, {strict: true}),\n\t]);\n\tt.is(message, foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Opposite sendMessage() \"strict\", subprocess listening, buffer false', async t => {\n\tconst subprocess = execa('ipc-send-strict-listen.js', {ipc: true, buffer: {ipc: false}});\n\tawait subprocess.sendMessage(foobarString, {strict: true});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('Opposite sendMessage() \"strict\", not listening, buffer false', async t => {\n\tconst subprocess = execa('ipc-send-strict.js', {ipc: true, buffer: {ipc: false}});\n\tconst {message} = await t.throwsAsync(subprocess.sendMessage(foobarString, {strict: true}));\n\tt.true(message.startsWith('subprocess.sendMessage() failed: the subprocess is sending a message too, instead of listening to incoming messages.'));\n\n\tconst {exitCode, isTerminated, stderr, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.false(isTerminated);\n\tt.true(stderr.includes('Error: sendMessage() failed: the parent process is sending a message too, instead of listening to incoming messages.'));\n\tt.deepEqual(ipcOutput, []);\n});\n"
  },
  {
    "path": "test/ipc/validation.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getStdio} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst stdioIpc = getStdio(3, 'ipc');\n\nconst testRequiredIpcSubprocess = async (t, methodName, options) => {\n\tconst subprocess = execa('empty.js', options);\n\tconst {message} = await t.throws(() => subprocess[methodName]());\n\tt.true(message.includes(`subprocess.${methodName}() can only be used`));\n\tawait subprocess;\n};\n\ntest('Cannot use subprocess.sendMessage() without ipc option', testRequiredIpcSubprocess, 'sendMessage', {});\ntest('Cannot use subprocess.sendMessage() with ipc: false', testRequiredIpcSubprocess, 'sendMessage', {ipc: false});\ntest('Cannot use subprocess.sendMessage() with stdio: [..., \"ipc\"]', testRequiredIpcSubprocess, 'sendMessage', stdioIpc);\ntest('Cannot use subprocess.getOneMessage() without ipc option', testRequiredIpcSubprocess, 'getOneMessage', {});\ntest('Cannot use subprocess.getOneMessage() with ipc: false', testRequiredIpcSubprocess, 'getOneMessage', {ipc: false});\ntest('Cannot use subprocess.getOneMessage() with stdio: [..., \"ipc\"]', testRequiredIpcSubprocess, 'getOneMessage', stdioIpc);\ntest('Cannot use subprocess.getEachMessage() without ipc option', testRequiredIpcSubprocess, 'getEachMessage', {});\ntest('Cannot use subprocess.getEachMessage() with ipc: false', testRequiredIpcSubprocess, 'getEachMessage', {ipc: false});\ntest('Cannot use subprocess.getEachMessage() with stdio: [..., \"ipc\"]', testRequiredIpcSubprocess, 'getEachMessage', stdioIpc);\n\nconst testRequiredIpcExports = async (t, methodName, options) => {\n\tconst {message} = await t.throwsAsync(execa('ipc-any.js', [methodName], options));\n\tt.true(message.includes(`${methodName}() can only be used`));\n};\n\ntest('Cannot use exports.sendMessage() without ipc option', testRequiredIpcExports, 'sendMessage', {});\ntest('Cannot use exports.sendMessage() with ipc: false', testRequiredIpcExports, 'sendMessage', {ipc: false});\ntest('Cannot use exports.getOneMessage() without ipc option', testRequiredIpcExports, 'getOneMessage', {});\ntest('Cannot use exports.getOneMessage() with ipc: false', testRequiredIpcExports, 'getOneMessage', {ipc: false});\ntest('Cannot use exports.getEachMessage() without ipc option', testRequiredIpcExports, 'getEachMessage', {});\ntest('Cannot use exports.getEachMessage() with ipc: false', testRequiredIpcExports, 'getEachMessage', {ipc: false});\n\nconst testPostDisconnection = async (t, methodName) => {\n\tconst subprocess = execa('empty.js', {ipc: true});\n\tawait subprocess;\n\tconst {message} = t.throws(() => subprocess[methodName](foobarString));\n\tt.true(message.includes(`subprocess.${methodName}() cannot be used`));\n};\n\ntest('subprocess.sendMessage() after disconnection', testPostDisconnection, 'sendMessage');\ntest('subprocess.getOneMessage() after disconnection', testPostDisconnection, 'getOneMessage');\ntest('subprocess.getEachMessage() after disconnection', testPostDisconnection, 'getEachMessage');\n\nconst testPostDisconnectionSubprocess = async (t, methodName) => {\n\tconst subprocess = execa('ipc-disconnect.js', [methodName], {ipc: true});\n\tsubprocess.disconnect();\n\tconst {message} = await t.throwsAsync(subprocess);\n\tt.true(message.includes(`${methodName}() cannot be used`));\n};\n\ntest('exports.sendMessage() after disconnection', testPostDisconnectionSubprocess, 'sendMessage');\ntest('exports.getOneMessage() after disconnection', testPostDisconnectionSubprocess, 'getOneMessage');\ntest('exports.getEachMessage() after disconnection', testPostDisconnectionSubprocess, 'getEachMessage');\n\nconst INVALID_TYPE_MESSAGE = 'The \"message\" argument must be one of type string';\nconst UNDEFINED_MESSAGE = 'The \"message\" argument must be specified';\nconst CLONE_MESSAGE = 'could not be cloned';\nconst CYCLE_MESSAGE = 'Converting circular structure to JSON';\nconst MAX_CALL_STACK_MESSAGE = 'Maximum call stack size exceeded';\n\nconst testInvalidPayload = async (t, serialization, message, expectedMessage) => {\n\tconst subprocess = execa('empty.js', {ipc: true, serialization});\n\tconst error = await t.throwsAsync(subprocess.sendMessage(message));\n\tt.true(error.message.includes('subprocess.sendMessage()\\'s argument type is invalid: the message cannot be serialized'));\n\tt.true(error.cause.message.includes(expectedMessage));\n\tawait subprocess;\n};\n\nconst cycleObject = {};\ncycleObject.self = cycleObject;\nconst toJsonCycle = {toJSON: () => ({test: true, toJsonCycle})};\n\ntest('subprocess.sendMessage() cannot send undefined', testInvalidPayload, 'advanced', undefined, UNDEFINED_MESSAGE);\ntest('subprocess.sendMessage() cannot send bigints', testInvalidPayload, 'advanced', 0n, INVALID_TYPE_MESSAGE);\ntest('subprocess.sendMessage() cannot send symbols', testInvalidPayload, 'advanced', Symbol('test'), INVALID_TYPE_MESSAGE);\ntest('subprocess.sendMessage() cannot send functions', testInvalidPayload, 'advanced', () => {}, INVALID_TYPE_MESSAGE);\ntest('subprocess.sendMessage() cannot send promises', testInvalidPayload, 'advanced', Promise.resolve(), CLONE_MESSAGE);\ntest('subprocess.sendMessage() cannot send proxies', testInvalidPayload, 'advanced', new Proxy({}, {}), CLONE_MESSAGE);\ntest('subprocess.sendMessage() cannot send Intl', testInvalidPayload, 'advanced', new Intl.Collator(), CLONE_MESSAGE);\ntest('subprocess.sendMessage() cannot send undefined, JSON', testInvalidPayload, 'json', undefined, UNDEFINED_MESSAGE);\ntest('subprocess.sendMessage() cannot send bigints, JSON', testInvalidPayload, 'json', 0n, INVALID_TYPE_MESSAGE);\ntest('subprocess.sendMessage() cannot send symbols, JSON', testInvalidPayload, 'json', Symbol('test'), INVALID_TYPE_MESSAGE);\ntest('subprocess.sendMessage() cannot send functions, JSON', testInvalidPayload, 'json', () => {}, INVALID_TYPE_MESSAGE);\ntest('subprocess.sendMessage() cannot send cycles, JSON', testInvalidPayload, 'json', cycleObject, CYCLE_MESSAGE);\ntest('subprocess.sendMessage() cannot send cycles in toJSON(), JSON', testInvalidPayload, 'json', toJsonCycle, MAX_CALL_STACK_MESSAGE);\n\ntest('exports.sendMessage() validates payload', async t => {\n\tconst subprocess = execa('ipc-echo-item.js', {ipc: true});\n\tawait subprocess.sendMessage([undefined]);\n\tconst {message} = await t.throwsAsync(subprocess);\n\tt.true(message.includes('Error: sendMessage()\\'s argument type is invalid: the message cannot be serialized'));\n\tt.true(message.includes(UNDEFINED_MESSAGE));\n});\n"
  },
  {
    "path": "test/methods/bind.js",
    "content": "import path from 'node:path';\nimport test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\texecaNode,\n\t$,\n} from '../../index.js';\nimport {foobarString, foobarUppercase} from '../helpers/input.js';\nimport {uppercaseGenerator} from '../helpers/generator.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');\nconst PRINT_ENV_PATH = path.join(FIXTURES_DIRECTORY, 'environment.js');\n\nconst testBindOptions = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);\n\tt.is(stdout, `${foobarString}\\n`);\n};\n\ntest('execa() can bind options', testBindOptions, execa);\ntest('execaNode() can bind options', testBindOptions, execaNode);\ntest('$ can bind options', testBindOptions, $);\n\nconst testBindOptionsSync = (t, execaMethod) => {\n\tconst {stdout} = execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString]);\n\tt.is(stdout, `${foobarString}\\n`);\n};\n\ntest('execaSync() can bind options', testBindOptionsSync, execaSync);\ntest('$.sync can bind options', testBindOptionsSync, $.sync);\n\nconst testBindPriority = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString], {stripFinalNewline: true});\n\tt.is(stdout, foobarString);\n};\n\ntest('execa() bound options have lower priority', testBindPriority, execa);\ntest('execaSync() bound options have lower priority', testBindPriority, execaSync);\ntest('execaNode() bound options have lower priority', testBindPriority, execaNode);\ntest('$ bound options have lower priority', testBindPriority, $);\ntest('$.sync bound options have lower priority', testBindPriority, $.sync);\n\nconst testBindUndefined = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({stripFinalNewline: false})(NOOP_PATH, [foobarString], {stripFinalNewline: undefined});\n\tt.is(stdout, foobarString);\n};\n\ntest('execa() undefined options use default value', testBindUndefined, execa);\ntest('execaSync() undefined options use default value', testBindUndefined, execaSync);\ntest('execaNode() undefined options use default value', testBindUndefined, execaNode);\ntest('$ undefined options use default value', testBindUndefined, $);\ntest('$.sync undefined options use default value', testBindUndefined, $.sync);\n\nconst testMergeEnv = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: 'bar'}});\n\tt.is(stdout, 'foo\\nbar');\n};\n\ntest('execa() bound options are merged', testMergeEnv, execa);\ntest('execaSync() bound options are merged', testMergeEnv, execaSync);\ntest('execaNode() bound options are merged', testMergeEnv, execaNode);\ntest('$ bound options are merged', testMergeEnv, $);\ntest('$.sync bound options are merged', testMergeEnv, $.sync);\n\nconst testMergeMultiple = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({env: {FOO: 'baz'}})({env: {BAR: 'bar'}})(PRINT_ENV_PATH, {env: {FOO: 'foo'}});\n\tt.is(stdout, 'foo\\nbar');\n};\n\ntest('execa() bound options are merged multiple times', testMergeMultiple, execa);\ntest('execaSync() bound options are merged multiple times', testMergeMultiple, execaSync);\ntest('execaNode() bound options are merged multiple times', testMergeMultiple, execaNode);\ntest('$ bound options are merged multiple times', testMergeMultiple, $);\ntest('$.sync bound options are merged multiple times', testMergeMultiple, $.sync);\n\nconst testMergeFdSpecific = async (t, execaMethod) => {\n\tconst {isMaxBuffer, shortMessage} = await t.throwsAsync(execaMethod({maxBuffer: {stdout: 1}})(NOOP_PATH, [foobarString], {maxBuffer: {stderr: 100}}));\n\tt.true(isMaxBuffer);\n\tt.true(shortMessage.includes('Command\\'s stdout was larger than 1'));\n};\n\ntest('execa() bound options merge fd-specific ones', testMergeFdSpecific, execa);\ntest('execaNode() bound options merge fd-specific ones', testMergeFdSpecific, execaNode);\ntest('$ bound options merge fd-specific ones', testMergeFdSpecific, $);\n\nconst testMergeEnvUndefined = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({env: {FOO: 'foo'}})(PRINT_ENV_PATH, {env: {BAR: undefined}});\n\tt.is(stdout, 'foo\\nundefined');\n};\n\ntest('execa() bound options are merged even if undefined', testMergeEnvUndefined, execa);\ntest('execaSync() bound options are merged even if undefined', testMergeEnvUndefined, execaSync);\ntest('execaNode() bound options are merged even if undefined', testMergeEnvUndefined, execaNode);\ntest('$ bound options are merged even if undefined', testMergeEnvUndefined, $);\ntest('$.sync bound options are merged even if undefined', testMergeEnvUndefined, $.sync);\n\nconst testMergeSpecific = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({stdout: {transform: uppercaseGenerator().transform, objectMode: true}})(NOOP_PATH, {stdout: {transform: uppercaseGenerator().transform}});\n\tt.is(stdout, foobarUppercase);\n};\n\ntest('execa() bound options only merge specific ones', testMergeSpecific, execa);\ntest('execaSync() bound options only merge specific ones', testMergeSpecific, execaSync);\ntest('execaNode() bound options only merge specific ones', testMergeSpecific, execaNode);\ntest('$ bound options only merge specific ones', testMergeSpecific, $);\ntest('$.sync bound options only merge specific ones', testMergeSpecific, $.sync);\n"
  },
  {
    "path": "test/methods/command.js",
    "content": "import path from 'node:path';\nimport test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\t$,\n\texecaNode,\n\texecaCommand,\n\texecaCommandSync,\n\tparseCommandString,\n} from '../../index.js';\nimport {\n\tsetFixtureDirectory,\n\tFIXTURES_DIRECTORY,\n\tFIXTURES_DIRECTORY_URL,\n} from '../helpers/fixtures-directory.js';\nimport {QUOTE} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\nconst STDIN_FIXTURE = path.join(FIXTURES_DIRECTORY, 'stdin.js');\nconst ECHO_FIXTURE_URL = new URL('echo.js', FIXTURES_DIRECTORY_URL);\n\nconst parseAndRunCommand = command => execa`${parseCommandString(command)}`;\n\ntest('execaCommand()', async t => {\n\tconst {stdout} = await execaCommand('echo.js foo bar');\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execa()', async t => {\n\tconst {stdout} = await execa('echo.js', parseCommandString('foo bar'));\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('execaCommandSync()', t => {\n\tconst {stdout} = execaCommandSync('echo.js foo bar');\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execaSync()', t => {\n\tconst {stdout} = execaSync('echo.js', parseCommandString('foo bar'));\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('execaCommand`...`', async t => {\n\tconst {stdout} = await execaCommand`${'echo.js foo bar'}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execa`...`', async t => {\n\tconst {stdout} = await execa`${parseCommandString('echo.js foo bar')}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execa`...`, only arguments', async t => {\n\tconst {stdout} = await execa`echo.js ${parseCommandString('foo bar')}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execa`...`, only some arguments', async t => {\n\tconst {stdout} = await execa`echo.js ${'foo bar'} ${parseCommandString('foo bar')}`;\n\tt.is(stdout, 'foo bar\\nfoo\\nbar');\n});\n\ntest('execaCommandSync`...`', t => {\n\tconst {stdout} = execaCommandSync`${'echo.js foo bar'}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execaSync`...`', t => {\n\tconst {stdout} = execaSync`${parseCommandString('echo.js foo bar')}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execaSync`...`, only arguments', t => {\n\tconst {stdout} = execaSync`echo.js ${parseCommandString('foo bar')}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execaSync`...`, only some arguments', t => {\n\tconst {stdout} = execaSync`echo.js ${'foo bar'} ${parseCommandString('foo bar')}`;\n\tt.is(stdout, 'foo bar\\nfoo\\nbar');\n});\n\ntest('parseCommandString() + $', async t => {\n\tconst {stdout} = await $`${parseCommandString('echo.js foo bar')}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + $.sync', t => {\n\tconst {stdout} = $.sync`${parseCommandString('echo.js foo bar')}`;\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('parseCommandString() + execaNode', async t => {\n\tconst {stdout} = await execaNode(ECHO_FIXTURE_URL, parseCommandString('foo bar'));\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('execaCommand(options)`...`', async t => {\n\tconst {stdout} = await execaCommand({stripFinalNewline: false})`${'echo.js foo bar'}`;\n\tt.is(stdout, 'foo\\nbar\\n');\n});\n\ntest('execaCommandSync(options)`...`', t => {\n\tconst {stdout} = execaCommandSync({stripFinalNewline: false})`${'echo.js foo bar'}`;\n\tt.is(stdout, 'foo\\nbar\\n');\n});\n\ntest('execaCommand(options)()', async t => {\n\tconst {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar');\n\tt.is(stdout, 'foo\\nbar\\n');\n});\n\ntest('execaCommandSync(options)()', t => {\n\tconst {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar');\n\tt.is(stdout, 'foo\\nbar\\n');\n});\n\ntest('execaCommand().pipe(execaCommand())', async t => {\n\tconst {stdout} = await execaCommand('echo.js foo bar').pipe(execaCommand(`node ${STDIN_FIXTURE}`));\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('execaCommand().pipe(...) does not use execaCommand', async t => {\n\tconst {escapedCommand} = await execaCommand('echo.js foo bar').pipe(`node ${STDIN_FIXTURE}`, {reject: false});\n\tt.true(escapedCommand.startsWith(`${QUOTE}node `));\n});\n\ntest('execaCommand() bound options have lower priority', async t => {\n\tconst {stdout} = await execaCommand({stripFinalNewline: false})('echo.js foo bar', {stripFinalNewline: true});\n\tt.is(stdout, 'foo\\nbar');\n});\n\ntest('execaCommandSync() bound options have lower priority', t => {\n\tconst {stdout} = execaCommandSync({stripFinalNewline: false})('echo.js foo bar', {stripFinalNewline: true});\n\tt.is(stdout, 'foo\\nbar');\n});\n\nconst testInvalidArgumentsArray = (t, execaMethod) => {\n\tt.throws(() => execaMethod('echo', ['foo']), {\n\t\tmessage: /The command and its arguments must be passed as a single string/,\n\t});\n};\n\ntest('execaCommand() must not pass an array of arguments', testInvalidArgumentsArray, execaCommand);\ntest('execaCommandSync() must not pass an array of arguments', testInvalidArgumentsArray, execaCommandSync);\n\nconst testInvalidArgumentsTemplate = (t, execaMethod) => {\n\tt.throws(() => execaMethod`echo foo`, {\n\t\tmessage: /The command and its arguments must be passed as a single string/,\n\t});\n};\n\ntest('execaCommand() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommand);\ntest('execaCommandSync() must not pass an array of arguments with a template string', testInvalidArgumentsTemplate, execaCommandSync);\n\nconst testInvalidArgumentsParse = (t, command) => {\n\tt.throws(() => parseCommandString(command), {\n\t\tmessage: /The command must be a string/,\n\t});\n};\n\ntest('execaCommand() must not pass a number', testInvalidArgumentsParse, 0);\ntest('execaCommand() must not pass undefined', testInvalidArgumentsParse, undefined);\ntest('execaCommand() must not pass null', testInvalidArgumentsParse, null);\ntest('execaCommand() must not pass a symbol', testInvalidArgumentsParse, Symbol('test'));\ntest('execaCommand() must not pass an object', testInvalidArgumentsParse, {});\ntest('execaCommand() must not pass an array', testInvalidArgumentsParse, []);\n\nconst testExecaCommandOutput = async (t, command, expectedOutput, execaMethod) => {\n\tconst {stdout} = await execaMethod(command);\n\tt.is(stdout, expectedOutput);\n};\n\ntest('execaCommand() allows escaping spaces in commands', testExecaCommandOutput, 'command\\\\ with\\\\ space.js foo bar', 'foo\\nbar', execaCommand);\ntest('execaCommand() trims', testExecaCommandOutput, '  echo.js foo bar  ', 'foo\\nbar', execaCommand);\ntest('execaCommand() ignores consecutive spaces', testExecaCommandOutput, 'echo.js foo    bar', 'foo\\nbar', execaCommand);\ntest('execaCommand() escapes other whitespaces', testExecaCommandOutput, 'echo.js foo\\tbar', 'foo\\tbar', execaCommand);\ntest('execaCommand() allows escaping spaces', testExecaCommandOutput, 'echo.js foo\\\\ bar', 'foo bar', execaCommand);\ntest('execaCommand() allows escaping backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\ bar', execaCommand);\ntest('execaCommand() allows escaping multiple backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\\\\\\\\\ bar', 'foo\\\\\\\\\\\\ bar', execaCommand);\ntest('execaCommand() allows escaping backslashes not before spaces', testExecaCommandOutput, 'echo.js foo\\\\bar baz', 'foo\\\\bar\\nbaz', execaCommand);\ntest('parseCommandString() allows escaping spaces in commands', testExecaCommandOutput, 'command\\\\ with\\\\ space.js foo bar', 'foo\\nbar', parseAndRunCommand);\ntest('parseCommandString() trims', testExecaCommandOutput, '  echo.js foo bar  ', 'foo\\nbar', parseAndRunCommand);\ntest('parseCommandString() ignores consecutive spaces', testExecaCommandOutput, 'echo.js foo    bar', 'foo\\nbar', parseAndRunCommand);\ntest('parseCommandString() escapes other whitespaces', testExecaCommandOutput, 'echo.js foo\\tbar', 'foo\\tbar', parseAndRunCommand);\ntest('parseCommandString() allows escaping spaces', testExecaCommandOutput, 'echo.js foo\\\\ bar', 'foo bar', parseAndRunCommand);\ntest('parseCommandString() allows escaping backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\ bar', 'foo\\\\ bar', parseAndRunCommand);\ntest('parseCommandString() allows escaping multiple backslashes before spaces', testExecaCommandOutput, 'echo.js foo\\\\\\\\\\\\\\\\ bar', 'foo\\\\\\\\\\\\ bar', parseAndRunCommand);\ntest('parseCommandString() allows escaping backslashes not before spaces', testExecaCommandOutput, 'echo.js foo\\\\bar baz', 'foo\\\\bar\\nbaz', parseAndRunCommand);\n\ntest('parseCommandString() can get empty strings', t => {\n\tt.deepEqual(parseCommandString(''), []);\n});\n\ntest('parseCommandString() can get only whitespaces', t => {\n\tt.deepEqual(parseCommandString('   '), []);\n});\n"
  },
  {
    "path": "test/methods/create.js",
    "content": "import path from 'node:path';\nimport test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\texecaNode,\n\t$,\n} from '../../index.js';\nimport {foobarString, foobarArray} from '../helpers/input.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');\n\nconst testTemplate = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod`${NOOP_PATH} ${foobarString}`;\n\tt.is(stdout, foobarString);\n};\n\ntest('execa() can use template strings', testTemplate, execa);\ntest('execaNode() can use template strings', testTemplate, execaNode);\ntest('$ can use template strings', testTemplate, $);\n\nconst testTemplateSync = (t, execaMethod) => {\n\tconst {stdout} = execaMethod`${NOOP_PATH} ${foobarString}`;\n\tt.is(stdout, foobarString);\n};\n\ntest('execaSync() can use template strings', testTemplateSync, execaSync);\ntest('$.sync can use template strings', testTemplateSync, $.sync);\n\nconst testTemplateOptions = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod({stripFinalNewline: false})`${NOOP_PATH} ${foobarString}`;\n\tt.is(stdout, `${foobarString}\\n`);\n};\n\ntest('execa() can use template strings with options', testTemplateOptions, execa);\ntest('execaNode() can use template strings with options', testTemplateOptions, execaNode);\ntest('$ can use template strings with options', testTemplateOptions, $);\n\nconst testTemplateOptionsSync = (t, execaMethod) => {\n\tconst {stdout} = execaMethod({stripFinalNewline: false})`${NOOP_PATH} ${foobarString}`;\n\tt.is(stdout, `${foobarString}\\n`);\n};\n\ntest('execaSync() can use template strings with options', testTemplateOptionsSync, execaSync);\ntest('$.sync can use template strings with options', testTemplateOptionsSync, $.sync);\n\nconst testSpacedCommand = async (t, commandArguments, execaMethod) => {\n\tconst {stdout} = await execaMethod('command with space.js', commandArguments);\n\tconst expectedStdout = commandArguments === undefined ? '' : commandArguments.join('\\n');\n\tt.is(stdout, expectedStdout);\n};\n\ntest('allow commands with spaces and no array arguments', testSpacedCommand, undefined, execa);\ntest('allow commands with spaces and array arguments', testSpacedCommand, foobarArray, execa);\ntest('allow commands with spaces and no array arguments, execaSync', testSpacedCommand, undefined, execaSync);\ntest('allow commands with spaces and array arguments, execaSync', testSpacedCommand, foobarArray, execaSync);\ntest('allow commands with spaces and no array arguments, $', testSpacedCommand, undefined, $);\ntest('allow commands with spaces and array arguments, $', testSpacedCommand, foobarArray, $);\ntest('allow commands with spaces and no array arguments, $.sync', testSpacedCommand, undefined, $.sync);\ntest('allow commands with spaces and array arguments, $.sync', testSpacedCommand, foobarArray, $.sync);\n"
  },
  {
    "path": "test/methods/main-async.js",
    "content": "import process from 'node:process';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst isWindows = process.platform === 'win32';\n\nif (isWindows) {\n\ttest('execa() - cmd file', async t => {\n\t\tconst {stdout} = await execa('hello.cmd');\n\t\tt.is(stdout, 'Hello World');\n\t});\n\n\ttest('execa() - run cmd command', async t => {\n\t\tconst {stdout} = await execa('cmd', ['/c', 'hello.cmd']);\n\t\tt.is(stdout, 'Hello World');\n\t});\n}\n\ntest('execa() returns a promise with pid', async t => {\n\tconst subprocess = execa('noop.js', ['foo']);\n\tt.is(typeof subprocess.pid, 'number');\n\tawait subprocess;\n});\n"
  },
  {
    "path": "test/methods/node.js",
    "content": "import path from 'node:path';\nimport process, {version} from 'node:process';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport getNode from 'get-node';\nimport {execa, execaSync, execaNode} from '../../index.js';\nimport {FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\nimport {identity, fullStdio} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getDenoNodePath} from '../helpers/file-path.js';\n\nprocess.chdir(FIXTURES_DIRECTORY);\n\nconst runWithNodeOption = (file, commandArguments, options) => Array.isArray(commandArguments)\n\t? execa(file, commandArguments, {...options, node: true})\n\t: execa(file, {...options, node: true});\nconst runWithNodeOptionSync = (file, commandArguments, options) => Array.isArray(commandArguments)\n\t? execaSync(file, commandArguments, {...options, node: true})\n\t: execaSync(file, {...options, node: true});\nconst runWithIpc = (file, options) => execa('node', [file], {...options, ipc: true});\n\nconst testNodeSuccess = async (t, execaMethod) => {\n\tconst {exitCode, stdout} = await execaMethod('noop.js', [foobarString]);\n\tt.is(exitCode, 0);\n\tt.is(stdout, foobarString);\n};\n\ntest('execaNode() succeeds', testNodeSuccess, execaNode);\ntest('The \"node\" option succeeds', testNodeSuccess, runWithNodeOption);\ntest('The \"node\" option succeeds - sync', testNodeSuccess, runWithNodeOptionSync);\n\ntest('execaNode(options) succeeds', async t => {\n\tconst {stdout} = await execaNode({stripFinalNewline: false})('noop.js', [foobarString]);\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('execaNode`...` succeeds', async t => {\n\tconst {stdout} = await execaNode`noop.js ${foobarString}`;\n\tt.is(stdout, foobarString);\n});\n\ntest('execaNode().pipe(execaNode()) succeeds', async t => {\n\tconst {stdout} = await execaNode('noop.js').pipe(execaNode('--version'));\n\tt.is(stdout, version);\n});\n\ntest('execaNode().pipe(execa()) requires using \"node\"', async t => {\n\tawait t.throwsAsync(execaNode('noop.js').pipe(execa('--version')));\n});\n\ntest('execaNode().pipe(...) requires using \"node\"', async t => {\n\tawait t.throwsAsync(execaNode('noop.js').pipe('--version'));\n});\n\ntest('execaNode().pipe`...` requires using \"node\"', async t => {\n\tawait t.throwsAsync(execaNode('noop.js').pipe`--version`);\n});\n\ntest('execaNode() cannot set the \"node\" option to false', t => {\n\tt.throws(() => {\n\t\texecaNode('empty.js', {node: false});\n\t}, {message: /The \"node\" option cannot be false/});\n});\n\nconst testDoubleNode = (t, nodePath, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod(nodePath, ['noop.js']);\n\t}, {message: /does not need to be \"node\"/});\n};\n\ntest('Cannot use \"node\" as binary - execaNode()', testDoubleNode, 'node', execaNode);\ntest('Cannot use \"node\" as binary - \"node\" option', testDoubleNode, 'node', runWithNodeOption);\ntest('Cannot use \"node\" as binary - \"node\" option sync', testDoubleNode, 'node', runWithNodeOptionSync);\ntest('Cannot use path to \"node\" as binary - execaNode()', testDoubleNode, process.execPath, execaNode);\ntest('Cannot use path to \"node\" as binary - \"node\" option', testDoubleNode, process.execPath, runWithNodeOption);\ntest('Cannot use path to \"node\" as binary - \"node\" option sync', testDoubleNode, process.execPath, runWithNodeOptionSync);\ntest('Cannot use deno style nodePath as binary - execaNode()', testDoubleNode, getDenoNodePath(), execaNode);\ntest('Cannot use deno style nodePath as binary - \"node\" option', testDoubleNode, getDenoNodePath(), runWithNodeOption);\ntest('Cannot use deno style nodePath as binary - \"node\" option sync', testDoubleNode, getDenoNodePath(), runWithNodeOptionSync);\n\nconst getNodePath = async () => {\n\tconst {path} = await getNode(TEST_NODE_VERSION);\n\treturn path;\n};\n\nconst TEST_NODE_VERSION = '16.0.0';\n\nconst testNodePath = async (t, execaMethod, mapPath) => {\n\tconst nodePath = mapPath(await getNodePath());\n\tconst {stdout} = await execaMethod('--version', [], {nodePath});\n\tt.is(stdout, `v${TEST_NODE_VERSION}`);\n};\n\ntest.serial('The \"nodePath\" option can be used - execaNode()', testNodePath, execaNode, identity);\ntest.serial('The \"nodePath\" option can be a file URL - execaNode()', testNodePath, execaNode, pathToFileURL);\ntest.serial('The \"nodePath\" option can be used - \"node\" option', testNodePath, runWithNodeOption, identity);\ntest.serial('The \"nodePath\" option can be a file URL - \"node\" option', testNodePath, runWithNodeOption, pathToFileURL);\ntest.serial('The \"nodePath\" option can be used - \"node\" option sync', testNodePath, runWithNodeOptionSync, identity);\ntest.serial('The \"nodePath\" option can be a file URL - \"node\" option sync', testNodePath, runWithNodeOptionSync, pathToFileURL);\n\nconst testNodePathDefault = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod('--version');\n\tt.is(stdout, process.version);\n};\n\ntest('The \"nodePath\" option defaults to the current Node.js binary - execaNode()', testNodePathDefault, execaNode);\ntest('The \"nodePath\" option defaults to the current Node.js binary - \"node\" option', testNodePathDefault, runWithNodeOption);\ntest('The \"nodePath\" option defaults to the current Node.js binary - \"node\" option sync', testNodePathDefault, runWithNodeOptionSync);\n\nconst testNodePathInvalid = (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('noop.js', [], {nodePath: true});\n\t}, {message: /The \"nodePath\" option must be a string or a file URL/});\n};\n\ntest('The \"nodePath\" option must be a string or URL - execaNode()', testNodePathInvalid, execaNode);\ntest('The \"nodePath\" option must be a string or URL - \"node\" option', testNodePathInvalid, runWithNodeOption);\ntest('The \"nodePath\" option must be a string or URL - \"node\" option sync', testNodePathInvalid, runWithNodeOptionSync);\n\nconst testFormerNodePath = (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('noop.js', [], {execPath: process.execPath});\n\t}, {message: /The \"execPath\" option has been removed/});\n};\n\ntest('The \"execPath\" option cannot be used - execaNode()', testFormerNodePath, execaNode);\ntest('The \"execPath\" option cannot be used - \"node\" option', testFormerNodePath, runWithNodeOption);\ntest('The \"execPath\" option cannot be used - \"node\" option sync', testFormerNodePath, runWithNodeOptionSync);\n\nconst nodePathArguments = ['-p', ['process.env.Path || process.env.PATH']];\n\nconst testSubprocessNodePath = async (t, execaMethod, mapPath) => {\n\tconst nodePath = mapPath(await getNodePath());\n\tconst {stdout} = await execaMethod(...nodePathArguments, {nodePath});\n\tt.true(stdout.includes(TEST_NODE_VERSION));\n};\n\ntest.serial('The \"nodePath\" option impacts the subprocess - execaNode()', testSubprocessNodePath, execaNode, identity);\ntest.serial('The \"nodePath\" option impacts the subprocess - \"node\" option', testSubprocessNodePath, runWithNodeOption, identity);\ntest.serial('The \"nodePath\" option impacts the subprocess - \"node\" option sync', testSubprocessNodePath, runWithNodeOptionSync, identity);\n\nconst testSubprocessNodePathDefault = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod(...nodePathArguments);\n\tt.true(stdout.includes(path.dirname(process.execPath)));\n};\n\ntest('The \"nodePath\" option defaults to the current Node.js binary in the subprocess - execaNode()', testSubprocessNodePathDefault, execaNode);\ntest('The \"nodePath\" option defaults to the current Node.js binary in the subprocess - \"node\" option', testSubprocessNodePathDefault, runWithNodeOption);\ntest('The \"nodePath\" option defaults to the current Node.js binary in the subprocess - \"node\" option sync', testSubprocessNodePathDefault, runWithNodeOptionSync);\n\ntest.serial('The \"nodePath\" option requires \"node: true\" to impact the subprocess', async t => {\n\tconst nodePath = await getNodePath();\n\tconst {stdout} = await execa('node', nodePathArguments.flat(), {nodePath});\n\tt.false(stdout.includes(TEST_NODE_VERSION));\n});\n\nconst testSubprocessNodePathCwd = async (t, execaMethod) => {\n\tconst nodePath = await getNodePath();\n\tconst cwd = path.dirname(path.dirname(nodePath));\n\tconst relativeExecPath = path.relative(cwd, nodePath);\n\tconst {stdout} = await execaMethod(...nodePathArguments, {nodePath: relativeExecPath, cwd});\n\tt.true(stdout.includes(TEST_NODE_VERSION));\n};\n\ntest.serial('The \"nodePath\" option is relative to \"cwd\" when used in the subprocess - execaNode()', testSubprocessNodePathCwd, execaNode);\ntest.serial('The \"nodePath\" option is relative to \"cwd\" when used in the subprocess - \"node\" option', testSubprocessNodePathCwd, runWithNodeOption);\ntest.serial('The \"nodePath\" option is relative to \"cwd\" when used in the subprocess - \"node\" option sync', testSubprocessNodePathCwd, runWithNodeOptionSync);\n\nconst testCwdNodePath = async (t, execaMethod) => {\n\tconst nodePath = await getNodePath();\n\tconst cwd = path.dirname(path.dirname(nodePath));\n\tconst relativeExecPath = path.relative(cwd, nodePath);\n\tconst {stdout} = await execaMethod('--version', [], {nodePath: relativeExecPath, cwd});\n\tt.is(stdout, `v${TEST_NODE_VERSION}`);\n};\n\ntest.serial('The \"nodePath\" option is relative to \"cwd\" - execaNode()', testCwdNodePath, execaNode);\ntest.serial('The \"nodePath\" option is relative to \"cwd\" - \"node\" option', testCwdNodePath, runWithNodeOption);\ntest.serial('The \"nodePath\" option is relative to \"cwd\" - \"node\" option sync', testCwdNodePath, runWithNodeOptionSync);\n\nconst testDenoExecPath = async (t, execaMethod) => {\n\tconst {exitCode, stdout} = await execaMethod('noop.js', [], {nodePath: getDenoNodePath()});\n\tt.is(exitCode, 0);\n\tt.is(stdout, foobarString);\n};\n\ntest('The deno style \"nodePath\" option can be used - execaNode()', testDenoExecPath, execaNode);\ntest('The deno style \"nodePath\" option can be used - \"node\" option', testDenoExecPath, runWithNodeOption);\ntest('The deno style \"nodePath\" option can be used - \"node\" option sync', testDenoExecPath, runWithNodeOptionSync);\n\nconst testNodeOptions = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod('empty.js', [], {nodeOptions: ['--version']});\n\tt.is(stdout, process.version);\n};\n\ntest('The \"nodeOptions\" option can be used - execaNode()', testNodeOptions, execaNode);\ntest('The \"nodeOptions\" option can be used - \"node\" option', testNodeOptions, runWithNodeOption);\ntest('The \"nodeOptions\" option can be used - \"node\" option sync', testNodeOptions, runWithNodeOptionSync);\n\nconst spawnNestedExecaNode = (realExecArgv, fakeExecArgv, execaMethod, nodeOptions) => execa(\n\t'node',\n\t[...realExecArgv, 'nested-node.js', fakeExecArgv, execaMethod, nodeOptions, 'noop.js', foobarString],\n\t{...fullStdio, cwd: FIXTURES_DIRECTORY},\n);\n\nconst testInspectRemoval = async (t, fakeExecArgv, execaMethod) => {\n\tconst {stdout, stdio} = await spawnNestedExecaNode([], fakeExecArgv, execaMethod, '');\n\tt.is(stdout, foobarString);\n\tt.is(stdio[3], '');\n};\n\ntest('The \"nodeOptions\" option removes --inspect without a port when defined by current process - execaNode()', testInspectRemoval, '--inspect', 'execaNode');\ntest('The \"nodeOptions\" option removes --inspect without a port when defined by current process - \"node\" option', testInspectRemoval, '--inspect', 'nodeOption');\ntest('The \"nodeOptions\" option removes --inspect with a port when defined by current process - execaNode()', testInspectRemoval, '--inspect=9222', 'execaNode');\ntest('The \"nodeOptions\" option removes --inspect with a port when defined by current process - \"node\" option', testInspectRemoval, '--inspect=9222', 'nodeOption');\ntest('The \"nodeOptions\" option removes --inspect-brk without a port when defined by current process - execaNode()', testInspectRemoval, '--inspect-brk', 'execaNode');\ntest('The \"nodeOptions\" option removes --inspect-brk without a port when defined by current process - \"node\" option', testInspectRemoval, '--inspect-brk', 'nodeOption');\ntest('The \"nodeOptions\" option removes --inspect-brk with a port when defined by current process - execaNode()', testInspectRemoval, '--inspect-brk=9223', 'execaNode');\ntest('The \"nodeOptions\" option removes --inspect-brk with a port when defined by current process - \"node\" option', testInspectRemoval, '--inspect-brk=9223', 'nodeOption');\n\nconst testInspectDifferentPort = async (t, execaMethod) => {\n\tconst {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9225'], '', execaMethod, '--inspect=9224');\n\tt.is(stdout, foobarString);\n\tt.true(stdio[3].includes('Debugger listening'));\n};\n\ntest.serial('The \"nodeOptions\" option allows --inspect with a different port even when defined by current process - execaNode()', testInspectDifferentPort, 'execaNode');\ntest.serial('The \"nodeOptions\" option allows --inspect with a different port even when defined by current process - \"node\" option', testInspectDifferentPort, 'nodeOption');\n\nconst testInspectSamePort = async (t, execaMethod) => {\n\tconst {stdout, stdio} = await spawnNestedExecaNode(['--inspect=9226'], '', execaMethod, '--inspect=9226');\n\tt.is(stdout, foobarString);\n\tt.true(stdio[3].includes('address already in use'));\n};\n\ntest.serial('The \"nodeOptions\" option forbids --inspect with the same port when defined by current process - execaNode()', testInspectSamePort, 'execaNode');\ntest.serial('The \"nodeOptions\" option forbids --inspect with the same port when defined by current process - \"node\" option', testInspectSamePort, 'nodeOption');\n\nconst testIpc = async (t, execaMethod, options) => {\n\tconst subprocess = execaMethod('ipc-echo.js', [], options);\n\n\tawait subprocess.sendMessage(foobarString);\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\n\tconst {stdio} = await subprocess;\n\tt.is(stdio.length, 4);\n\tt.is(stdio[3], undefined);\n};\n\ntest('execaNode() adds an ipc channel', testIpc, execaNode, {});\ntest('The \"node\" option adds an ipc channel', testIpc, runWithNodeOption, {});\ntest('The \"ipc\" option adds an ipc channel', testIpc, runWithIpc, {});\ntest('The \"ipc\" option works with \"stdio: \\'pipe\\'\"', testIpc, runWithIpc, {stdio: 'pipe'});\ntest('The \"ipc\" option works with \"stdio: [\\'pipe\\', \\'pipe\\', \\'pipe\\']\"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe']});\ntest('The \"ipc\" option works with \"stdio: [\\'pipe\\', \\'pipe\\', \\'pipe\\', \\'ipc\\']\"', testIpc, runWithIpc, {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});\ntest('The \"ipc\" option works with \"stdout: \\'pipe\\'\"', testIpc, runWithIpc, {stdout: 'pipe'});\n\nconst NO_SEND_MESSAGE = 'sendMessage() can only be used';\n\ntest('No ipc channel is added by default', async t => {\n\tconst {message, stdio} = await t.throwsAsync(execa('node', ['ipc-send.js']));\n\tt.true(message.includes(NO_SEND_MESSAGE));\n\tt.is(stdio.length, 3);\n});\n\nconst testDisableIpc = async (t, execaMethod) => {\n\tconst {failed, message, stdio} = await execaMethod('ipc-send.js', [], {ipc: false, reject: false});\n\tt.true(failed);\n\tt.true(message.includes(NO_SEND_MESSAGE));\n\tt.is(stdio.length, 3);\n};\n\ntest('Can disable \"ipc\" - execaNode()', testDisableIpc, execaNode);\ntest('Can disable \"ipc\" - \"node\" option', testDisableIpc, runWithNodeOption);\ntest('Can disable \"ipc\" - \"node\" option sync', testDisableIpc, runWithNodeOptionSync);\n\nconst NO_IPC_MESSAGE = /The \"ipc: true\" option cannot be used/;\n\nconst testNoIpcSync = (t, node) => {\n\tt.throws(() => {\n\t\texecaSync('node', ['ipc-send.js'], {ipc: true, node});\n\t}, {message: NO_IPC_MESSAGE});\n};\n\ntest('Cannot use \"ipc: true\" with execaSync()', testNoIpcSync, undefined);\ntest('Cannot use \"ipc: true\" with execaSync() - \"node: false\"', testNoIpcSync, false);\n\ntest('Cannot use \"ipc: true\" with execaSync() - \"node: true\"', t => {\n\tt.throws(() => {\n\t\texecaSync('ipc-send.js', {ipc: true, node: true});\n\t}, {message: NO_IPC_MESSAGE});\n});\n\nconst testNoShell = async (t, execaMethod) => {\n\tconst {failed, message} = await execaMethod('node --version', [], {shell: true, reject: false});\n\tt.true(failed);\n\tt.true(message.includes('MODULE_NOT_FOUND'));\n};\n\ntest('Cannot use \"shell: true\" - execaNode()', testNoShell, execaNode);\ntest('Cannot use \"shell: true\" - \"node\" option', testNoShell, runWithNodeOption);\ntest('Cannot use \"shell: true\" - \"node\" option sync', testNoShell, runWithNodeOptionSync);\n"
  },
  {
    "path": "test/methods/override-promise.js",
    "content": "import test from 'ava';\n// The helper module overrides Promise on import so has to be imported before `execa`.\nimport {restorePromise} from '../helpers/override-promise.js';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nrestorePromise();\nsetFixtureDirectory();\n\ntest('should work with third-party Promise', async t => {\n\tconst {stdout} = await execa('noop.js', ['foo']);\n\tt.is(stdout, 'foo');\n});\n"
  },
  {
    "path": "test/methods/parameters-args.js",
    "content": "import test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\texecaCommand,\n\texecaCommandSync,\n\texecaNode,\n\t$,\n} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst testInvalidArguments = async (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('echo', true);\n\t}, {message: /Second argument must be either/});\n};\n\ntest('execa()\\'s second argument must be valid', testInvalidArguments, execa);\ntest('execaSync()\\'s second argument must be valid', testInvalidArguments, execaSync);\ntest('execaCommand()\\'s second argument must be valid', testInvalidArguments, execaCommand);\ntest('execaCommandSync()\\'s second argument must be valid', testInvalidArguments, execaCommandSync);\ntest('execaNode()\\'s second argument must be valid', testInvalidArguments, execaNode);\ntest('$\\'s second argument must be valid', testInvalidArguments, $);\ntest('$.sync\\'s second argument must be valid', testInvalidArguments, $.sync);\n\nconst testInvalidArgumentsItems = async (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('echo', [{}]);\n\t}, {message: 'Second argument must be an array of strings: [object Object]'});\n};\n\ntest('execa()\\'s second argument must not be objects', testInvalidArgumentsItems, execa);\ntest('execaSync()\\'s second argument must not be objects', testInvalidArgumentsItems, execaSync);\ntest('execaCommand()\\'s second argument must not be objects', testInvalidArgumentsItems, execaCommand);\ntest('execaCommandSync()\\'s second argument must not be objects', testInvalidArgumentsItems, execaCommandSync);\ntest('execaNode()\\'s second argument must not be objects', testInvalidArgumentsItems, execaNode);\ntest('$\\'s second argument must not be objects', testInvalidArgumentsItems, $);\ntest('$.sync\\'s second argument must not be objects', testInvalidArgumentsItems, $.sync);\n\nconst testNullByteArgument = async (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('echo', ['a\\0b']);\n\t}, {message: /null bytes/});\n};\n\ntest('execa()\\'s second argument must not include \\\\0', testNullByteArgument, execa);\ntest('execaSync()\\'s second argument must not include \\\\0', testNullByteArgument, execaSync);\ntest('execaCommand()\\'s second argument must not include \\\\0', testNullByteArgument, execaCommand);\ntest('execaCommandSync()\\'s second argument must not include \\\\0', testNullByteArgument, execaCommandSync);\ntest('execaNode()\\'s second argument must not include \\\\0', testNullByteArgument, execaNode);\ntest('$\\'s second argument must not include \\\\0', testNullByteArgument, $);\ntest('$.sync\\'s second argument must not include \\\\0', testNullByteArgument, $.sync);\n"
  },
  {
    "path": "test/methods/parameters-command.js",
    "content": "import path from 'node:path';\nimport {fileURLToPath} from 'node:url';\nimport test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\texecaCommand,\n\texecaCommandSync,\n\texecaNode,\n\t$,\n} from '../../index.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY_URL} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testFileUrl = async (t, execaMethod) => {\n\tconst command = new URL('noop.js', FIXTURES_DIRECTORY_URL);\n\tconst {stdout} = await execaMethod(command);\n\tt.is(stdout, foobarString);\n};\n\ntest('execa()\\'s command argument can be a file URL', testFileUrl, execa);\ntest('execaSync()\\'s command argument can be a file URL', testFileUrl, execaSync);\ntest('execaCommand()\\'s command argument can be a file URL', testFileUrl, execaCommand);\ntest('execaCommandSync()\\'s command argument can be a file URL', testFileUrl, execaCommandSync);\ntest('execaNode()\\'s command argument can be a file URL', testFileUrl, execaNode);\ntest('$\\'s command argument can be a file URL', testFileUrl, $);\ntest('$.sync\\'s command argument can be a file URL', testFileUrl, $.sync);\n\nconst testInvalidFileUrl = async (t, execaMethod) => {\n\tconst invalidUrl = new URL('https://invalid.com');\n\tt.throws(() => {\n\t\texecaMethod(invalidUrl);\n\t}, {code: 'ERR_INVALID_URL_SCHEME'});\n};\n\ntest('execa()\\'s command argument cannot be a non-file URL', testInvalidFileUrl, execa);\ntest('execaSync()\\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaSync);\ntest('execaCommand()\\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommand);\ntest('execaCommandSync()\\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaCommandSync);\ntest('execaNode()\\'s command argument cannot be a non-file URL', testInvalidFileUrl, execaNode);\ntest('$\\'s command argument cannot be a non-file URL', testInvalidFileUrl, $);\ntest('$.sync\\'s command argument cannot be a non-file URL', testInvalidFileUrl, $.sync);\n\nconst testInvalidCommand = async (t, commandArgument, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod(commandArgument);\n\t}, {message: /First argument must be a string or a file URL/});\n};\n\ntest('execa()\\'s first argument must be defined', testInvalidCommand, undefined, execa);\ntest('execaSync()\\'s first argument must be defined', testInvalidCommand, undefined, execaSync);\ntest('execaCommand()\\'s first argument must be defined', testInvalidCommand, undefined, execaCommand);\ntest('execaCommandSync()\\'s first argument must be defined', testInvalidCommand, undefined, execaCommandSync);\ntest('execaNode()\\'s first argument must be defined', testInvalidCommand, undefined, execaNode);\ntest('$\\'s first argument must be defined', testInvalidCommand, undefined, $);\ntest('$.sync\\'s first argument must be defined', testInvalidCommand, undefined, $.sync);\ntest('execa()\\'s first argument must be valid', testInvalidCommand, true, execa);\ntest('execaSync()\\'s first argument must be valid', testInvalidCommand, true, execaSync);\ntest('execaCommand()\\'s first argument must be valid', testInvalidCommand, true, execaCommand);\ntest('execaCommandSync()\\'s first argument must be valid', testInvalidCommand, true, execaCommandSync);\ntest('execaNode()\\'s first argument must be valid', testInvalidCommand, true, execaNode);\ntest('$\\'s first argument must be valid', testInvalidCommand, true, $);\ntest('$.sync\\'s first argument must be valid', testInvalidCommand, true, $.sync);\ntest('execa()\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execa);\ntest('execaSync()\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaSync);\ntest('execaCommand()\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommand);\ntest('execaCommandSync()\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaCommandSync);\ntest('execaNode()\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], execaNode);\ntest('$\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $);\ntest('$.sync\\'s command argument must be a string or file URL', testInvalidCommand, ['command', 'arg'], $.sync);\n\nconst testRelativePath = async (t, execaMethod) => {\n\t// @todo: use import.meta.dirname after dropping support for Node <20.11.0\n\tconst rootDirectory = path.basename(fileURLToPath(new URL('../..', import.meta.url)));\n\tconst pathViaParentDirectory = path.join('..', rootDirectory, 'test', 'fixtures', 'noop.js');\n\tconst {stdout} = await execaMethod(pathViaParentDirectory);\n\tt.is(stdout, foobarString);\n};\n\ntest('execa() use relative path with \\'..\\' chars', testRelativePath, execa);\ntest('execaSync() use relative path with \\'..\\' chars', testRelativePath, execaSync);\ntest('execaCommand() use relative path with \\'..\\' chars', testRelativePath, execaCommand);\ntest('execaCommandSync() use relative path with \\'..\\' chars', testRelativePath, execaCommandSync);\ntest('execaNode() use relative path with \\'..\\' chars', testRelativePath, execaNode);\ntest('$ use relative path with \\'..\\' chars', testRelativePath, $);\ntest('$.sync use relative path with \\'..\\' chars', testRelativePath, $.sync);\n"
  },
  {
    "path": "test/methods/parameters-options.js",
    "content": "import path from 'node:path';\nimport test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\texecaCommand,\n\texecaCommandSync,\n\texecaNode,\n\t$,\n} from '../../index.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst NOOP_PATH = path.join(FIXTURES_DIRECTORY, 'noop.js');\n\nconst testSerializeArgument = async (t, commandArgument, execaMethod) => {\n\tconst {stdout} = await execaMethod(NOOP_PATH, [commandArgument]);\n\tt.is(stdout, String(commandArgument));\n};\n\ntest('execa()\\'s arguments can be numbers', testSerializeArgument, 1, execa);\ntest('execa()\\'s arguments can be booleans', testSerializeArgument, true, execa);\ntest('execa()\\'s arguments can be NaN', testSerializeArgument, Number.NaN, execa);\ntest('execa()\\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, execa);\ntest('execa()\\'s arguments can be null', testSerializeArgument, null, execa);\ntest('execa()\\'s arguments can be undefined', testSerializeArgument, undefined, execa);\ntest('execa()\\'s arguments can be bigints', testSerializeArgument, 1n, execa);\ntest('execa()\\'s arguments can be symbols', testSerializeArgument, Symbol('test'), execa);\ntest('execaSync()\\'s arguments can be numbers', testSerializeArgument, 1, execaSync);\ntest('execaSync()\\'s arguments can be booleans', testSerializeArgument, true, execaSync);\ntest('execaSync()\\'s arguments can be NaN', testSerializeArgument, Number.NaN, execaSync);\ntest('execaSync()\\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, execaSync);\ntest('execaSync()\\'s arguments can be null', testSerializeArgument, null, execaSync);\ntest('execaSync()\\'s arguments can be undefined', testSerializeArgument, undefined, execaSync);\ntest('execaSync()\\'s arguments can be bigints', testSerializeArgument, 1n, execaSync);\ntest('execaSync()\\'s arguments can be symbols', testSerializeArgument, Symbol('test'), execaSync);\ntest('execaNode()\\'s arguments can be numbers', testSerializeArgument, 1, execaNode);\ntest('execaNode()\\'s arguments can be booleans', testSerializeArgument, true, execaNode);\ntest('execaNode()\\'s arguments can be NaN', testSerializeArgument, Number.NaN, execaNode);\ntest('execaNode()\\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, execaNode);\ntest('execaNode()\\'s arguments can be null', testSerializeArgument, null, execaNode);\ntest('execaNode()\\'s arguments can be undefined', testSerializeArgument, undefined, execaNode);\ntest('execaNode()\\'s arguments can be bigints', testSerializeArgument, 1n, execaNode);\ntest('execaNode()\\'s arguments can be symbols', testSerializeArgument, Symbol('test'), execaNode);\ntest('$\\'s arguments can be numbers', testSerializeArgument, 1, $);\ntest('$\\'s arguments can be booleans', testSerializeArgument, true, $);\ntest('$\\'s arguments can be NaN', testSerializeArgument, Number.NaN, $);\ntest('$\\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, $);\ntest('$\\'s arguments can be null', testSerializeArgument, null, $);\ntest('$\\'s arguments can be undefined', testSerializeArgument, undefined, $);\ntest('$\\'s arguments can be bigints', testSerializeArgument, 1n, $);\ntest('$\\'s arguments can be symbols', testSerializeArgument, Symbol('test'), $);\ntest('$.sync\\'s arguments can be numbers', testSerializeArgument, 1, $.sync);\ntest('$.sync\\'s arguments can be booleans', testSerializeArgument, true, $.sync);\ntest('$.sync\\'s arguments can be NaN', testSerializeArgument, Number.NaN, $.sync);\ntest('$.sync\\'s arguments can be Infinity', testSerializeArgument, Number.POSITIVE_INFINITY, $.sync);\ntest('$.sync\\'s arguments can be null', testSerializeArgument, null, $.sync);\ntest('$.sync\\'s arguments can be undefined', testSerializeArgument, undefined, $.sync);\ntest('$.sync\\'s arguments can be bigints', testSerializeArgument, 1n, $.sync);\ntest('$.sync\\'s arguments can be symbols', testSerializeArgument, Symbol('test'), $.sync);\n\nconst testInvalidOptions = async (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('echo', [], new Map());\n\t}, {message: /Last argument must be an options object/});\n};\n\ntest('execa()\\'s third argument must be a plain object', testInvalidOptions, execa);\ntest('execaSync()\\'s third argument must be a plain object', testInvalidOptions, execaSync);\ntest('execaCommand()\\'s third argument must be a plain object', testInvalidOptions, execaCommand);\ntest('execaCommandSync()\\'s third argument must be a plain object', testInvalidOptions, execaCommandSync);\ntest('execaNode()\\'s third argument must be a plain object', testInvalidOptions, execaNode);\ntest('$\\'s third argument must be a plain object', testInvalidOptions, $);\ntest('$.sync\\'s third argument must be a plain object', testInvalidOptions, $.sync);\n"
  },
  {
    "path": "test/methods/promise.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\ntest('promise methods are not enumerable', t => {\n\tconst descriptors = Object.getOwnPropertyDescriptors(execa('noop.js'));\n\tt.false(descriptors.then.enumerable);\n\tt.false(descriptors.catch.enumerable);\n\tt.false(descriptors.finally.enumerable);\n});\n\ntest('finally function is executed on success', async t => {\n\tlet isCalled = false;\n\tconst {stdout} = await execa('noop.js', ['foo']).finally(() => {\n\t\tisCalled = true;\n\t});\n\tt.is(isCalled, true);\n\tt.is(stdout, 'foo');\n});\n\ntest('finally function is executed on failure', async t => {\n\tlet isError = false;\n\tconst {stdout, stderr} = await t.throwsAsync(execa('exit.js', ['2']).finally(() => {\n\t\tisError = true;\n\t}));\n\tt.is(isError, true);\n\tt.is(typeof stdout, 'string');\n\tt.is(typeof stderr, 'string');\n});\n\ntest('throw in finally function bubbles up on success', async t => {\n\tconst {message} = await t.throwsAsync(execa('noop.js', ['foo']).finally(() => {\n\t\tthrow new Error('called');\n\t}));\n\tt.is(message, 'called');\n});\n\ntest('throw in finally bubbles up on error', async t => {\n\tconst {message} = await t.throwsAsync(execa('exit.js', ['2']).finally(() => {\n\t\tthrow new Error('called');\n\t}));\n\tt.is(message, 'called');\n});\n\nconst testNoAwait = async (t, fixtureName, options, message) => {\n\tconst {stdout} = await execa('no-await.js', [JSON.stringify(options), fixtureName]);\n\tt.true(stdout.includes(message));\n};\n\ntest('Throws if promise is not awaited and subprocess fails', testNoAwait, 'fail.js', {}, 'exit code 2');\ntest('Throws if promise is not awaited and subprocess times out', testNoAwait, 'forever.js', {timeout: 1}, 'timed out');\n"
  },
  {
    "path": "test/methods/script.js",
    "content": "import test from 'ava';\nimport {isStream} from 'is-stream';\nimport {$} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testScriptStdoutSync = (t, getSubprocess, expectedStdout) => {\n\tconst {stdout} = getSubprocess();\n\tt.is(stdout, expectedStdout);\n};\n\ntest('$.sync`...`', testScriptStdoutSync, () => $.sync`echo.js foo bar`, 'foo\\nbar');\ntest('$.s`...`', testScriptStdoutSync, () => $.s`echo.js foo bar`, 'foo\\nbar');\ntest('$(options).sync`...`', testScriptStdoutSync, () => $({stripFinalNewline: false}).sync`echo.js ${foobarString}`, `${foobarString}\\n`);\ntest('$.sync(options)`...`', testScriptStdoutSync, () => $.sync({stripFinalNewline: false})`echo.js ${foobarString}`, `${foobarString}\\n`);\n\ntest('Cannot call $.sync.sync', t => {\n\tt.false('sync' in $.sync);\n});\n\ntest('Cannot call $.sync(options).sync', t => {\n\tt.false('sync' in $.sync({}));\n});\n\ntest('$(options)() stdin defaults to \"inherit\"', async t => {\n\tconst {stdout} = await $({input: foobarString})('stdin-script.js');\n\tt.is(stdout, foobarString);\n});\n\ntest('$.sync(options)() stdin defaults to \"inherit\"', t => {\n\tconst {stdout} = $.sync({input: foobarString})('stdin-script.js');\n\tt.is(stdout, foobarString);\n});\n\ntest('$(options).sync() stdin defaults to \"inherit\"', t => {\n\tconst {stdout} = $({input: foobarString}).sync('stdin-script.js');\n\tt.is(stdout, foobarString);\n});\n\ntest('$(options)`...` stdin defaults to \"inherit\"', async t => {\n\tconst {stdout} = await $({input: foobarString})`stdin-script.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.sync(options)`...` stdin defaults to \"inherit\"', t => {\n\tconst {stdout} = $.sync({input: foobarString})`stdin-script.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$(options).sync`...` stdin defaults to \"inherit\"', t => {\n\tconst {stdout} = $({input: foobarString}).sync`stdin-script.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$ stdin has no default value when stdio is set', t => {\n\tt.true(isStream($({stdio: 'pipe'})`noop.js`.stdin));\n});\n"
  },
  {
    "path": "test/methods/template.js",
    "content": "import test from 'ava';\nimport {$} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\n// Workaround since some text editors or IDEs do not allow inputting \\r directly\nconst escapedCall = string => {\n\tconst templates = [string];\n\ttemplates.raw = [string];\n\treturn $(templates);\n};\n\nconst testScriptStdout = async (t, getSubprocess, expectedStdout) => {\n\tconst {stdout} = await getSubprocess();\n\tt.is(stdout, expectedStdout);\n};\n\ntest('$ allows number interpolation', testScriptStdout, () => $`echo.js 1 ${2}`, '1\\n2');\ntest('$ can concatenate multiple tokens', testScriptStdout, () => $`echo.js ${'foo'}bar${'foo'}`, 'foobarfoo');\ntest('$ can use newlines and tab indentations', testScriptStdout, () => $`echo.js foo\n\tbar`, 'foo\\nbar');\ntest('$ can use newlines and space indentations', testScriptStdout, () => $`echo.js foo\n  bar`, 'foo\\nbar');\ntest('$ can use escaped newlines and space indentations', testScriptStdout, () => $`echo.js foo\\\n  bar`, 'foo\\nbar');\ntest('$ can use escaped newlines and inline tab indentations', testScriptStdout, () => $`echo.js foo\\\n\tbar`, 'foo\\nbar');\ntest('$ can use escaped newlines and character escaped tab indentations', testScriptStdout, () => $`echo.js foo\\\n\\tbar`, 'foo\\tbar');\ntest('$ can use escaped newlines and character escaped newlines', testScriptStdout, () => $`echo.js foo\\\n\\n\\nbar`, 'foo\\n\\nbar');\ntest('$ can use Windows newlines and tab indentations', testScriptStdout, () => escapedCall('echo.js foo\\r\\n\\tbar'), 'foo\\nbar');\ntest('$ can use Windows newlines and space indentations', testScriptStdout, () => escapedCall('echo.js foo\\r\\n  bar'), 'foo\\nbar');\ntest('$ does not ignore comments in expressions', testScriptStdout, () => $`echo.js foo\n\t${/* This is a comment */''}\n\tbar\n\t${/* This is another comment */''}\n\tbaz\n`, 'foo\\n\\nbar\\n\\nbaz');\ntest('$ allows escaping spaces with interpolation', testScriptStdout, () => $`echo.js ${'foo bar'}`, 'foo bar');\ntest('$ allows escaping spaces in commands with interpolation', testScriptStdout, () => $`${'command with space.js'} foo bar`, 'foo\\nbar');\ntest('$ trims', testScriptStdout, () => $`  echo.js foo bar  `, 'foo\\nbar');\ntest('$ allows array interpolation', testScriptStdout, () => $`echo.js ${['foo', 'bar']}`, 'foo\\nbar');\ntest('$ allows empty array interpolation', testScriptStdout, () => $`echo.js foo ${[]} bar`, 'foo\\nbar');\ntest('$ allows space escaped values in array interpolation', testScriptStdout, () => $`echo.js ${['foo', 'bar baz']}`, 'foo\\nbar baz');\ntest('$ can concatenate at the end of tokens followed by an array', testScriptStdout, () => $`echo.js foo${['bar', 'foo']}`, 'foobar\\nfoo');\ntest('$ can concatenate at the start of tokens followed by an array', testScriptStdout, () => $`echo.js ${['foo', 'bar']}foo`, 'foo\\nbarfoo');\ntest('$ can concatenate at the start and end of tokens followed by an array', testScriptStdout, () => $`echo.js foo${['bar', 'foo']}bar`, 'foobar\\nfoobar');\ntest('$ handles escaped newlines', testScriptStdout, () => $`echo.js a\\\nb`, 'ab');\ntest('$ handles backslashes at end of lines', testScriptStdout, () => $`echo.js a\\\\\n b`, 'a\\\\\\nb');\ntest('$ handles double backslashes at end of lines', testScriptStdout, () => $`echo.js a\\\\\\\\\n b`, 'a\\\\\\\\\\nb');\ntest('$ handles tokens - a', testScriptStdout, () => $`echo.js a`, 'a');\ntest('$ handles expressions - a', testScriptStdout, () => $`echo.js ${'a'}`, 'a');\ntest('$ handles tokens - abc', testScriptStdout, () => $`echo.js abc`, 'abc');\ntest('$ handles expressions - abc', testScriptStdout, () => $`echo.js ${'abc'}`, 'abc');\ntest('$ handles tokens - \"\"', testScriptStdout, () => $`echo.js`, '');\ntest('$ handles expressions - \"\"', testScriptStdout, () => $`echo.js a ${''} b`, 'a\\n\\nb');\ntest('$ splits tokens - \"\"', testScriptStdout, () => $`echo.js ab`, 'ab');\ntest('$ splits expressions - \"\"', testScriptStdout, () => $`echo.js ${'a'}${'b'}`, 'ab');\ntest('$ concatenates expressions - \"\"', testScriptStdout, () => $`echo.js a${'b'}c`, 'abc');\ntest('$ handles tokens - \" \"', testScriptStdout, () => $`echo.js `, '');\ntest('$ handles expressions - \" \"', testScriptStdout, () => $`echo.js ${' '}`, ' ');\ntest('$ splits tokens - \" \"', testScriptStdout, () => $`echo.js a b`, 'a\\nb');\ntest('$ splits expressions - \" \"', testScriptStdout, () => $`echo.js ${'a'} ${'b'}`, 'a\\nb');\ntest('$ concatenates tokens - \" \"', testScriptStdout, () => $`echo.js  a `, 'a');\ntest('$ concatenates expressions - \" \"', testScriptStdout, () => $`echo.js  ${'a'} `, 'a');\ntest('$ handles tokens - \"  \" (2 spaces)', testScriptStdout, () => $`echo.js  `, '');\ntest('$ handles expressions - \"  \" (2 spaces)', testScriptStdout, () => $`echo.js ${'  '}`, '  ');\ntest('$ splits tokens - \"  \" (2 spaces)', testScriptStdout, () => $`echo.js a  b`, 'a\\nb');\ntest('$ splits expressions - \"  \" (2 spaces)', testScriptStdout, () => $`echo.js ${'a'}  ${'b'}`, 'a\\nb');\ntest('$ concatenates tokens - \"  \" (2 spaces)', testScriptStdout, () => $`echo.js   a  `, 'a');\ntest('$ concatenates expressions - \"  \" (2 spaces)', testScriptStdout, () => $`echo.js   ${'a'}  `, 'a');\ntest('$ handles tokens - \"   \" (3 spaces)', testScriptStdout, () => $`echo.js   `, '');\ntest('$ handles expressions - \"   \" (3 spaces)', testScriptStdout, () => $`echo.js ${'   '}`, '   ');\ntest('$ splits tokens - \"  \" (3 spaces)', testScriptStdout, () => $`echo.js a   b`, 'a\\nb');\ntest('$ splits expressions - \"   \" (3 spaces)', testScriptStdout, () => $`echo.js ${'a'}   ${'b'}`, 'a\\nb');\ntest('$ concatenates tokens - \"   \" (3 spaces)', testScriptStdout, () => $`echo.js    a   `, 'a');\ntest('$ concatenates expressions - \"   \" (3 spaces)', testScriptStdout, () => $`echo.js    ${'a'}   `, 'a');\ntest('$ handles tokens - \\\\t (no escape)', testScriptStdout, () => $`echo.js \t`, '');\ntest('$ handles expressions - \\\\t (no escape)', testScriptStdout, () => $`echo.js ${'\t'}`, '\\t');\ntest('$ splits tokens - \\\\t (no escape)', testScriptStdout, () => $`echo.js a\tb`, 'a\\nb');\ntest('$ splits expressions - \\\\t (no escape)', testScriptStdout, () => $`echo.js ${'a'}\t${'b'}`, 'a\\nb');\ntest('$ concatenates tokens - \\\\t (no escape)', testScriptStdout, () => $`echo.js \ta\t b`, 'a\\nb');\ntest('$ concatenates expressions - \\\\t (no escape)', testScriptStdout, () => $`echo.js \t${'a'}\t b`, 'a\\nb');\ntest('$ handles tokens - \\\\t (escape)', testScriptStdout, () => $`echo.js \\t`, '\\t');\ntest('$ handles expressions - \\\\t (escape)', testScriptStdout, () => $`echo.js ${'\\t'}`, '\\t');\ntest('$ splits tokens - \\\\t (escape)', testScriptStdout, () => $`echo.js a\\tb`, 'a\\tb');\ntest('$ splits expressions - \\\\t (escape)', testScriptStdout, () => $`echo.js ${'a'}\\t${'b'}`, 'a\\tb');\ntest('$ concatenates tokens - \\\\t (escape)', testScriptStdout, () => $`echo.js \\ta\\t b`, '\\ta\\t\\nb');\ntest('$ concatenates expressions - \\\\t (escape)', testScriptStdout, () => $`echo.js \\t${'a'}\\t b`, '\\ta\\t\\nb');\ntest('$ handles tokens - \\\\n (no escape)', testScriptStdout, () => $`echo.js\n `, '');\ntest('$ handles expressions - \\\\n (no escape)', testScriptStdout, () => $`echo.js ${`\n`} `, '\\n');\ntest('$ splits tokens - \\\\n (no escape)', testScriptStdout, () => $`echo.js a\n b`, 'a\\nb');\ntest('$ splits expressions - \\\\n (no escape)', testScriptStdout, () => $`echo.js ${'a'}\n ${'b'}`, 'a\\nb');\ntest('$ concatenates tokens - \\\\n (no escape)', testScriptStdout, () => $`echo.js\na\n b`, 'a\\nb');\ntest('$ concatenates expressions - \\\\n (no escape)', testScriptStdout, () => $`echo.js\n${'a'}\n b`, 'a\\nb');\ntest('$ handles tokens - \\\\n (escape)', testScriptStdout, () => $`echo.js \\n `, '\\n');\ntest('$ handles expressions - \\\\n (escape)', testScriptStdout, () => $`echo.js ${'\\n'} `, '\\n');\ntest('$ splits tokens - \\\\n (escape)', testScriptStdout, () => $`echo.js a\\n b`, 'a\\n\\nb');\ntest('$ splits expressions - \\\\n (escape)', testScriptStdout, () => $`echo.js ${'a'}\\n ${'b'}`, 'a\\n\\nb');\ntest('$ concatenates tokens - \\\\n (escape)', testScriptStdout, () => $`echo.js \\na\\n b`, '\\na\\n\\nb');\ntest('$ concatenates expressions - \\\\n (escape)', testScriptStdout, () => $`echo.js \\n${'a'}\\n b`, '\\na\\n\\nb');\ntest('$ handles tokens - \\\\r (no escape)', testScriptStdout, () => escapedCall('echo.js \\r '), '');\ntest('$ splits tokens - \\\\r (no escape)', testScriptStdout, () => escapedCall('echo.js a\\rb'), 'a\\nb');\ntest('$ splits expressions - \\\\r (no escape)', testScriptStdout, () => escapedCall(`echo.js ${'a'}\\r${'b'}`), 'a\\nb');\ntest('$ concatenates tokens - \\\\r (no escape)', testScriptStdout, () => escapedCall('echo.js \\ra\\r b'), 'a\\nb');\ntest('$ concatenates expressions - \\\\r (no escape)', testScriptStdout, () => escapedCall(`echo.js \\r${'a'}\\r b`), 'a\\nb');\ntest('$ splits tokens - \\\\r (escape)', testScriptStdout, () => $`echo.js a\\r b`, 'a\\r\\nb');\ntest('$ splits expressions - \\\\r (escape)', testScriptStdout, () => $`echo.js ${'a'}\\r ${'b'}`, 'a\\r\\nb');\ntest('$ concatenates tokens - \\\\r (escape)', testScriptStdout, () => $`echo.js \\ra\\r b`, '\\ra\\r\\nb');\ntest('$ concatenates expressions - \\\\r (escape)', testScriptStdout, () => $`echo.js \\r${'a'}\\r b`, '\\ra\\r\\nb');\ntest('$ handles tokens - \\\\r\\\\n (no escape)', testScriptStdout, () => escapedCall('echo.js \\r\\n '), '');\ntest('$ splits tokens - \\\\r\\\\n (no escape)', testScriptStdout, () => escapedCall('echo.js a\\r\\nb'), 'a\\nb');\ntest('$ splits expressions - \\\\r\\\\n (no escape)', testScriptStdout, () => escapedCall(`echo.js ${'a'}\\r\\n${'b'}`), 'a\\nb');\ntest('$ concatenates tokens - \\\\r\\\\n (no escape)', testScriptStdout, () => escapedCall('echo.js \\r\\na\\r\\n b'), 'a\\nb');\ntest('$ concatenates expressions - \\\\r\\\\n (no escape)', testScriptStdout, () => escapedCall(`echo.js \\r\\n${'a'}\\r\\n b`), 'a\\nb');\ntest('$ handles tokens - \\\\r\\\\n (escape)', testScriptStdout, () => $`echo.js \\r\\n `, '\\r\\n');\ntest('$ handles expressions - \\\\r\\\\n (escape)', testScriptStdout, () => $`echo.js ${'\\r\\n'} `, '\\r\\n');\ntest('$ splits tokens - \\\\r\\\\n (escape)', testScriptStdout, () => $`echo.js a\\r\\n b`, 'a\\r\\n\\nb');\ntest('$ splits expressions - \\\\r\\\\n (escape)', testScriptStdout, () => $`echo.js ${'a'}\\r\\n ${'b'}`, 'a\\r\\n\\nb');\ntest('$ concatenates tokens - \\\\r\\\\n (escape)', testScriptStdout, () => $`echo.js \\r\\na\\r\\n b`, '\\r\\na\\r\\n\\nb');\ntest('$ concatenates expressions - \\\\r\\\\n (escape)', testScriptStdout, () => $`echo.js \\r\\n${'a'}\\r\\n b`, '\\r\\na\\r\\n\\nb');\n/* eslint-disable no-irregular-whitespace */\ntest('$ handles expressions - \\\\f (no escape)', testScriptStdout, () => $`echo.js ${'\f'}`, '\\f');\ntest('$ splits tokens - \\\\f (no escape)', testScriptStdout, () => $`echo.js a\fb`, 'a\\fb');\ntest('$ splits expressions - \\\\f (no escape)', testScriptStdout, () => $`echo.js ${'a'}\f${'b'}`, 'a\\fb');\ntest('$ concatenates tokens - \\\\f (no escape)', testScriptStdout, () => $`echo.js \fa\f b`, '\\fa\\f\\nb');\ntest('$ concatenates expressions - \\\\f (no escape)', testScriptStdout, () => $`echo.js \f${'a'}\f b`, '\\fa\\f\\nb');\n/* eslint-enable no-irregular-whitespace */\ntest('$ handles tokens - \\\\f (escape)', testScriptStdout, () => $`echo.js \\f`, '\\f');\ntest('$ handles expressions - \\\\f (escape)', testScriptStdout, () => $`echo.js ${'\\f'}`, '\\f');\ntest('$ splits tokens - \\\\f (escape)', testScriptStdout, () => $`echo.js a\\fb`, 'a\\fb');\ntest('$ splits expressions - \\\\f (escape)', testScriptStdout, () => $`echo.js ${'a'}\\f${'b'}`, 'a\\fb');\ntest('$ concatenates tokens - \\\\f (escape)', testScriptStdout, () => $`echo.js \\fa\\f b`, '\\fa\\f\\nb');\ntest('$ concatenates expressions - \\\\f (escape)', testScriptStdout, () => $`echo.js \\f${'a'}\\f b`, '\\fa\\f\\nb');\ntest('$ handles tokens - \\\\', testScriptStdout, () => $`echo.js \\\\`, '\\\\');\ntest('$ handles expressions - \\\\', testScriptStdout, () => $`echo.js ${'\\\\'}`, '\\\\');\ntest('$ splits tokens - \\\\', testScriptStdout, () => $`echo.js a\\\\b`, 'a\\\\b');\ntest('$ splits expressions - \\\\', testScriptStdout, () => $`echo.js ${'a'}\\\\${'b'}`, 'a\\\\b');\ntest('$ concatenates tokens - \\\\', testScriptStdout, () => $`echo.js \\\\a\\\\ b`, '\\\\a\\\\\\nb');\ntest('$ concatenates expressions - \\\\', testScriptStdout, () => $`echo.js \\\\${'a'}\\\\ b`, '\\\\a\\\\\\nb');\ntest('$ handles tokens - \\\\\\\\', testScriptStdout, () => $`echo.js \\\\\\\\`, '\\\\\\\\');\ntest('$ handles expressions - \\\\\\\\', testScriptStdout, () => $`echo.js ${'\\\\\\\\'}`, '\\\\\\\\');\ntest('$ splits tokens - \\\\\\\\', testScriptStdout, () => $`echo.js a\\\\\\\\b`, 'a\\\\\\\\b');\ntest('$ splits expressions - \\\\\\\\', testScriptStdout, () => $`echo.js ${'a'}\\\\\\\\${'b'}`, 'a\\\\\\\\b');\ntest('$ concatenates tokens - \\\\\\\\', testScriptStdout, () => $`echo.js \\\\\\\\a\\\\\\\\ b`, '\\\\\\\\a\\\\\\\\\\nb');\ntest('$ concatenates expressions - \\\\\\\\', testScriptStdout, () => $`echo.js \\\\\\\\${'a'}\\\\\\\\ b`, '\\\\\\\\a\\\\\\\\\\nb');\ntest('$ handles tokens - `', testScriptStdout, () => $`echo.js \\``, '`');\ntest('$ handles expressions - `', testScriptStdout, () => $`echo.js ${'`'}`, '`');\ntest('$ splits tokens - `', testScriptStdout, () => $`echo.js a\\`b`, 'a`b');\ntest('$ splits expressions - `', testScriptStdout, () => $`echo.js ${'a'}\\`${'b'}`, 'a`b');\ntest('$ concatenates tokens - `', testScriptStdout, () => $`echo.js \\`a\\` b`, '`a`\\nb');\ntest('$ concatenates expressions - `', testScriptStdout, () => $`echo.js \\`${'a'}\\` b`, '`a`\\nb');\ntest('$ handles tokens - \\\\v', testScriptStdout, () => $`echo.js \\v`, '\\v');\ntest('$ handles expressions - \\\\v', testScriptStdout, () => $`echo.js ${'\\v'}`, '\\v');\ntest('$ splits tokens - \\\\v', testScriptStdout, () => $`echo.js a\\vb`, 'a\\vb');\ntest('$ splits expressions - \\\\v', testScriptStdout, () => $`echo.js ${'a'}\\v${'b'}`, 'a\\vb');\ntest('$ concatenates tokens - \\\\v', testScriptStdout, () => $`echo.js \\va\\v b`, '\\va\\v\\nb');\ntest('$ concatenates expressions - \\\\v', testScriptStdout, () => $`echo.js \\v${'a'}\\v b`, '\\va\\v\\nb');\ntest('$ handles tokens - \\\\u2028', testScriptStdout, () => $`echo.js \\u2028`, '\\u2028');\ntest('$ handles expressions - \\\\u2028', testScriptStdout, () => $`echo.js ${'\\u2028'}`, '\\u2028');\ntest('$ splits tokens - \\\\u2028', testScriptStdout, () => $`echo.js a\\u2028b`, 'a\\u2028b');\ntest('$ splits expressions - \\\\u2028', testScriptStdout, () => $`echo.js ${'a'}\\u2028${'b'}`, 'a\\u2028b');\ntest('$ concatenates tokens - \\\\u2028', testScriptStdout, () => $`echo.js \\u2028a\\u2028 b`, '\\u2028a\\u2028\\nb');\ntest('$ concatenates expressions - \\\\u2028', testScriptStdout, () => $`echo.js \\u2028${'a'}\\u2028 b`, '\\u2028a\\u2028\\nb');\ntest('$ handles tokens - \\\\a', testScriptStdout, () => $`echo.js \\a`, 'a');\ntest('$ splits tokens - \\\\a', testScriptStdout, () => $`echo.js a\\ab`, 'aab');\ntest('$ splits expressions - \\\\a', testScriptStdout, () => $`echo.js ${'a'}\\a${'b'}`, 'aab');\ntest('$ concatenates tokens - \\\\a', testScriptStdout, () => $`echo.js \\aa\\a b`, 'aaa\\nb');\ntest('$ concatenates expressions - \\\\a', testScriptStdout, () => $`echo.js \\a${'a'}\\a b`, 'aaa\\nb');\ntest('$ handles tokens - \\\\cJ', testScriptStdout, () => $`echo.js \\cJ`, 'cJ');\ntest('$ splits tokens - \\\\cJ', testScriptStdout, () => $`echo.js a\\cJb`, 'acJb');\ntest('$ splits expressions - \\\\cJ', testScriptStdout, () => $`echo.js ${'a'}\\cJ${'b'}`, 'acJb');\ntest('$ concatenates tokens - \\\\cJ', testScriptStdout, () => $`echo.js \\cJa\\cJ b`, 'cJacJ\\nb');\ntest('$ concatenates expressions - \\\\cJ', testScriptStdout, () => $`echo.js \\cJ${'a'}\\cJ b`, 'cJacJ\\nb');\ntest('$ handles tokens - \\\\.', testScriptStdout, () => $`echo.js \\.`, '.');\ntest('$ splits tokens - \\\\.', testScriptStdout, () => $`echo.js a\\.b`, 'a.b');\ntest('$ splits expressions - \\\\.', testScriptStdout, () => $`echo.js ${'a'}\\.${'b'}`, 'a.b');\ntest('$ concatenates tokens - \\\\.', testScriptStdout, () => $`echo.js \\.a\\. b`, '.a.\\nb');\ntest('$ concatenates expressions - \\\\.', testScriptStdout, () => $`echo.js \\.${'a'}\\. b`, '.a.\\nb');\n/* eslint-disable unicorn/no-hex-escape */\ntest('$ handles tokens - \\\\x63', testScriptStdout, () => $`echo.js \\x63`, 'c');\ntest('$ splits tokens - \\\\x63', testScriptStdout, () => $`echo.js a\\x63b`, 'acb');\ntest('$ splits expressions - \\\\x63', testScriptStdout, () => $`echo.js ${'a'}\\x63${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\x63', testScriptStdout, () => $`echo.js \\x63a\\x63 b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\x63', testScriptStdout, () => $`echo.js \\x63${'a'}\\x63 b`, 'cac\\nb');\n/* eslint-enable unicorn/no-hex-escape */\ntest('$ handles tokens - \\\\u0063', testScriptStdout, () => $`echo.js \\u0063`, 'c');\ntest('$ splits tokens - \\\\u0063', testScriptStdout, () => $`echo.js a\\u0063b`, 'acb');\ntest('$ splits expressions - \\\\u0063', testScriptStdout, () => $`echo.js ${'a'}\\u0063${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u0063', testScriptStdout, () => $`echo.js \\u0063a\\u0063 b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u0063', testScriptStdout, () => $`echo.js \\u0063${'a'}\\u0063 b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{1}', testScriptStdout, () => $`echo.js \\u{1}`, '\\u0001');\ntest('$ splits tokens - \\\\u{1}', testScriptStdout, () => $`echo.js a\\u{1}b`, 'a\\u0001b');\ntest('$ splits expressions - \\\\u{1}', testScriptStdout, () => $`echo.js ${'a'}\\u{1}${'b'}`, 'a\\u0001b');\ntest('$ concatenates tokens - \\\\u{1}', testScriptStdout, () => $`echo.js \\u{1}a\\u{1} b`, '\\u0001a\\u0001\\nb');\ntest('$ concatenates expressions - \\\\u{1}', testScriptStdout, () => $`echo.js \\u{1}${'a'}\\u{1} b`, '\\u0001a\\u0001\\nb');\ntest('$ handles tokens - \\\\u{63}', testScriptStdout, () => $`echo.js \\u{63}`, 'c');\ntest('$ splits tokens - \\\\u{63}', testScriptStdout, () => $`echo.js a\\u{63}b`, 'acb');\ntest('$ splits expressions - \\\\u{63}', testScriptStdout, () => $`echo.js ${'a'}\\u{63}${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u{63}', testScriptStdout, () => $`echo.js \\u{63}a\\u{63} b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u{63}', testScriptStdout, () => $`echo.js \\u{63}${'a'}\\u{63} b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{063}', testScriptStdout, () => $`echo.js \\u{063}`, 'c');\ntest('$ splits tokens - \\\\u{063}', testScriptStdout, () => $`echo.js a\\u{063}b`, 'acb');\ntest('$ splits expressions - \\\\u{063}', testScriptStdout, () => $`echo.js ${'a'}\\u{063}${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u{063}', testScriptStdout, () => $`echo.js \\u{063}a\\u{063} b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u{063}', testScriptStdout, () => $`echo.js \\u{063}${'a'}\\u{063} b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{0063}', testScriptStdout, () => $`echo.js \\u{0063}`, 'c');\ntest('$ splits tokens - \\\\u{0063}', testScriptStdout, () => $`echo.js a\\u{0063}b`, 'acb');\ntest('$ splits expressions - \\\\u{0063}', testScriptStdout, () => $`echo.js ${'a'}\\u{0063}${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u{0063}', testScriptStdout, () => $`echo.js \\u{0063}a\\u{0063} b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u{0063}', testScriptStdout, () => $`echo.js \\u{0063}${'a'}\\u{0063} b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{00063}', testScriptStdout, () => $`echo.js \\u{00063}`, 'c');\ntest('$ splits tokens - \\\\u{00063}', testScriptStdout, () => $`echo.js a\\u{00063}b`, 'acb');\ntest('$ splits expressions - \\\\u{00063}', testScriptStdout, () => $`echo.js ${'a'}\\u{00063}${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u{00063}', testScriptStdout, () => $`echo.js \\u{00063}a\\u{00063} b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u{00063}', testScriptStdout, () => $`echo.js \\u{00063}${'a'}\\u{00063} b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{000063}', testScriptStdout, () => $`echo.js \\u{000063}`, 'c');\ntest('$ splits tokens - \\\\u{000063}', testScriptStdout, () => $`echo.js a\\u{000063}b`, 'acb');\ntest('$ splits expressions - \\\\u{000063}', testScriptStdout, () => $`echo.js ${'a'}\\u{000063}${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u{000063}', testScriptStdout, () => $`echo.js \\u{000063}a\\u{000063} b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u{000063}', testScriptStdout, () => $`echo.js \\u{000063}${'a'}\\u{000063} b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{0000063}', testScriptStdout, () => $`echo.js \\u{0000063}`, 'c');\ntest('$ splits tokens - \\\\u{0000063}', testScriptStdout, () => $`echo.js a\\u{0000063}b`, 'acb');\ntest('$ splits expressions - \\\\u{0000063}', testScriptStdout, () => $`echo.js ${'a'}\\u{0000063}${'b'}`, 'acb');\ntest('$ concatenates tokens - \\\\u{0000063}', testScriptStdout, () => $`echo.js \\u{0000063}a\\u{0000063} b`, 'cac\\nb');\ntest('$ concatenates expressions - \\\\u{0000063}', testScriptStdout, () => $`echo.js \\u{0000063}${'a'}\\u{0000063} b`, 'cac\\nb');\ntest('$ handles tokens - \\\\u{0063}}', testScriptStdout, () => $`echo.js \\u{0063}}`, 'c}');\ntest('$ splits tokens - \\\\u{0063}}', testScriptStdout, () => $`echo.js a\\u{0063}}b`, 'ac}b');\ntest('$ splits expressions - \\\\u{0063}}', testScriptStdout, () => $`echo.js ${'a'}\\u{0063}}${'b'}`, 'ac}b');\ntest('$ concatenates tokens - \\\\u{0063}}', testScriptStdout, () => $`echo.js \\u{0063}}a\\u{0063}} b`, 'c}ac}\\nb');\ntest('$ concatenates expressions - \\\\u{0063}}', testScriptStdout, () => $`echo.js \\u{0063}}${'a'}\\u{0063}} b`, 'c}ac}\\nb');\n\nconst testScriptErrorStdout = async (t, getSubprocess) => {\n\tt.throws(getSubprocess, {message: /null bytes/});\n};\n\ntest('$ handles tokens - \\\\0', testScriptErrorStdout, () => $`echo.js \\0`);\ntest('$ splits tokens - \\\\0', testScriptErrorStdout, () => $`echo.js a\\0b`);\ntest('$ splits expressions - \\\\0', testScriptErrorStdout, () => $`echo.js ${'a'}\\0${'b'}`);\ntest('$ concatenates tokens - \\\\0', testScriptErrorStdout, () => $`echo.js \\0a\\0 b`);\ntest('$ concatenates expressions - \\\\0', testScriptErrorStdout, () => $`echo.js \\0${'a'}\\0 b`);\n\nconst testReturnInterpolate = async (t, getSubprocess, expectedStdout, options = {}) => {\n\tconst foo = await $(options)`echo.js foo`;\n\tconst {stdout} = await getSubprocess(foo);\n\tt.is(stdout, expectedStdout);\n};\n\ntest('$ allows execa return value interpolation', testReturnInterpolate, foo => $`echo.js ${foo} bar`, 'foo\\nbar');\ntest('$ allows execa return value buffer interpolation', testReturnInterpolate, foo => $`echo.js ${foo} bar`, 'foo\\nbar', {encoding: 'buffer'});\ntest('$ allows execa return value array interpolation', testReturnInterpolate, foo => $`echo.js ${[foo, 'bar']}`, 'foo\\nbar');\ntest('$ allows execa return value buffer array interpolation', testReturnInterpolate, foo => $`echo.js ${[foo, 'bar']}`, 'foo\\nbar', {encoding: 'buffer'});\n\nconst testReturnInterpolateSync = (t, getSubprocess, expectedStdout, options = {}) => {\n\tconst foo = $(options).sync`echo.js foo`;\n\tconst {stdout} = getSubprocess(foo);\n\tt.is(stdout, expectedStdout);\n};\n\ntest('$.sync allows execa return value interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${foo} bar`, 'foo\\nbar');\ntest('$.sync allows execa return value buffer interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${foo} bar`, 'foo\\nbar', {encoding: 'buffer'});\ntest('$.sync allows execa return value array interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${[foo, 'bar']}`, 'foo\\nbar');\ntest('$.sync allows execa return value buffer array interpolation', testReturnInterpolateSync, foo => $.sync`echo.js ${[foo, 'bar']}`, 'foo\\nbar', {encoding: 'buffer'});\n\nconst testInvalidSequence = (t, getSubprocess) => {\n\tt.throws(getSubprocess, {message: /Invalid backslash sequence/});\n};\n\ntest('$ handles invalid escape sequence - \\\\1', testInvalidSequence, () => $`echo.js \\1`);\ntest('$ handles invalid escape sequence - \\\\u', testInvalidSequence, () => $`echo.js \\u`);\ntest('$ handles invalid escape sequence - \\\\u0', testInvalidSequence, () => $`echo.js \\u0`);\ntest('$ handles invalid escape sequence - \\\\u00', testInvalidSequence, () => $`echo.js \\u00`);\ntest('$ handles invalid escape sequence - \\\\u000', testInvalidSequence, () => $`echo.js \\u000`);\ntest('$ handles invalid escape sequence - \\\\ug', testInvalidSequence, () => $`echo.js \\ug`);\ntest('$ handles invalid escape sequence - \\\\u{', testInvalidSequence, () => $`echo.js \\u{`);\ntest('$ handles invalid escape sequence - \\\\u{0000', testInvalidSequence, () => $`echo.js \\u{0000`);\ntest('$ handles invalid escape sequence - \\\\u{g}', testInvalidSequence, () => $`echo.js \\u{g}`);\n/* eslint-disable unicorn/no-hex-escape */\ntest('$ handles invalid escape sequence - \\\\x', testInvalidSequence, () => $`echo.js \\x`);\ntest('$ handles invalid escape sequence - \\\\x0', testInvalidSequence, () => $`echo.js \\x0`);\ntest('$ handles invalid escape sequence - \\\\xgg', testInvalidSequence, () => $`echo.js \\xgg`);\n/* eslint-enable unicorn/no-hex-escape */\n\nconst testEmptyScript = (t, getSubprocess) => {\n\tt.throws(getSubprocess, {message: /Template script must not be empty/});\n};\n\ntest('$``', testEmptyScript, () => $``);\ntest('$` `', testEmptyScript, () => $` `);\ntest('$`  ` (2 spaces)', testEmptyScript, () => $`  `);\ntest('$`\\\\t`', testEmptyScript, () => $`\t`);\ntest('$`\\\\n`', testEmptyScript, () => $`\n`);\n\nconst testInvalidExpression = (t, invalidExpression) => {\n\tt.throws(\n\t\t() => $`echo.js ${invalidExpression}`,\n\t\t{message: /in template expression/},\n\t);\n};\n\ntest('$ throws on invalid expression - undefined', testInvalidExpression, undefined);\ntest('$ throws on invalid expression - null', testInvalidExpression, null);\ntest('$ throws on invalid expression - true', testInvalidExpression, true);\ntest('$ throws on invalid expression - {}', testInvalidExpression, {});\ntest('$ throws on invalid expression - {foo: \"bar\"}', testInvalidExpression, {foo: 'bar'});\ntest('$ throws on invalid expression - {stdout: 1}', testInvalidExpression, {stdout: 1});\ntest('$ throws on invalid expression - [undefined]', testInvalidExpression, [undefined]);\ntest('$ throws on invalid expression - [null]', testInvalidExpression, [null]);\ntest('$ throws on invalid expression - [true]', testInvalidExpression, [true]);\ntest('$ throws on invalid expression - [{}]', testInvalidExpression, [{}]);\ntest('$ throws on invalid expression - [{foo: \"bar\"}]', testInvalidExpression, [{foo: 'bar'}]);\ntest('$ throws on invalid expression - [{stdout: 1}]', testInvalidExpression, [{stdout: 1}]);\n\nconst testMissingOutput = (t, invalidExpression) => {\n\tt.throws(\n\t\t() => $`echo.js ${invalidExpression()}`,\n\t\t{message: /Missing result.stdout/},\n\t);\n};\n\ntest('$ throws on invalid expression - {stdout: undefined}', testMissingOutput, () => ({stdout: undefined}));\ntest('$ throws on invalid expression - [{stdout: undefined}]', testMissingOutput, () => [{stdout: undefined}]);\ntest('$ throws on invalid expression - $(options).sync', testMissingOutput, () => $({stdio: 'ignore'}).sync`noop.js`);\ntest('$ throws on invalid expression - [$(options).sync]', testMissingOutput, () => [$({stdio: 'ignore'}).sync`noop.js`]);\n\nconst testInvalidPromise = (t, invalidExpression) => {\n\tt.throws(\n\t\t() => $`echo.js ${invalidExpression()}`,\n\t\t{message: /Please use \\${await subprocess}/},\n\t);\n};\n\ntest('$ throws on invalid expression - Promise.resolve()', testInvalidPromise, async () => ({}));\ntest('$ throws on invalid expression - Promise.resolve({stdout: \"foo\"})', testInvalidPromise, async () => ({foo: 'bar'}));\ntest('$ throws on invalid expression - [Promise.resolve()]', testInvalidPromise, () => [Promise.resolve()]);\ntest('$ throws on invalid expression - [Promise.resolve({stdout: \"foo\"})]', testInvalidPromise, () => [Promise.resolve({stdout: 'foo'})]);\ntest('$ throws on invalid expression - $', testInvalidPromise, () => $`noop.js`);\ntest('$ throws on invalid expression - [$]', testInvalidPromise, () => [$`noop.js`]);\n"
  },
  {
    "path": "test/pipe/abort.js",
    "content": "import {once} from 'node:events';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst assertUnPipeError = async (t, pipePromise) => {\n\tconst error = await t.throwsAsync(pipePromise);\n\n\tt.is(error.command, 'source.pipe(destination)');\n\tt.is(error.escapedCommand, error.command);\n\n\tt.is(typeof error.cwd, 'string');\n\tt.true(error.failed);\n\tt.false(error.timedOut);\n\tt.false(error.isCanceled);\n\tt.false(error.isTerminated);\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, undefined);\n\tt.is(error.signalDescription, undefined);\n\tt.is(error.stdout, undefined);\n\tt.is(error.stderr, undefined);\n\tt.is(error.all, undefined);\n\tt.deepEqual(error.stdio, Array.from({length: error.stdio.length}));\n\tt.deepEqual(error.pipedFrom, []);\n\n\tt.true(error.originalMessage.includes('Pipe canceled'));\n\tt.true(error.shortMessage.includes(`Command failed: ${error.command}`));\n\tt.true(error.shortMessage.includes(error.originalMessage));\n\tt.true(error.message.includes(error.shortMessage));\n};\n\ntest('Can unpipe a single subprocess', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('stdin.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tsource.stdin.end(foobarString);\n\tdestination.stdin.end('.');\n\n\tt.like(await destination, {stdout: '.'});\n\tt.like(await source, {stdout: foobarString});\n});\n\ntest('Can use an already aborted signal', async t => {\n\tconst abortController = new AbortController();\n\tabortController.abort();\n\tconst source = execa('empty.js');\n\tconst destination = execa('empty.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\n\tawait assertUnPipeError(t, pipePromise);\n});\n\ntest('Can unpipe a subprocess among other sources', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('stdin.js');\n\tconst secondSource = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\tconst secondPipePromise = secondSource.pipe(destination);\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tsource.stdin.end('.');\n\n\tt.is(await secondPipePromise, await destination);\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await source, {stdout: '.'});\n\tt.like(await secondSource, {stdout: foobarString});\n});\n\ntest('Can unpipe a subprocess among other sources on the same subprocess', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('stdin-both.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\tconst secondPipePromise = source.pipe(destination, {from: 'stderr'});\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tsource.stdin.end(foobarString);\n\n\tt.is(await secondPipePromise, await destination);\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await source, {stdout: foobarString, stderr: foobarString});\n});\n\ntest('Can unpipe a subprocess among other destinations', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('stdin.js');\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\tconst secondPipePromise = source.pipe(secondDestination);\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tsource.stdin.end(foobarString);\n\tdestination.stdin.end('.');\n\n\tt.is(await secondPipePromise, await secondDestination);\n\tt.like(await destination, {stdout: '.'});\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await secondDestination, {stdout: foobarString});\n});\n\ntest('Can unpipe then re-pipe a subprocess', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('stdin.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\n\tsource.stdin.write('.');\n\tconst [firstWrite] = await once(source.stdout, 'data');\n\tt.is(firstWrite.toString(), '.');\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tsource.pipe(destination);\n\tsource.stdin.end('.');\n\n\tt.like(await destination, {stdout: '..'});\n\tt.like(await source, {stdout: '..'});\n});\n\ntest('Can unpipe to prevent termination to propagate to source', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('stdin.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tdestination.kill();\n\tt.like(await t.throwsAsync(destination), {signal: 'SIGTERM'});\n\n\tsource.stdin.end(foobarString);\n\tt.like(await source, {stdout: foobarString});\n});\n\ntest('Can unpipe to prevent termination to propagate to destination', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('noop-forever.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\n\tabortController.abort();\n\tawait assertUnPipeError(t, pipePromise);\n\n\tsource.kill();\n\tt.like(await t.throwsAsync(source), {signal: 'SIGTERM'});\n\n\tdestination.stdin.end(foobarString);\n\tt.like(await destination, {stdout: foobarString});\n});\n"
  },
  {
    "path": "test/pipe/pipe-arguments.js",
    "content": "import {spawn} from 'node:child_process';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport {$, execa} from '../../index.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getDenoNodePath} from '../helpers/file-path.js';\n\nsetFixtureDirectory();\n\ntest('$.pipe(subprocess)', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`);\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(subprocess)', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe($({stdin: 'pipe'})`stdin.js`);\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(subprocess)', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe($({stdin: 'pipe'})`stdin.js`)\n\t\t.pipe($({stdin: 'pipe'})`stdin.js`);\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe`command`', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe`command`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe`command`', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe`stdin.js`\n\t\t.pipe`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe(\"file\")', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe('stdin.js');\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(\"file\")`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe('stdin.js');\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(\"file\")', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe`stdin.js`\n\t\t.pipe('stdin.js');\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(fileUrl)`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe(pathToFileURL(`${FIXTURES_DIRECTORY}/stdin.js`));\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe(\"file\", commandArguments, options)', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY});\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(\"file\", commandArguments, options)`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY});\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(\"file\", commandArguments, options with denoNodePath)`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY, nodePath: getDenoNodePath()});\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(\"file\", commandArguments, denoNodePath)`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe(getDenoNodePath(), ['stdin.js'], {cwd: FIXTURES_DIRECTORY});\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(\"file\", commandArguments, options)', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe`stdin.js`\n\t\t.pipe('node', ['stdin.js'], {cwd: FIXTURES_DIRECTORY});\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe(subprocess, pipeOptions)', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(subprocess, pipeOptions)', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(subprocess, pipeOptions)', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}`\n\t\t.pipe($({stdin: 'pipe'})`noop-stdin-fd.js 2`, {from: 'stderr'})\n\t\t.pipe($({stdin: 'pipe'})`stdin.js`, {from: 'stderr'});\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe(pipeOptions)`command`', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe({from: 'stderr'})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(pipeOptions)`command`', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe({from: 'stderr'})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(pipeOptions)`command`', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}`\n\t\t.pipe({from: 'stderr'})`noop-stdin-fd.js 2`\n\t\t.pipe({from: 'stderr'})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe(\"file\", pipeOptions)', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}`.pipe('stdin.js', {from: 'stderr'});\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(\"file\", pipeOptions)', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['2', foobarString]).pipe('stdin.js', {from: 'stderr'});\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(\"file\", pipeOptions)', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}`\n\t\t.pipe({from: 'stderr'})`noop-stdin-fd.js 2`\n\t\t.pipe('stdin.js', {from: 'stderr'});\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe(options)`command`', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe({stripFinalNewline: false})`stdin.js`;\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('execa.$.pipe(options)`command`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe({stripFinalNewline: false})`stdin.js`;\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe.pipe(options)`command`', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe({})`stdin.js`\n\t\t.pipe({stripFinalNewline: false})`stdin.js`;\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe(\"file\", options)', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe('stdin.js', {stripFinalNewline: false});\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('execa.$.pipe(\"file\", options)', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe('stdin.js', {stripFinalNewline: false});\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe.pipe(\"file\", options)', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe({})`stdin.js`\n\t\t.pipe('stdin.js', {stripFinalNewline: false});\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe(pipeAndSubprocessOptions)`command`', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}\\n`.pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('execa.$.pipe(pipeAndSubprocessOptions)`command`', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['2', `${foobarString}\\n`]).pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe.pipe(pipeAndSubprocessOptions)`command`', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}\\n`\n\t\t.pipe({from: 'stderr'})`noop-stdin-fd.js 2`\n\t\t.pipe({from: 'stderr', stripFinalNewline: false})`stdin.js`;\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe(\"file\", pipeAndSubprocessOptions)', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}\\n`.pipe('stdin.js', {from: 'stderr', stripFinalNewline: false});\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('execa.$.pipe(\"file\", pipeAndSubprocessOptions)', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['2', `${foobarString}\\n`]).pipe('stdin.js', {from: 'stderr', stripFinalNewline: false});\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe.pipe(\"file\", pipeAndSubprocessOptions)', async t => {\n\tconst {stdout} = await $`noop-fd.js 2 ${foobarString}\\n`\n\t\t.pipe({from: 'stderr'})`noop-stdin-fd.js 2`\n\t\t.pipe('stdin.js', {from: 'stderr', stripFinalNewline: false});\n\tt.is(stdout, `${foobarString}\\n`);\n});\n\ntest('$.pipe(options)(secondOptions)`command`', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.$.pipe(options)(secondOptions)`command`', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe.pipe(options)(secondOptions)`command`', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`\n\t\t.pipe({})({})`stdin.js`\n\t\t.pipe({stripFinalNewline: false})({stripFinalNewline: true})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('$.pipe`command` forces \"stdin: pipe\"', async t => {\n\tconst {stdout} = await $`noop.js ${foobarString}`.pipe({stdin: 'ignore'})`stdin.js`;\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.pipe(\"file\") forces \"stdin: \"pipe\"', async t => {\n\tconst {stdout} = await execa('noop.js', [foobarString]).pipe('stdin.js', {stdin: 'ignore'});\n\tt.is(stdout, foobarString);\n});\n\ntest('execa.pipe(subprocess) does not force \"stdin: pipe\"', async t => {\n\tawait t.throwsAsync(\n\t\texeca('noop.js', [foobarString]).pipe(execa('stdin.js', {stdin: 'ignore'})),\n\t\t{message: /\"stdin: 'ignore'\" option is incompatible/},\n\t);\n});\n\ntest('$.pipe(options)(subprocess) fails', async t => {\n\tawait t.throwsAsync(\n\t\t$`empty.js`.pipe({stdout: 'pipe'})($`empty.js`),\n\t\t{message: /Please use \\.pipe/},\n\t);\n});\n\ntest('execa.$.pipe(options)(subprocess) fails', async t => {\n\tawait t.throwsAsync(\n\t\texeca('empty.js').pipe({stdout: 'pipe'})($`empty.js`),\n\t\t{message: /Please use \\.pipe/},\n\t);\n});\n\ntest('$.pipe(options)(\"file\") fails', async t => {\n\tawait t.throwsAsync(\n\t\t$`empty.js`.pipe({stdout: 'pipe'})('empty.js'),\n\t\t{message: /Please use \\.pipe/},\n\t);\n});\n\ntest('execa.$.pipe(options)(\"file\") fails', async t => {\n\tawait t.throwsAsync(\n\t\texeca('empty.js').pipe({stdout: 'pipe'})('empty.js'),\n\t\t{message: /Please use \\.pipe/},\n\t);\n});\n\nconst testInvalidPipe = async (t, ...pipeArguments) => {\n\tawait t.throwsAsync(\n\t\t$`empty.js`.pipe(...pipeArguments),\n\t\t{message: /must be a template string/},\n\t);\n};\n\ntest('$.pipe(nonExecaSubprocess) fails', testInvalidPipe, spawn('node', ['--version']));\ntest('$.pipe(false) fails', testInvalidPipe, false);\n"
  },
  {
    "path": "test/pipe/sequence.js",
    "content": "import {once} from 'node:events';\nimport process from 'node:process';\nimport {PassThrough} from 'node:stream';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {noopGenerator} from '../helpers/generator.js';\nimport {prematureClose} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst isLinux = process.platform === 'linux';\n\ntest('Source stream abort -> destination success', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tsource.stdout.destroy();\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n\tawait destination;\n});\n\ntest('Source stream error -> destination success', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst cause = new Error('test');\n\tsource.stdout.destroy(cause);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tt.like(await t.throwsAsync(source), {originalMessage: cause.message, exitCode: 1});\n\tawait destination;\n});\n\ntest('Destination stream abort -> source failure', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tdestination.stdin.destroy();\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await t.throwsAsync(destination), prematureClose);\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n});\n\ntest('Destination stream error -> source failure', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst cause = new Error('test');\n\tdestination.stdin.destroy(cause);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await t.throwsAsync(destination), {originalMessage: cause.message, exitCode: 0});\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n});\n\ntest('Source success -> destination success', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.is(await pipePromise, await destination);\n});\n\ntest('Destination stream end -> source failure', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tdestination.stdin.end();\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tawait destination;\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n});\n\ntest('Source normal failure -> destination success', async t => {\n\tconst source = execa('noop-fail.js', ['1', foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tt.like(await t.throwsAsync(source), {stdout: foobarString, exitCode: 2});\n\tawait destination;\n});\n\ntest('Source normal failure -> deep destination success', async t => {\n\tconst source = execa('noop-fail.js', ['1', foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = pipePromise.pipe(secondDestination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tt.is(await t.throwsAsync(secondPipePromise), await t.throwsAsync(source));\n\tt.like(await t.throwsAsync(source), {stdout: foobarString, exitCode: 2});\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await secondDestination, {stdout: foobarString});\n});\n\nconst testSourceTerminated = async (t, signal) => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tsource.kill(signal);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tt.like(await t.throwsAsync(source), {signal});\n\tawait destination;\n};\n\ntest('Source SIGTERM -> destination success', testSourceTerminated, 'SIGTERM');\ntest('Source SIGKILL -> destination success', testSourceTerminated, 'SIGKILL');\n\ntest('Destination success before source -> source success', async t => {\n\tconst passThroughStream = new PassThrough();\n\tconst source = execa('stdin.js', {stdin: ['pipe', passThroughStream]});\n\tconst destination = execa('empty.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tawait destination;\n\tpassThroughStream.end();\n\tawait source;\n\tt.is(await pipePromise, await destination);\n});\n\ntest('Destination normal failure -> source failure', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('fail.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await t.throwsAsync(destination), {exitCode: 2});\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n});\n\ntest('Destination normal failure -> deep source failure', async t => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('fail.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = pipePromise.pipe(secondDestination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.is(await t.throwsAsync(secondPipePromise), await t.throwsAsync(secondDestination));\n\tt.like(await t.throwsAsync(secondDestination), {exitCode: 2});\n\tt.like(await t.throwsAsync(destination), {exitCode: 1});\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n});\n\nconst testDestinationTerminated = async (t, signal) => {\n\tconst source = execa('noop-repeat.js');\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tdestination.kill(signal);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await t.throwsAsync(destination), {signal});\n\tt.like(await t.throwsAsync(source), {exitCode: 1});\n};\n\ntest('Destination SIGTERM -> source abort', testDestinationTerminated, 'SIGTERM');\ntest('Destination SIGKILL -> source abort', testDestinationTerminated, 'SIGKILL');\n\ntest('Source already ended -> ignore source', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tawait source;\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await pipePromise, await destination);\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: ''});\n});\n\ntest('Source already aborted -> ignore source', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tsource.stdout.destroy();\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await pipePromise, await destination);\n\tt.like(await source, {stdout: ''});\n\tt.like(await destination, {stdout: ''});\n});\n\ntest('Source already errored -> failure', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst cause = new Error('test');\n\tsource.stdout.destroy(cause);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\tt.like(await t.throwsAsync(source), {cause});\n\tt.like(await destination, {stdout: ''});\n});\n\ntest('Destination already ended -> ignore source', async t => {\n\tconst destination = execa('stdin.js');\n\tdestination.stdin.end('.');\n\tawait destination;\n\tconst source = execa('noop.js', [foobarString]);\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await pipePromise, await destination);\n\tt.like(await destination, {stdout: '.'});\n\tt.like(await source, {stdout: ''});\n});\n\ntest('Destination already aborted -> failure', async t => {\n\tconst destination = execa('stdin.js');\n\tdestination.stdin.destroy();\n\tt.like(await t.throwsAsync(destination), prematureClose);\n\tconst source = execa('noop.js', [foobarString]);\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await source, {stdout: ''});\n});\n\ntest('Destination already errored -> failure', async t => {\n\tconst destination = execa('stdin.js');\n\tconst cause = new Error('test');\n\tdestination.stdin.destroy(cause);\n\tt.like(await t.throwsAsync(destination), {cause});\n\tconst source = execa('noop.js', [foobarString]);\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await source, {stdout: ''});\n});\n\ntest('Source normal failure + destination normal failure', async t => {\n\tconst source = execa('noop-fail.js', ['1', foobarString]);\n\tconst destination = execa('stdin-fail.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await t.throwsAsync(source), {stdout: foobarString, exitCode: 2});\n\tt.like(await t.throwsAsync(destination), {stdout: foobarString, exitCode: 2});\n});\n\ntest('Simultaneous error on source and destination', async t => {\n\tconst source = execa('noop.js', ['']);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tconst sourceCause = new Error(foobarString);\n\tsource.emit('error', sourceCause);\n\tconst destinationCause = new Error('other');\n\tdestination.emit('error', destinationCause);\n\n\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(destination));\n\tt.like(await t.throwsAsync(source), {cause: {originalMessage: sourceCause.originalMessage}});\n\tt.like(await t.throwsAsync(destination), {cause: {originalMessage: destinationCause.originalMessage}});\n});\n\ntest('Does not need to await individual promises', async t => {\n\tconst source = execa('fail.js');\n\tconst destination = execa('fail.js');\n\tawait t.throwsAsync(source.pipe(destination));\n});\n\ntest('Need to await .pipe() return value', async t => {\n\tconst source = execa('fail.js');\n\tconst destination = execa('fail.js');\n\tconst pipePromise = source.pipe(destination);\n\tawait Promise.all([\n\t\tonce(process, 'unhandledRejection'),\n\t\tt.throwsAsync(source),\n\t\tt.throwsAsync(destination),\n\t]);\n\tawait t.throwsAsync(pipePromise);\n});\n\nif (isLinux) {\n\tconst testYesHead = async (t, useStdoutTransform, useStdinTransform, all) => {\n\t\tconst source = execa('yes', {stdout: useStdoutTransform ? noopGenerator(false) : 'pipe', all});\n\t\tconst destination = execa('head', ['-n', '1'], {stdin: useStdinTransform ? noopGenerator(false) : 'pipe'});\n\t\tconst pipePromise = source.pipe(destination);\n\t\tt.is(await t.throwsAsync(pipePromise), await t.throwsAsync(source));\n\t\tt.like(await destination, {stdout: 'y'});\n\t\tt.like(await t.throwsAsync(source), {exitCode: 1, stderr: 'yes: standard output: Connection reset by peer'});\n\n\t\tt.false(source.stdout.readableEnded);\n\t\tt.is(source.stdout.errored, null);\n\t\tt.true(source.stdout.destroyed);\n\t\tt.true(source.stderr.readableEnded);\n\t\tt.is(source.stderr.errored, null);\n\t\tt.true(source.stderr.destroyed);\n\n\t\tif (all) {\n\t\t\tt.true(source.all.readableEnded);\n\t\t\tt.is(source.all.errored, null);\n\t\t\tt.true(source.all.destroyed);\n\t\t}\n\t};\n\n\ttest.serial('Works with yes | head', testYesHead, false, false, false);\n\ttest.serial('Works with yes | head, input transform', testYesHead, false, true, false);\n\ttest.serial('Works with yes | head, output transform', testYesHead, true, false, false);\n\ttest.serial('Works with yes | head, input/output transform', testYesHead, true, true, false);\n\ttest.serial('Works with yes | head, \"all\" option', testYesHead, false, false, true);\n\ttest.serial('Works with yes | head, \"all\" option, input transform', testYesHead, false, true, true);\n\ttest.serial('Works with yes | head, \"all\" option, output transform', testYesHead, true, false, true);\n\ttest.serial('Works with yes | head, \"all\" option, input/output transform', testYesHead, true, true, true);\n}\n"
  },
  {
    "path": "test/pipe/setup.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio, fullReadableStdio} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst pipeToSubprocess = async (t, readableFdNumber, writableFdNumber, from, to, readableOptions = {}, writableOptions = {}) => {\n\tconst {stdout} = await execa('noop-fd.js', [`${readableFdNumber}`, foobarString], readableOptions)\n\t\t.pipe(execa('stdin-fd.js', [`${writableFdNumber}`], writableOptions), {from, to});\n\tt.is(stdout, foobarString);\n};\n\ntest('pipe(...) can pipe', pipeToSubprocess, 1, 0);\ntest('pipe(..., {from: \"stdout\"}) can pipe', pipeToSubprocess, 1, 0, 'stdout');\ntest('pipe(..., {from: \"fd1\"}) can pipe', pipeToSubprocess, 1, 0, 'fd1');\ntest('pipe(..., {from: \"stderr\"}) can pipe stderr', pipeToSubprocess, 2, 0, 'stderr');\ntest('pipe(..., {from: \"fd2\"}) can pipe', pipeToSubprocess, 2, 0, 'fd2');\ntest('pipe(..., {from: \"fd3\"}) can pipe', pipeToSubprocess, 3, 0, 'fd3', undefined, fullStdio);\ntest('pipe(..., {from: \"all\"}) can pipe stdout', pipeToSubprocess, 1, 0, 'all', undefined, {all: true});\ntest('pipe(..., {from: \"all\"}) can pipe stderr', pipeToSubprocess, 2, 0, 'all', undefined, {all: true});\ntest('pipe(..., {from: \"all\"}) can pipe stdout even with \"stderr: ignore\"', pipeToSubprocess, 1, 0, 'all', undefined, {all: true, stderr: 'ignore'});\ntest('pipe(..., {from: \"all\"}) can pipe stderr even with \"stdout: ignore\"', pipeToSubprocess, 2, 0, 'all', undefined, {all: true, stdout: 'ignore'});\ntest('pipe(..., {to: \"stdin\"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'stdin');\ntest('pipe(..., {to: \"fd0\"}) can pipe', pipeToSubprocess, 1, 0, undefined, 'fd0');\ntest('pipe(..., {to: \"fd3\"}) can pipe', pipeToSubprocess, 1, 3, undefined, 'fd3', {}, fullReadableStdio());\n"
  },
  {
    "path": "test/pipe/streaming.js",
    "content": "import {once} from 'node:events';\nimport {PassThrough} from 'node:stream';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {assertMaxListeners} from '../helpers/listeners.js';\nimport {fullReadableStdio} from '../helpers/stdio.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\ntest('Can pipe two sources to same destination', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst secondSource = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await secondSource, {stdout: foobarString});\n\tt.like(await destination, {stdout: `${foobarString}\\n${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n});\n\ntest('Can pipe three sources to same destination', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst secondSource = execa('noop.js', [foobarString]);\n\tconst thirdSource = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\tconst thirdPromise = thirdSource.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await secondSource, {stdout: foobarString});\n\tt.like(await thirdSource, {stdout: foobarString});\n\tt.like(await destination, {stdout: `${foobarString}\\n${foobarString}\\n${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n\tt.is(await thirdPromise, await destination);\n});\n\ntest.serial('Can pipe many sources to same destination', async t => {\n\tconst checkMaxListeners = assertMaxListeners(t);\n\n\tconst expectedResults = Array.from({length: PARALLEL_COUNT}, (_, index) => `${index}`).sort();\n\tconst sources = expectedResults.map(expectedResult => execa('noop.js', [expectedResult]));\n\tconst destination = execa('stdin.js');\n\tconst pipePromises = sources.map(source => source.pipe(destination));\n\n\tconst results = await Promise.all(sources);\n\tt.deepEqual(results.map(({stdout}) => stdout), expectedResults);\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.stdout.split('\\n').sort(), expectedResults);\n\tt.deepEqual(await Promise.all(pipePromises), sources.map(() => destinationResult));\n\n\tcheckMaxListeners();\n});\n\ntest.serial('Can pipe same source to many destinations', async t => {\n\tconst checkMaxListeners = assertMaxListeners(t);\n\n\tconst source = execa('noop-fd.js', ['1', foobarString]);\n\tconst expectedResults = Array.from({length: PARALLEL_COUNT}, (_, index) => `${index}`);\n\tconst destinations = expectedResults.map(expectedResult => execa('noop-stdin-double.js', [expectedResult]));\n\tconst pipePromises = destinations.map(destination => source.pipe(destination));\n\n\tt.like(await source, {stdout: foobarString});\n\tconst results = await Promise.all(destinations);\n\tt.deepEqual(results.map(({stdout}) => stdout), expectedResults.map(result => `${foobarString} ${result}`));\n\tt.deepEqual(await Promise.all(pipePromises), results);\n\n\tcheckMaxListeners();\n});\n\ntest('Can pipe two streams from same subprocess to same destination', async t => {\n\tconst source = execa('noop-both.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = source.pipe(destination, {from: 'stderr'});\n\n\tt.like(await source, {stdout: foobarString, stderr: foobarString});\n\tt.like(await destination, {stdout: `${foobarString}\\n${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n});\n\ntest('Can pipe same source to two streams from same subprocess', async t => {\n\tconst source = execa('noop-fd.js', ['1', foobarString]);\n\tconst destination = execa('stdin-fd-both.js', ['3'], fullReadableStdio());\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = source.pipe(destination, {to: 'fd3'});\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: `${foobarString}${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n});\n\ntest('Can pipe a new source to same destination after some source has already written', async t => {\n\tconst passThroughStream = new PassThrough();\n\tconst source = execa('stdin.js', {stdin: ['pipe', passThroughStream]});\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tpassThroughStream.write('foo');\n\tconst firstWrite = await once(destination.stdout, 'data');\n\tt.is(firstWrite.toString(), 'foo');\n\n\tconst secondSource = execa('noop.js', ['bar']);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\tpassThroughStream.end();\n\n\tt.like(await source, {stdout: 'foo'});\n\tt.like(await secondSource, {stdout: 'bar'});\n\tt.like(await destination, {stdout: 'foobar'});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n});\n\ntest('Can pipe a second source to same destination after destination has already ended', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.is(await pipePromise, await destination);\n\n\tconst secondSource = execa('noop.js', [foobarString]);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\n\tt.like(await secondSource, {stdout: ''});\n\tt.is(await secondPipePromise, await destination);\n});\n\ntest('Can pipe same source to a second destination after source has already ended', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.is(await pipePromise, await destination);\n\n\tconst secondDestination = execa('stdin.js');\n\tconst secondPipePromise = source.pipe(secondDestination);\n\n\tt.like(await secondDestination, {stdout: ''});\n\tt.is(await secondPipePromise, await secondDestination);\n});\n\ntest('Can pipe a new source to same destination after some but not all sources have ended', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst passThroughStream = new PassThrough();\n\tconst secondSource = execa('stdin.js', {stdin: ['pipe', passThroughStream]});\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\n\tconst thirdSource = execa('noop.js', [foobarString]);\n\tconst thirdPipePromise = thirdSource.pipe(destination);\n\tpassThroughStream.end(`${foobarString}\\n`);\n\n\tt.like(await secondSource, {stdout: foobarString});\n\tt.like(await thirdSource, {stdout: foobarString});\n\tt.like(await destination, {stdout: `${foobarString}\\n${foobarString}\\n${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n\tt.is(await thirdPipePromise, await destination);\n});\n\ntest('Can pipe two subprocesses already ended', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tdestination.stdin.end('.');\n\tawait Promise.all([source, destination]);\n\tconst pipePromise = source.pipe(destination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: '.'});\n\tt.is(await pipePromise, await destination);\n});\n\ntest('Can pipe to same destination through multiple paths', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = pipePromise.pipe(secondDestination);\n\tconst thirdPipePromise = source.pipe(secondDestination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await secondDestination, {stdout: `${foobarString}\\n${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await secondDestination);\n\tt.is(await thirdPipePromise, await secondDestination);\n});\n\ntest('Can pipe two sources to same destination in objectMode', async t => {\n\tconst stdoutTransform = {\n\t\t* transform() {\n\t\t\tyield [foobarString];\n\t\t},\n\t\tobjectMode: true,\n\t};\n\tconst source = execa('noop.js', [''], {stdout: stdoutTransform});\n\tconst secondSource = execa('noop.js', [''], {stdout: stdoutTransform});\n\tt.true(source.stdout.readableObjectMode);\n\tt.true(secondSource.stdout.readableObjectMode);\n\n\tconst stdinTransform = {\n\t\t* transform([chunk]) {\n\t\t\tyield chunk;\n\t\t},\n\t\tobjectMode: true,\n\t};\n\tconst destination = execa('stdin.js', {stdin: stdinTransform});\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\n\tt.like(await source, {stdout: [[foobarString]]});\n\tt.like(await secondSource, {stdout: [[foobarString]]});\n\tt.like(await destination, {stdout: `${foobarString}\\n${foobarString}`});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await destination);\n});\n\ntest('Can pipe one source to two destinations', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = source.pipe(secondDestination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await secondDestination, {stdout: foobarString});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await secondDestination);\n});\n\ntest('Can pipe one source to three destinations', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst thirdDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = source.pipe(secondDestination);\n\tconst thirdPipePromise = source.pipe(thirdDestination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await secondDestination, {stdout: foobarString});\n\tt.like(await thirdDestination, {stdout: foobarString});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await secondDestination);\n\tt.is(await thirdPipePromise, await thirdDestination);\n});\n\ntest('Can create a series of pipes', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = pipePromise.pipe(secondDestination);\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.like(await secondDestination, {stdout: foobarString});\n\tt.is(await pipePromise, await destination);\n\tt.is(await secondPipePromise, await secondDestination);\n});\n\ntest('Returns pipedFrom on success', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.pipedFrom, []);\n\tconst sourceResult = await source;\n\n\tt.like(await pipePromise, {pipedFrom: [sourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom on deep success', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = pipePromise.pipe(secondDestination);\n\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.pipedFrom, []);\n\tconst secondDestinationResult = await secondDestination;\n\tt.deepEqual(secondDestinationResult.pipedFrom, []);\n\tconst sourceResult = await source;\n\n\tt.like(await secondPipePromise, {pipedFrom: [destinationResult]});\n\tt.deepEqual(secondDestinationResult.pipedFrom, [destinationResult]);\n\tt.like(await pipePromise, {pipedFrom: [sourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom on source failure', async t => {\n\tconst source = execa('noop-fail.js', ['1', foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.pipedFrom, []);\n\tconst sourceResult = await t.throwsAsync(source);\n\n\tt.like(await t.throwsAsync(pipePromise), {pipedFrom: []});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom on destination failure', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin-fail.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tconst destinationResult = await t.throwsAsync(destination);\n\tconst sourceResult = await source;\n\n\tt.like(await t.throwsAsync(pipePromise), {pipedFrom: [sourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom on source + destination failure', async t => {\n\tconst source = execa('noop-fail.js', ['1', foobarString]);\n\tconst destination = execa('stdin-fail.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tconst destinationResult = await t.throwsAsync(destination);\n\tconst sourceResult = await t.throwsAsync(source);\n\n\tt.like(await t.throwsAsync(pipePromise), {pipedFrom: [sourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom on deep failure', async t => {\n\tconst source = execa('noop-fail.js', ['1', foobarString]);\n\tconst destination = execa('stdin-fail.js');\n\tconst secondDestination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = pipePromise.pipe(secondDestination);\n\n\tconst destinationResult = await t.throwsAsync(destination);\n\tconst secondDestinationResult = await secondDestination;\n\tt.deepEqual(secondDestinationResult.pipedFrom, []);\n\tconst sourceResult = await t.throwsAsync(source);\n\n\tt.like(await t.throwsAsync(secondPipePromise), {pipedFrom: [sourceResult]});\n\tt.deepEqual(secondDestinationResult.pipedFrom, [destinationResult]);\n\tt.like(await t.throwsAsync(pipePromise), {pipedFrom: [sourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom from multiple sources', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst secondSource = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = secondSource.pipe(destination);\n\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.pipedFrom, []);\n\tconst sourceResult = await source;\n\tconst secondSourceResult = await secondSource;\n\n\tt.like(await pipePromise, {pipedFrom: [sourceResult, secondSourceResult]});\n\tt.like(await secondPipePromise, {pipedFrom: [sourceResult, secondSourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult, secondSourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n\tt.deepEqual(secondSourceResult.pipedFrom, []);\n});\n\ntest('Returns pipedFrom from already ended subprocesses', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tdestination.stdin.end('.');\n\tawait Promise.all([source, destination]);\n\tconst pipePromise = source.pipe(destination);\n\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.pipedFrom, []);\n\tconst sourceResult = await source;\n\tt.deepEqual(sourceResult.pipedFrom, []);\n\n\tt.like(await pipePromise, {pipedFrom: [sourceResult]});\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Does not return nor set pipedFrom on signal abort', async t => {\n\tconst abortController = new AbortController();\n\tconst source = execa('empty.js');\n\tconst destination = execa('empty.js');\n\tconst pipePromise = source.pipe(destination, {unpipeSignal: abortController.signal});\n\n\tabortController.abort();\n\tt.like(await t.throwsAsync(pipePromise), {pipedFrom: []});\n\tconst destinationResult = await destination;\n\tt.deepEqual(destinationResult.pipedFrom, []);\n\tconst sourceResult = await source;\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n\ntest('Can pipe same source to same destination twice', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\tconst secondPipePromise = source.pipe(destination);\n\n\tconst destinationResult = await destination;\n\tt.like(destinationResult, {pipedFrom: []});\n\tconst sourceResult = await source;\n\tt.like(sourceResult, {pipedFrom: []});\n\n\tt.like(await source, {stdout: foobarString});\n\tt.like(await destination, {stdout: foobarString});\n\tt.is(await pipePromise, destinationResult);\n\tt.is(await secondPipePromise, destinationResult);\n\tt.deepEqual(destinationResult.pipedFrom, [sourceResult]);\n\tt.deepEqual(sourceResult.pipedFrom, []);\n});\n"
  },
  {
    "path": "test/pipe/throw.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {assertPipeError} from '../helpers/pipe.js';\n\nsetFixtureDirectory();\n\ntest('Destination stream is ended when first argument is invalid', async t => {\n\tconst source = execa('empty.js', {stdout: 'ignore'});\n\tconst destination = execa('stdin.js');\n\tconst pipePromise = source.pipe(destination);\n\n\tawait assertPipeError(t, pipePromise, 'option is incompatible');\n\tawait source;\n\tt.like(await destination, {stdout: ''});\n});\n\ntest('Destination stream is ended when first argument is invalid - $', async t => {\n\tconst pipePromise = execa('empty.js', {stdout: 'ignore'}).pipe`stdin.js`;\n\tawait assertPipeError(t, pipePromise, 'option is incompatible');\n});\n\ntest('Source stream is aborted when second argument is invalid', async t => {\n\tconst source = execa('noop.js', [foobarString]);\n\tconst pipePromise = source.pipe(false);\n\n\tawait assertPipeError(t, pipePromise, 'an Execa subprocess');\n\tt.like(await source, {stdout: ''});\n});\n\ntest('Both arguments might be invalid', async t => {\n\tconst source = execa('empty.js', {stdout: 'ignore'});\n\tconst pipePromise = source.pipe(false);\n\n\tawait assertPipeError(t, pipePromise, 'an Execa subprocess');\n\tt.like(await source, {stdout: undefined});\n});\n"
  },
  {
    "path": "test/resolve/all.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {defaultHighWaterMark} from '../helpers/stream.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst textEncoder = new TextEncoder();\nconst foobarStringFull = `${foobarString}\\n`;\nconst doubleFoobarStringFull = `${foobarStringFull}${foobarStringFull}`;\nconst doubleFoobarString = `${foobarStringFull}${foobarString}`;\nconst doubleFoobarUint8ArrayFull = textEncoder.encode(doubleFoobarStringFull);\nconst doubleFoobarUint8Array = textEncoder.encode(doubleFoobarString);\nconst doubleFoobarArrayFull = [foobarStringFull, foobarStringFull];\nconst doubleFoobarArray = [foobarString, foobarString];\n\n// eslint-disable-next-line max-params\nconst testAllBoth = async (t, expectedOutput, encoding, lines, stripFinalNewline, isFailure, execaMethod) => {\n\tconst fixtureName = isFailure ? 'noop-both-fail.js' : 'noop-both.js';\n\tconst {exitCode, all} = await execaMethod(fixtureName, [foobarString], {\n\t\tall: true,\n\t\tencoding,\n\t\tlines,\n\t\tstripFinalNewline,\n\t\treject: !isFailure,\n\t});\n\tt.is(exitCode, isFailure ? 1 : 0);\n\tt.deepEqual(all, expectedOutput);\n};\n\nconst fdOne = {stderr: true};\nconst fdBoth = {stdout: true, stderr: true};\n\ntest('result.all is defined', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, false, execa);\ntest('result.all is defined, encoding \"buffer\"', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, false, execa);\ntest('result.all is defined, lines', testAllBoth, doubleFoobarArrayFull, 'utf8', true, false, false, execa);\ntest('result.all is defined, lines, fd-specific one', testAllBoth, doubleFoobarArrayFull, 'utf8', fdOne, false, false, execa);\ntest('result.all is defined, lines, fd-specific both', testAllBoth, doubleFoobarArrayFull, 'utf8', fdBoth, false, false, execa);\ntest('result.all is defined, stripFinalNewline', testAllBoth, doubleFoobarString, 'utf8', false, true, false, execa);\ntest('result.all is defined, stripFinalNewline, fd-specific one', testAllBoth, doubleFoobarString, 'utf8', false, fdOne, false, execa);\ntest('result.all is defined, stripFinalNewline, fd-specific both', testAllBoth, doubleFoobarString, 'utf8', false, fdBoth, false, execa);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, false, execa);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific one', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdOne, false, execa);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific both', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdBoth, false, execa);\ntest('result.all is defined, lines, stripFinalNewline', testAllBoth, doubleFoobarArray, 'utf8', true, true, false, execa);\ntest('result.all is defined, lines, fd-specific one, stripFinalNewline', testAllBoth, doubleFoobarArray, 'utf8', fdOne, true, false, execa);\ntest('result.all is defined, lines, fd-specific both, stripFinalNewline', testAllBoth, doubleFoobarArray, 'utf8', fdBoth, true, false, execa);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific one', testAllBoth, doubleFoobarArray, 'utf8', true, fdOne, false, execa);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific both', testAllBoth, doubleFoobarArray, 'utf8', true, fdBoth, false, execa);\ntest('result.all is defined, failure', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, true, execa);\ntest('result.all is defined, encoding \"buffer\", failure', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, true, execa);\ntest('result.all is defined, lines, failure', testAllBoth, doubleFoobarArrayFull, 'utf8', true, false, true, execa);\ntest('result.all is defined, lines, fd-specific one, failure', testAllBoth, doubleFoobarArrayFull, 'utf8', fdOne, false, true, execa);\ntest('result.all is defined, lines, fd-specific both, failure', testAllBoth, doubleFoobarArrayFull, 'utf8', fdBoth, false, true, execa);\ntest('result.all is defined, stripFinalNewline, failure', testAllBoth, doubleFoobarString, 'utf8', false, true, true, execa);\ntest('result.all is defined, stripFinalNewline, fd-specific one, failure', testAllBoth, doubleFoobarString, 'utf8', false, fdOne, true, execa);\ntest('result.all is defined, stripFinalNewline, fd-specific both, failure', testAllBoth, doubleFoobarString, 'utf8', false, fdBoth, true, execa);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, failure', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, true, execa);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific one, failure', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdOne, true, execa);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific both, failure', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdBoth, true, execa);\ntest('result.all is defined, lines, stripFinalNewline, failure', testAllBoth, doubleFoobarArray, 'utf8', true, true, true, execa);\ntest('result.all is defined, lines, fd-specific one, stripFinalNewline, failure', testAllBoth, doubleFoobarArray, 'utf8', fdOne, true, true, execa);\ntest('result.all is defined, lines, fd-specific both, stripFinalNewline, failure', testAllBoth, doubleFoobarArray, 'utf8', fdBoth, true, true, execa);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific one, failure', testAllBoth, doubleFoobarArray, 'utf8', true, fdOne, true, execa);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific both, failure', testAllBoth, doubleFoobarArray, 'utf8', true, fdBoth, true, execa);\ntest('result.all is defined, sync', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, false, execaSync);\ntest('result.all is defined, encoding \"buffer\", sync', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, false, execaSync);\ntest('result.all is defined, lines, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', true, false, false, execaSync);\ntest('result.all is defined, lines, fd-specific one, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', fdOne, false, false, execaSync);\ntest('result.all is defined, lines, fd-specific both, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', fdBoth, false, false, execaSync);\ntest('result.all is defined, stripFinalNewline, sync', testAllBoth, doubleFoobarString, 'utf8', false, true, false, execaSync);\ntest('result.all is defined, stripFinalNewline, fd-specific one, sync', testAllBoth, doubleFoobarString, 'utf8', false, fdOne, false, execaSync);\ntest('result.all is defined, stripFinalNewline, fd-specific both, sync', testAllBoth, doubleFoobarString, 'utf8', false, fdBoth, false, execaSync);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, false, execaSync);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific one, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdOne, false, execaSync);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific both, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdBoth, false, execaSync);\ntest('result.all is defined, lines, stripFinalNewline, sync', testAllBoth, doubleFoobarArray, 'utf8', true, true, false, execaSync);\ntest('result.all is defined, lines, fd-specific one, stripFinalNewline, sync', testAllBoth, doubleFoobarArray, 'utf8', fdOne, true, false, execaSync);\ntest('result.all is defined, lines, fd-specific both, stripFinalNewline, sync', testAllBoth, doubleFoobarArray, 'utf8', fdBoth, true, false, execaSync);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific one, sync', testAllBoth, doubleFoobarArray, 'utf8', true, fdOne, false, execaSync);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific both, sync', testAllBoth, doubleFoobarArray, 'utf8', true, fdBoth, false, execaSync);\ntest('result.all is defined, failure, sync', testAllBoth, doubleFoobarStringFull, 'utf8', false, false, true, execaSync);\ntest('result.all is defined, encoding \"buffer\", failure, sync', testAllBoth, doubleFoobarUint8ArrayFull, 'buffer', false, false, true, execaSync);\ntest('result.all is defined, lines, failure, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', true, false, true, execaSync);\ntest('result.all is defined, lines, fd-specific one, failure, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', fdOne, false, true, execaSync);\ntest('result.all is defined, lines, fd-specific both, failure, sync', testAllBoth, doubleFoobarArrayFull, 'utf8', fdBoth, false, true, execaSync);\ntest('result.all is defined, stripFinalNewline, failure, sync', testAllBoth, doubleFoobarString, 'utf8', false, true, true, execaSync);\ntest('result.all is defined, stripFinalNewline, fd-specific one, failure, sync', testAllBoth, doubleFoobarString, 'utf8', false, fdOne, true, execaSync);\ntest('result.all is defined, stripFinalNewline, fd-specific both, failure, sync', testAllBoth, doubleFoobarString, 'utf8', false, fdBoth, true, execaSync);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, failure, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, true, true, execaSync);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific one, failure, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdOne, true, execaSync);\ntest('result.all is defined, encoding \"buffer\", stripFinalNewline, fd-specific both, failure, sync', testAllBoth, doubleFoobarUint8Array, 'buffer', false, fdBoth, true, execaSync);\ntest('result.all is defined, lines, stripFinalNewline, failure, sync', testAllBoth, doubleFoobarArray, 'utf8', true, true, true, execaSync);\ntest('result.all is defined, lines, fd-specific one, stripFinalNewline, failure, sync', testAllBoth, doubleFoobarArray, 'utf8', fdOne, true, true, execaSync);\ntest('result.all is defined, lines, fd-specific both, stripFinalNewline, failure, sync', testAllBoth, doubleFoobarArray, 'utf8', fdBoth, true, true, execaSync);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific one, failure, sync', testAllBoth, doubleFoobarArray, 'utf8', true, fdOne, true, execaSync);\ntest('result.all is defined, lines, stripFinalNewline, fd-specific both, failure, sync', testAllBoth, doubleFoobarArray, 'utf8', true, fdBoth, true, execaSync);\n\ntest.serial('result.all shows both `stdout` and `stderr` intermixed', async t => {\n\tconst {all} = await execa('noop-132.js', {all: true});\n\tt.is(all, '1\\n2\\n3');\n});\n\ntest.serial('result.all shows both `stdout` and `stderr` not intermixed, sync', t => {\n\tconst {all} = execaSync('noop-132.js', {all: true});\n\tt.is(all, '1\\n3\\n2');\n});\n\nconst testAllIgnored = async (t, options, execaMethod) => {\n\tconst {all} = await execaMethod('noop.js');\n\tt.is(all, undefined);\n};\n\ntest('result.all is undefined unless opts.all is true', testAllIgnored, {}, execa);\ntest('result.all is undefined if opts.all is false', testAllIgnored, {all: false}, execa);\ntest('result.all is undefined if ignored', testAllIgnored, {stdio: 'ignore', all: true}, execa);\ntest('result.all is undefined unless opts.all is true, sync', testAllIgnored, {}, execaSync);\ntest('result.all is undefined if opts.all is false, sync', testAllIgnored, {all: false}, execaSync);\ntest('result.all is undefined if ignored, sync', testAllIgnored, {stdio: 'ignore', all: true}, execaSync);\n\nconst testAllProperties = async (t, options) => {\n\tconst subprocess = execa('empty.js', {...options, all: true});\n\tt.is(subprocess.all.readableObjectMode, false);\n\tt.is(subprocess.all.readableHighWaterMark, defaultHighWaterMark);\n\tawait subprocess;\n};\n\ntest('subprocess.all has the right objectMode and highWaterMark - stdout + stderr', testAllProperties, {});\ntest('subprocess.all has the right objectMode and highWaterMark - stdout only', testAllProperties, {stderr: 'ignore'});\ntest('subprocess.all has the right objectMode and highWaterMark - stderr only', testAllProperties, {stdout: 'ignore'});\n\nconst testAllIgnore = async (t, streamName, otherStreamName) => {\n\tconst subprocess = execa('noop-both.js', {[otherStreamName]: 'ignore', all: true});\n\tt.is(subprocess[otherStreamName], null);\n\tt.not(subprocess[streamName], null);\n\tt.not(subprocess.all, null);\n\tt.is(subprocess.all.readableObjectMode, subprocess[streamName].readableObjectMode);\n\tt.is(subprocess.all.readableHighWaterMark, subprocess[streamName].readableHighWaterMark);\n\n\tconst result = await subprocess;\n\tt.is(result[otherStreamName], undefined);\n\tt.is(result[streamName], foobarString);\n\tt.is(result.all, foobarString);\n};\n\ntest('can use all: true with stdout: ignore', testAllIgnore, 'stderr', 'stdout');\ntest('can use all: true with stderr: ignore', testAllIgnore, 'stdout', 'stderr');\n\nconst testAllIgnoreSync = (t, streamName, otherStreamName) => {\n\tconst result = execaSync('noop-both.js', {[otherStreamName]: 'ignore', all: true});\n\tt.is(result[otherStreamName], undefined);\n\tt.is(result[streamName], foobarString);\n\tt.is(result.all, foobarString);\n};\n\ntest('can use all: true with stdout: ignore, sync', testAllIgnoreSync, 'stderr', 'stdout');\ntest('can use all: true with stderr: ignore, sync', testAllIgnoreSync, 'stdout', 'stderr');\n\ntest('can use all: true with stdout: ignore + stderr: ignore', async t => {\n\tconst subprocess = execa('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});\n\tt.is(subprocess.stdout, null);\n\tt.is(subprocess.stderr, null);\n\tt.is(subprocess.all, undefined);\n\n\tconst {stdout, stderr, all} = await subprocess;\n\tt.is(stdout, undefined);\n\tt.is(stderr, undefined);\n\tt.is(all, undefined);\n});\n\ntest('can use all: true with stdout: ignore + stderr: ignore, sync', t => {\n\tconst {stdout, stderr, all} = execaSync('noop-both.js', {stdout: 'ignore', stderr: 'ignore', all: true});\n\tt.is(stdout, undefined);\n\tt.is(stderr, undefined);\n\tt.is(all, undefined);\n});\n"
  },
  {
    "path": "test/resolve/buffer-end.js",
    "content": "import {once} from 'node:events';\nimport {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio, getStdio} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst testBufferIgnore = async (t, fdNumber, all) => {\n\tawait t.notThrowsAsync(execa('max-buffer.js', [`${fdNumber}`], {...getStdio(fdNumber, 'ignore'), buffer: false, all}));\n};\n\ntest('Subprocess buffers stdout, which does not prevent exit if ignored', testBufferIgnore, 1, false);\ntest('Subprocess buffers stderr, which does not prevent exit if ignored', testBufferIgnore, 2, false);\ntest('Subprocess buffers all, which does not prevent exit if ignored', testBufferIgnore, 1, true);\n\nconst testBufferNotRead = async (t, fdNumber, all) => {\n\tconst subprocess = execa('max-buffer.js', [`${fdNumber}`], {...fullStdio, buffer: false, all});\n\tawait t.notThrowsAsync(subprocess);\n};\n\ntest('Subprocess buffers stdout, which does not prevent exit if not read and buffer is false', testBufferNotRead, 1, false);\ntest('Subprocess buffers stderr, which does not prevent exit if not read and buffer is false', testBufferNotRead, 2, false);\ntest('Subprocess buffers stdio[*], which does not prevent exit if not read and buffer is false', testBufferNotRead, 3, false);\ntest('Subprocess buffers all, which does not prevent exit if not read and buffer is false', testBufferNotRead, 1, true);\n\nconst testBufferRead = async (t, fdNumber, all) => {\n\tconst subprocess = execa('max-buffer.js', [`${fdNumber}`], {...fullStdio, buffer: false, all});\n\tconst stream = all ? subprocess.all : subprocess.stdio[fdNumber];\n\tstream.resume();\n\tawait t.notThrowsAsync(subprocess);\n};\n\ntest('Subprocess buffers stdout, which does not prevent exit if read and buffer is false', testBufferRead, 1, false);\ntest('Subprocess buffers stderr, which does not prevent exit if read and buffer is false', testBufferRead, 2, false);\ntest('Subprocess buffers stdio[*], which does not prevent exit if read and buffer is false', testBufferRead, 3, false);\ntest('Subprocess buffers all, which does not prevent exit if read and buffer is false', testBufferRead, 1, true);\n\nconst testBufferExit = async (t, fdNumber, fixtureName, reject) => {\n\tconst subprocess = execa(fixtureName, [`${fdNumber}`], {...fullStdio, reject});\n\tawait setTimeout(100);\n\tconst {stdio} = await subprocess;\n\tt.is(stdio[fdNumber], 'foobar');\n};\n\ntest('Subprocess buffers stdout before it is read', testBufferExit, 1, 'noop-delay.js', true);\ntest('Subprocess buffers stderr before it is read', testBufferExit, 2, 'noop-delay.js', true);\ntest('Subprocess buffers stdio[*] before it is read', testBufferExit, 3, 'noop-delay.js', true);\ntest('Subprocess buffers stdout right away, on successfully exit', testBufferExit, 1, 'noop-fd.js', true);\ntest('Subprocess buffers stderr right away, on successfully exit', testBufferExit, 2, 'noop-fd.js', true);\ntest('Subprocess buffers stdio[*] right away, on successfully exit', testBufferExit, 3, 'noop-fd.js', true);\ntest('Subprocess buffers stdout right away, on failure', testBufferExit, 1, 'noop-fail.js', false);\ntest('Subprocess buffers stderr right away, on failure', testBufferExit, 2, 'noop-fail.js', false);\ntest('Subprocess buffers stdio[*] right away, on failure', testBufferExit, 3, 'noop-fail.js', false);\n\nconst testBufferDirect = async (t, fdNumber) => {\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`], fullStdio);\n\tconst data = await once(subprocess.stdio[fdNumber], 'data');\n\tt.is(data.toString().trim(), 'foobar');\n\tconst result = await subprocess;\n\tt.is(result.stdio[fdNumber], 'foobar');\n};\n\ntest('Subprocess buffers stdout right away, even if directly read', testBufferDirect, 1);\ntest('Subprocess buffers stderr right away, even if directly read', testBufferDirect, 2);\ntest('Subprocess buffers stdio[*] right away, even if directly read', testBufferDirect, 3);\n\nconst testBufferDestroyOnEnd = async (t, fdNumber) => {\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`], fullStdio);\n\tconst result = await subprocess;\n\tt.is(result.stdio[fdNumber], 'foobar');\n\tt.true(subprocess.stdio[fdNumber].destroyed);\n};\n\ntest('subprocess.stdout must be read right away', testBufferDestroyOnEnd, 1);\ntest('subprocess.stderr must be read right away', testBufferDestroyOnEnd, 2);\ntest('subprocess.stdio[*] must be read right away', testBufferDestroyOnEnd, 3);\n"
  },
  {
    "path": "test/resolve/exit.js",
    "content": "import process from 'node:process';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nconst isWindows = process.platform === 'win32';\n\nsetFixtureDirectory();\n\ntest('exitCode is 0 on success', async t => {\n\tconst {exitCode} = await execa('noop.js', ['foo']);\n\tt.is(exitCode, 0);\n});\n\nconst testExitCode = async (t, expectedExitCode) => {\n\tconst {exitCode, originalMessage, shortMessage, message} = await t.throwsAsync(\n\t\texeca('exit.js', [`${expectedExitCode}`]),\n\t);\n\tt.is(exitCode, expectedExitCode);\n\tt.is(originalMessage, undefined);\n\tt.is(shortMessage, `Command failed with exit code ${expectedExitCode}: exit.js ${expectedExitCode}`);\n\tt.is(message, shortMessage);\n};\n\ntest('exitCode is 2', testExitCode, 2);\ntest('exitCode is 3', testExitCode, 3);\ntest('exitCode is 4', testExitCode, 4);\n\nif (!isWindows) {\n\ttest('error.signal is SIGINT', async t => {\n\t\tconst subprocess = execa('forever.js');\n\n\t\tprocess.kill(subprocess.pid, 'SIGINT');\n\n\t\tconst {signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGINT/});\n\t\tt.is(signal, 'SIGINT');\n\t});\n\n\ttest('error.signalDescription is defined', async t => {\n\t\tconst subprocess = execa('forever.js');\n\n\t\tprocess.kill(subprocess.pid, 'SIGINT');\n\n\t\tconst {signalDescription} = await t.throwsAsync(subprocess, {message: /User interruption with CTRL-C/});\n\t\tt.is(signalDescription, 'User interruption with CTRL-C');\n\t});\n\n\ttest('error.signal is SIGTERM', async t => {\n\t\tconst subprocess = execa('forever.js');\n\n\t\tprocess.kill(subprocess.pid, 'SIGTERM');\n\n\t\tconst {signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGTERM/});\n\t\tt.is(signal, 'SIGTERM');\n\t});\n\n\ttest('error.signal uses killSignal', async t => {\n\t\tconst {signal} = await t.throwsAsync(execa('forever.js', {killSignal: 'SIGINT', timeout: 1, message: /timed out after/}));\n\t\tt.is(signal, 'SIGINT');\n\t});\n\n\ttest('exitCode is undefined on signal termination', async t => {\n\t\tconst subprocess = execa('forever.js');\n\n\t\tprocess.kill(subprocess.pid);\n\n\t\tconst {exitCode} = await t.throwsAsync(subprocess);\n\t\tt.is(exitCode, undefined);\n\t});\n}\n\ntest('result.signal is undefined for successful execution', async t => {\n\tconst {signal} = await execa('noop.js');\n\tt.is(signal, undefined);\n});\n\ntest('result.signal is undefined if subprocess failed, but was not killed', async t => {\n\tconst {signal} = await t.throwsAsync(execa('fail.js'));\n\tt.is(signal, undefined);\n});\n\ntest('result.signalDescription is undefined for successful execution', async t => {\n\tconst {signalDescription} = await execa('noop.js');\n\tt.is(signalDescription, undefined);\n});\n"
  },
  {
    "path": "test/resolve/no-buffer.js",
    "content": "import {once} from 'node:events';\nimport test from 'ava';\nimport getStream from 'get-stream';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {foobarString, foobarUppercase, foobarUppercaseUint8Array} from '../helpers/input.js';\nimport {resultGenerator, uppercaseGenerator, uppercaseBufferGenerator} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\nconst testLateStream = async (t, fdNumber, all) => {\n\tconst subprocess = execa('noop-fd-ipc.js', [`${fdNumber}`, foobarString], {\n\t\t...fullStdio,\n\t\tipc: true,\n\t\tbuffer: false,\n\t\tall,\n\t});\n\tawait subprocess.getOneMessage();\n\tconst [output, allOutput] = await Promise.all([\n\t\tgetStream(subprocess.stdio[fdNumber]),\n\t\tall ? getStream(subprocess.all) : undefined,\n\t\tsubprocess,\n\t]);\n\n\tt.is(output, '');\n\n\tif (all) {\n\t\tt.is(allOutput, '');\n\t}\n};\n\ntest('Lacks some data when stdout is read too late `buffer` set to `false`', testLateStream, 1, false);\ntest('Lacks some data when stderr is read too late `buffer` set to `false`', testLateStream, 2, false);\ntest('Lacks some data when stdio[*] is read too late `buffer` set to `false`', testLateStream, 3, false);\ntest('Lacks some data when all is read too late `buffer` set to `false`', testLateStream, 1, true);\n\nconst getFirstDataEvent = async stream => {\n\tconst [output] = await once(stream, 'data');\n\treturn output.toString();\n};\n\n// eslint-disable-next-line max-params\nconst testIterationBuffer = async (t, fdNumber, buffer, useDataEvents, all) => {\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], {...fullStdio, buffer, all});\n\tconst getOutput = useDataEvents ? getFirstDataEvent : getStream;\n\tconst [result, output, allOutput] = await Promise.all([\n\t\tsubprocess,\n\t\tgetOutput(subprocess.stdio[fdNumber]),\n\t\tall ? getOutput(subprocess.all) : undefined,\n\t]);\n\n\tconst expectedResult = buffer ? foobarString : undefined;\n\n\tt.is(result.stdio[fdNumber], expectedResult);\n\tt.is(output, foobarString);\n\n\tif (all) {\n\t\tt.is(result.all, expectedResult);\n\t\tt.is(allOutput, foobarString);\n\t}\n};\n\ntest('Can iterate stdout when `buffer` set to `false`', testIterationBuffer, 1, false, false, false);\ntest('Can iterate stderr when `buffer` set to `false`', testIterationBuffer, 2, false, false, false);\ntest('Can iterate stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, false, false);\ntest('Can iterate all when `buffer` set to `false`', testIterationBuffer, 1, false, false, true);\ntest('Can iterate stdout when `buffer` set to `true`', testIterationBuffer, 1, true, false, false);\ntest('Can iterate stderr when `buffer` set to `true`', testIterationBuffer, 2, true, false, false);\ntest('Can iterate stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, false, false);\ntest('Can iterate all when `buffer` set to `true`', testIterationBuffer, 1, true, false, true);\ntest('Can listen to `data` events on stdout when `buffer` set to `false`', testIterationBuffer, 1, false, true, false);\ntest('Can listen to `data` events on stderr when `buffer` set to `false`', testIterationBuffer, 2, false, true, false);\ntest('Can listen to `data` events on stdio[*] when `buffer` set to `false`', testIterationBuffer, 3, false, true, false);\ntest('Can listen to `data` events on all when `buffer` set to `false`', testIterationBuffer, 1, false, true, true);\ntest('Can listen to `data` events on stdout when `buffer` set to `true`', testIterationBuffer, 1, true, true, false);\ntest('Can listen to `data` events on stderr when `buffer` set to `true`', testIterationBuffer, 2, true, true, false);\ntest('Can listen to `data` events on stdio[*] when `buffer` set to `true`', testIterationBuffer, 3, true, true, false);\ntest('Can listen to `data` events on all when `buffer` set to `true`', testIterationBuffer, 1, true, true, true);\n\nconst testNoBufferStreamError = async (t, fdNumber, all) => {\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`], {...fullStdio, buffer: false, all});\n\tconst stream = all ? subprocess.all : subprocess.stdio[fdNumber];\n\tconst cause = new Error('test');\n\tstream.destroy(cause);\n\tt.like(await t.throwsAsync(subprocess), {cause});\n};\n\ntest('Listen to stdout errors even when `buffer` is `false`', testNoBufferStreamError, 1, false);\ntest('Listen to stderr errors even when `buffer` is `false`', testNoBufferStreamError, 2, false);\ntest('Listen to stdio[*] errors even when `buffer` is `false`', testNoBufferStreamError, 3, false);\ntest('Listen to all errors even when `buffer` is `false`', testNoBufferStreamError, 1, true);\n\nconst testOutput = async (t, buffer, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {buffer});\n\tt.is(stdout, foobarString);\n};\n\ntest('buffer: true returns output', testOutput, true, execa);\ntest('buffer: true returns output, fd-specific', testOutput, {stderr: false}, execa);\ntest('buffer: default returns output', testOutput, undefined, execa);\ntest('buffer: default returns output, fd-specific', testOutput, {}, execa);\n\nconst testNoOutput = async (t, stdioOption, buffer, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {stdout: stdioOption, buffer});\n\tt.is(stdout, undefined);\n};\n\ntest('buffer: false does not return output', testNoOutput, 'pipe', false, execa);\ntest('buffer: false does not return output, fd-specific', testNoOutput, 'pipe', {stdout: false}, execa);\ntest('buffer: false does not return output, stdout undefined', testNoOutput, undefined, false, execa);\ntest('buffer: false does not return output, stdout null', testNoOutput, null, false, execa);\ntest('buffer: false does not return output, stdout [\"pipe\"]', testNoOutput, ['pipe'], false, execa);\ntest('buffer: false does not return output, stdout [undefined]', testNoOutput, [undefined], false, execa);\ntest('buffer: false does not return output, stdout [null]', testNoOutput, [null], false, execa);\ntest('buffer: false does not return output, stdout [\"pipe\", undefined]', testNoOutput, ['pipe', undefined], false, execa);\ntest('buffer: false does not return output, sync', testNoOutput, 'pipe', false, execaSync);\ntest('buffer: false does not return output, fd-specific, sync', testNoOutput, 'pipe', {stdout: false}, execaSync);\ntest('buffer: false does not return output, stdout undefined, sync', testNoOutput, undefined, false, execaSync);\ntest('buffer: false does not return output, stdout null, sync', testNoOutput, null, false, execaSync);\ntest('buffer: false does not return output, stdout [\"pipe\"], sync', testNoOutput, ['pipe'], false, execaSync);\ntest('buffer: false does not return output, stdout [undefined], sync', testNoOutput, [undefined], false, execaSync);\ntest('buffer: false does not return output, stdout [null], sync', testNoOutput, [null], false, execaSync);\ntest('buffer: false does not return output, stdout [\"pipe\", undefined], sync', testNoOutput, ['pipe', undefined], false, execaSync);\n\nconst testNoOutputFail = async (t, execaMethod) => {\n\tconst {exitCode, stdout} = await execaMethod('fail.js', {buffer: false, reject: false});\n\tt.is(exitCode, 2);\n\tt.is(stdout, undefined);\n};\n\ntest('buffer: false does not return output, failure', testNoOutputFail, execa);\ntest('buffer: false does not return output, failure, sync', testNoOutputFail, execaSync);\n\n// eslint-disable-next-line max-params\nconst testNoOutputAll = async (t, buffer, bufferStdout, bufferStderr, execaMethod) => {\n\tconst {stdout, stderr, all} = await execaMethod('noop-both.js', {all: true, buffer, stripFinalNewline: false});\n\tt.is(stdout, bufferStdout ? `${foobarString}\\n` : undefined);\n\tt.is(stderr, bufferStderr ? `${foobarString}\\n` : undefined);\n\tconst stdoutStderr = [stdout, stderr].filter(Boolean);\n\tt.is(all, stdoutStderr.length === 0 ? undefined : stdoutStderr.join(''));\n};\n\ntest('buffer: {}, all: true', testNoOutputAll, {}, true, true, execa);\ntest('buffer: {stdout: false}, all: true', testNoOutputAll, {stdout: false}, false, true, execa);\ntest('buffer: {stderr: false}, all: true', testNoOutputAll, {stderr: false}, true, false, execa);\ntest('buffer: {all: false}, all: true', testNoOutputAll, {all: false}, false, false, execa);\ntest('buffer: {}, all: true, sync', testNoOutputAll, {}, true, true, execaSync);\ntest('buffer: {stdout: false}, all: true, sync', testNoOutputAll, {stdout: false}, false, true, execaSync);\ntest('buffer: {stderr: false}, all: true, sync', testNoOutputAll, {stderr: false}, true, false, execaSync);\ntest('buffer: {all: false}, all: true, sync', testNoOutputAll, {all: false}, false, false, execaSync);\n\nconst testTransform = async (t, objectMode, execaMethod) => {\n\tconst lines = [];\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tbuffer: false,\n\t\tstdout: [uppercaseGenerator(objectMode), resultGenerator(lines)(objectMode)],\n\t});\n\tt.is(stdout, undefined);\n\tt.deepEqual(lines, [foobarUppercase]);\n};\n\ntest('buffer: false still runs transforms', testTransform, false, execa);\ntest('buffer: false still runs transforms, objectMode', testTransform, true, execa);\ntest('buffer: false still runs transforms, sync', testTransform, false, execaSync);\ntest('buffer: false still runs transforms, objectMode, sync', testTransform, true, execaSync);\n\nconst testTransformBinary = async (t, objectMode, execaMethod) => {\n\tconst lines = [];\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {\n\t\tbuffer: false,\n\t\tstdout: [uppercaseBufferGenerator(objectMode, true), resultGenerator(lines)(objectMode)],\n\t\tencoding: 'buffer',\n\t});\n\tt.is(stdout, undefined);\n\tt.deepEqual(lines, [foobarUppercaseUint8Array]);\n};\n\ntest('buffer: false still runs transforms, encoding \"buffer\"', testTransformBinary, false, execa);\ntest('buffer: false still runs transforms, encoding \"buffer\", objectMode', testTransformBinary, true, execa);\ntest('buffer: false still runs transforms, encoding \"buffer\", sync', testTransformBinary, false, execaSync);\ntest('buffer: false still runs transforms, encoding \"buffer\", objectMode, sync', testTransformBinary, true, execaSync);\n\nconst testStreamEnd = async (t, fdNumber, buffer) => {\n\tconst subprocess = execa('wrong command', {...fullStdio, buffer});\n\tawait Promise.all([\n\t\tt.throwsAsync(subprocess, {message: /wrong command/}),\n\t\tonce(subprocess.stdio[fdNumber], 'end'),\n\t]);\n};\n\ntest('buffer: false > emits end event on stdout when promise is rejected', testStreamEnd, 1, false);\ntest('buffer: false > emits end event on stderr when promise is rejected', testStreamEnd, 2, false);\ntest('buffer: false > emits end event on stdio[*] when promise is rejected', testStreamEnd, 3, false);\ntest('buffer: true > emits end event on stdout when promise is rejected', testStreamEnd, 1, true);\ntest('buffer: true > emits end event on stderr when promise is rejected', testStreamEnd, 2, true);\ntest('buffer: true > emits end event on stdio[*] when promise is rejected', testStreamEnd, 3, true);\n"
  },
  {
    "path": "test/resolve/stdio.js",
    "content": "import {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tfullStdio,\n\tgetStdio,\n\tprematureClose,\n\tassertEpipe,\n} from '../helpers/stdio.js';\nimport {infiniteGenerator} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\nconst getStreamInputSubprocess = fdNumber => execa('stdin-fd.js', [`${fdNumber}`], fdNumber === 3\n\t? getStdio(3, [new Uint8Array(), infiniteGenerator()])\n\t: {});\nconst getStreamOutputSubprocess = fdNumber => execa('noop-repeat.js', [`${fdNumber}`], fdNumber === 3 ? fullStdio : {});\n\nconst assertStreamInputError = (t, {exitCode, signal, isTerminated, failed}) => {\n\tt.is(exitCode, 0);\n\tt.is(signal, undefined);\n\tt.false(isTerminated);\n\tt.true(failed);\n};\n\nconst assertStreamOutputError = (t, fdNumber, {exitCode, signal, isTerminated, failed, stderr}) => {\n\tif (fdNumber !== 3) {\n\t\tt.is(exitCode, 1);\n\t}\n\n\tt.is(signal, undefined);\n\tt.false(isTerminated);\n\tt.true(failed);\n\n\tassertEpipe(t, stderr, fdNumber);\n};\n\nconst testStreamInputAbort = async (t, fdNumber) => {\n\tconst subprocess = getStreamInputSubprocess(fdNumber);\n\tsubprocess.stdio[fdNumber].destroy();\n\tconst error = await t.throwsAsync(subprocess, prematureClose);\n\tassertStreamInputError(t, error);\n};\n\ntest('Aborting stdin should not make the subprocess exit', testStreamInputAbort, 0);\ntest('Aborting input stdio[*] should not make the subprocess exit', testStreamInputAbort, 3);\n\nconst testStreamOutputAbort = async (t, fdNumber) => {\n\tconst subprocess = getStreamOutputSubprocess(fdNumber);\n\tsubprocess.stdio[fdNumber].destroy();\n\tconst error = await t.throwsAsync(subprocess);\n\tassertStreamOutputError(t, fdNumber, error);\n};\n\ntest('Aborting stdout should not make the subprocess exit', testStreamOutputAbort, 1);\ntest('Aborting stderr should not make the subprocess exit', testStreamOutputAbort, 2);\ntest('Aborting output stdio[*] should not make the subprocess exit', testStreamOutputAbort, 3);\n\nconst testStreamInputDestroy = async (t, fdNumber) => {\n\tconst subprocess = getStreamInputSubprocess(fdNumber);\n\tconst cause = new Error('test');\n\tsubprocess.stdio[fdNumber].destroy(cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tassertStreamInputError(t, error);\n};\n\ntest('Destroying stdin should not make the subprocess exit', testStreamInputDestroy, 0);\ntest('Destroying input stdio[*] should not make the subprocess exit', testStreamInputDestroy, 3);\n\nconst testStreamOutputDestroy = async (t, fdNumber) => {\n\tconst subprocess = getStreamOutputSubprocess(fdNumber);\n\tconst cause = new Error('test');\n\tsubprocess.stdio[fdNumber].destroy(cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tassertStreamOutputError(t, fdNumber, error);\n};\n\ntest('Destroying stdout should not make the subprocess exit', testStreamOutputDestroy, 1);\ntest('Destroying stderr should not make the subprocess exit', testStreamOutputDestroy, 2);\ntest('Destroying output stdio[*] should not make the subprocess exit', testStreamOutputDestroy, 3);\n\nconst testStreamInputError = async (t, fdNumber) => {\n\tconst subprocess = getStreamInputSubprocess(fdNumber);\n\tconst cause = new Error('test');\n\tconst stream = subprocess.stdio[fdNumber];\n\tstream.emit('error', cause);\n\tstream.end();\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tassertStreamInputError(t, error);\n};\n\ntest('Errors on stdin should not make the subprocess exit', testStreamInputError, 0);\ntest('Errors on input stdio[*] should not make the subprocess exit', testStreamInputError, 3);\n\nconst testStreamOutputError = async (t, fdNumber) => {\n\tconst subprocess = getStreamOutputSubprocess(fdNumber);\n\tconst cause = new Error('test');\n\tconst stream = subprocess.stdio[fdNumber];\n\tstream.emit('error', cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tassertStreamOutputError(t, fdNumber, error);\n};\n\ntest('Errors on stdout should make the subprocess exit', testStreamOutputError, 1);\ntest('Errors on stderr should make the subprocess exit', testStreamOutputError, 2);\ntest('Errors on output stdio[*] should make the subprocess exit', testStreamOutputError, 3);\n\nconst testWaitOnStreamEnd = async (t, fdNumber) => {\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], fullStdio);\n\tawait setTimeout(100);\n\tsubprocess.stdio[fdNumber].end('foobar');\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, 'foobar');\n};\n\ntest('Subprocess waits on stdin before exiting', testWaitOnStreamEnd, 0);\ntest('Subprocess waits on stdio[*] before exiting', testWaitOnStreamEnd, 3);\n"
  },
  {
    "path": "test/resolve/wait-abort.js",
    "content": "import {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {prematureClose} from '../helpers/stdio.js';\nimport {noopReadable, noopWritable, noopDuplex} from '../helpers/stream.js';\nimport {\n\tendOptionStream,\n\tdestroyOptionStream,\n\tdestroySubprocessStream,\n\tgetStreamStdio,\n} from '../helpers/wait.js';\n\nsetFixtureDirectory();\n\nconst noop = () => {};\n\n// eslint-disable-next-line max-params\nconst testStreamAbortWait = async (t, streamMethod, stream, fdNumber, useTransform) => {\n\tconst subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStreamStdio(fdNumber, stream, useTransform));\n\tstreamMethod({stream, subprocess, fdNumber});\n\tsubprocess.stdin.end();\n\tawait setImmediate();\n\tstream.destroy();\n\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, '');\n\tt.true(stream.destroyed);\n};\n\ntest('Keeps running when stdin option is used and subprocess.stdin ends', testStreamAbortWait, noop, noopReadable(), 0, false);\ntest('Keeps running when stdin option is used and subprocess.stdin Duplex ends', testStreamAbortWait, noop, noopDuplex(), 0, false);\ntest('Keeps running when input stdio[*] option is used and input subprocess.stdio[*] ends', testStreamAbortWait, noop, noopReadable(), 3, false);\ntest('Keeps running when stdin option is used and subprocess.stdin ends, with a transform', testStreamAbortWait, noop, noopReadable(), 0, true);\ntest('Keeps running when stdin option is used and subprocess.stdin Duplex ends, with a transform', testStreamAbortWait, noop, noopDuplex(), 0, true);\ntest('Keeps running when input stdio[*] option is used and input subprocess.stdio[*] ends, with a transform', testStreamAbortWait, noop, noopReadable(), 3, true);\n\n// eslint-disable-next-line max-params\nconst testStreamAbortSuccess = async (t, streamMethod, stream, fdNumber, useTransform) => {\n\tconst subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStreamStdio(fdNumber, stream, useTransform));\n\tstreamMethod({stream, subprocess, fdNumber});\n\tsubprocess.stdin.end();\n\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, '');\n\tt.true(stream.destroyed);\n};\n\ntest('Passes when stdin option aborts', testStreamAbortSuccess, destroyOptionStream, noopReadable(), 0, false);\ntest('Passes when stdin option Duplex aborts', testStreamAbortSuccess, destroyOptionStream, noopDuplex(), 0, false);\ntest('Passes when input stdio[*] option aborts', testStreamAbortSuccess, destroyOptionStream, noopReadable(), 3, false);\ntest('Passes when stdout option ends with no more writes', testStreamAbortSuccess, endOptionStream, noopWritable(), 1, false);\ntest('Passes when stderr option ends with no more writes', testStreamAbortSuccess, endOptionStream, noopWritable(), 2, false);\ntest('Passes when output stdio[*] option ends with no more writes', testStreamAbortSuccess, endOptionStream, noopWritable(), 3, false);\ntest('Passes when subprocess.stdout aborts with no more writes', testStreamAbortSuccess, destroySubprocessStream, noopWritable(), 1, false);\ntest('Passes when subprocess.stdout Duplex aborts with no more writes', testStreamAbortSuccess, destroySubprocessStream, noopDuplex(), 1, false);\ntest('Passes when subprocess.stderr aborts with no more writes', testStreamAbortSuccess, destroySubprocessStream, noopWritable(), 2, false);\ntest('Passes when subprocess.stderr Duplex aborts with no more writes', testStreamAbortSuccess, destroySubprocessStream, noopDuplex(), 2, false);\ntest('Passes when output subprocess.stdio[*] aborts with no more writes', testStreamAbortSuccess, destroySubprocessStream, noopWritable(), 3, false);\ntest('Passes when output subprocess.stdio[*] Duplex aborts with no more writes', testStreamAbortSuccess, destroySubprocessStream, noopDuplex(), 3, false);\ntest('Passes when stdin option aborts, with a transform', testStreamAbortSuccess, destroyOptionStream, noopReadable(), 0, true);\ntest('Passes when stdin option Duplex aborts, with a transform', testStreamAbortSuccess, destroyOptionStream, noopDuplex(), 0, true);\ntest('Passes when input stdio[*] option aborts, with a transform', testStreamAbortSuccess, destroyOptionStream, noopReadable(), 3, true);\ntest('Passes when stdout option ends with no more writes, with a transform', testStreamAbortSuccess, endOptionStream, noopWritable(), 1, true);\ntest('Passes when stderr option ends with no more writes, with a transform', testStreamAbortSuccess, endOptionStream, noopWritable(), 2, true);\ntest('Passes when output stdio[*] option ends with no more writes, with a transform', testStreamAbortSuccess, endOptionStream, noopWritable(), 3, true);\ntest('Passes when subprocess.stdout aborts with no more writes, with a transform', testStreamAbortSuccess, destroySubprocessStream, noopWritable(), 1, true);\ntest('Passes when subprocess.stdout Duplex aborts with no more writes, with a transform', testStreamAbortSuccess, destroySubprocessStream, noopDuplex(), 1, true);\ntest('Passes when subprocess.stderr aborts with no more writes, with a transform', testStreamAbortSuccess, destroySubprocessStream, noopWritable(), 2, true);\ntest('Passes when subprocess.stderr Duplex aborts with no more writes, with a transform', testStreamAbortSuccess, destroySubprocessStream, noopDuplex(), 2, true);\ntest('Passes when output subprocess.stdio[*] aborts with no more writes, with a transform', testStreamAbortSuccess, destroySubprocessStream, noopWritable(), 3, true);\ntest('Passes when output subprocess.stdio[*] Duplex aborts with no more writes, with a transform', testStreamAbortSuccess, destroySubprocessStream, noopDuplex(), 3, true);\n\n// eslint-disable-next-line max-params\nconst testStreamAbortFail = async (t, streamMethod, stream, fdNumber, useTransform) => {\n\tconst subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStreamStdio(fdNumber, stream, useTransform));\n\tstreamMethod({stream, subprocess, fdNumber});\n\tif (fdNumber !== 0) {\n\t\tsubprocess.stdin.end();\n\t}\n\n\tconst error = await t.throwsAsync(subprocess);\n\tt.like(error, {...prematureClose, exitCode: 0});\n\tt.true(stream.destroyed);\n};\n\ntest('Throws abort error when subprocess.stdin aborts', testStreamAbortFail, destroySubprocessStream, noopReadable(), 0, false);\ntest('Throws abort error when subprocess.stdin Duplex aborts', testStreamAbortFail, destroySubprocessStream, noopDuplex(), 0, false);\ntest('Throws abort error when input subprocess.stdio[*] aborts', testStreamAbortFail, destroySubprocessStream, noopReadable(), 3, false);\ntest('Throws abort error when stdout option aborts with no more writes', testStreamAbortFail, destroyOptionStream, noopWritable(), 1, false);\ntest('Throws abort error when stdout option Duplex aborts with no more writes', testStreamAbortFail, destroyOptionStream, noopDuplex(), 1, false);\ntest('Throws abort error when stderr option aborts with no more writes', testStreamAbortFail, destroyOptionStream, noopWritable(), 2, false);\ntest('Throws abort error when stderr option Duplex aborts with no more writes', testStreamAbortFail, destroyOptionStream, noopDuplex(), 2, false);\ntest('Throws abort error when output stdio[*] option aborts with no more writes', testStreamAbortFail, destroyOptionStream, noopWritable(), 3, false);\ntest('Throws abort error when output stdio[*] Duplex option aborts with no more writes', testStreamAbortFail, destroyOptionStream, noopDuplex(), 3, false);\ntest('Throws abort error when subprocess.stdin aborts, with a transform', testStreamAbortFail, destroySubprocessStream, noopReadable(), 0, true);\ntest('Throws abort error when subprocess.stdin Duplex aborts, with a transform', testStreamAbortFail, destroySubprocessStream, noopDuplex(), 0, true);\ntest('Throws abort error when input subprocess.stdio[*] aborts, with a transform', testStreamAbortFail, destroySubprocessStream, noopReadable(), 3, true);\ntest('Throws abort error when stdout option aborts with no more writes, with a transform', testStreamAbortFail, destroyOptionStream, noopWritable(), 1, true);\ntest('Throws abort error when stdout option Duplex aborts with no more writes, with a transform', testStreamAbortFail, destroyOptionStream, noopDuplex(), 1, true);\ntest('Throws abort error when stderr option aborts with no more writes, with a transform', testStreamAbortFail, destroyOptionStream, noopWritable(), 2, true);\ntest('Throws abort error when stderr option Duplex aborts with no more writes, with a transform', testStreamAbortFail, destroyOptionStream, noopDuplex(), 2, true);\ntest('Throws abort error when output stdio[*] option aborts with no more writes, with a transform', testStreamAbortFail, destroyOptionStream, noopWritable(), 3, true);\ntest('Throws abort error when output stdio[*] Duplex option aborts with no more writes, with a transform', testStreamAbortFail, destroyOptionStream, noopDuplex(), 3, true);\n"
  },
  {
    "path": "test/resolve/wait-epipe.js",
    "content": "import {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {assertEpipe} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\nimport {noopWritable, noopDuplex} from '../helpers/stream.js';\nimport {\n\tendOptionStream,\n\tdestroyOptionStream,\n\tdestroySubprocessStream,\n\tgetStreamStdio,\n} from '../helpers/wait.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testStreamEpipeFail = async (t, streamMethod, stream, fdNumber, useTransform) => {\n\tconst subprocess = execa('noop-stdin-fd.js', [`${fdNumber}`], getStreamStdio(fdNumber, stream, useTransform));\n\tstreamMethod({stream, subprocess, fdNumber});\n\tawait setImmediate();\n\tsubprocess.stdin.end(foobarString);\n\n\tconst {exitCode, stdio, stderr} = await t.throwsAsync(subprocess);\n\tt.is(exitCode, 1);\n\tt.is(stdio[fdNumber], '');\n\tt.true(stream.destroyed);\n\tassertEpipe(t, stderr, fdNumber);\n};\n\ntest('Throws EPIPE when stdout option ends with more writes', testStreamEpipeFail, endOptionStream, noopWritable(), 1, false);\ntest('Throws EPIPE when stdout option aborts with more writes', testStreamEpipeFail, destroyOptionStream, noopWritable(), 1, false);\ntest('Throws EPIPE when stdout option Duplex aborts with more writes', testStreamEpipeFail, destroyOptionStream, noopDuplex(), 1, false);\ntest('Throws EPIPE when stderr option ends with more writes', testStreamEpipeFail, endOptionStream, noopWritable(), 2, false);\ntest('Throws EPIPE when stderr option aborts with more writes', testStreamEpipeFail, destroyOptionStream, noopWritable(), 2, false);\ntest('Throws EPIPE when stderr option Duplex aborts with more writes', testStreamEpipeFail, destroyOptionStream, noopDuplex(), 2, false);\ntest('Throws EPIPE when output stdio[*] option ends with more writes', testStreamEpipeFail, endOptionStream, noopWritable(), 3, false);\ntest('Throws EPIPE when output stdio[*] option aborts with more writes', testStreamEpipeFail, destroyOptionStream, noopWritable(), 3, false);\ntest('Throws EPIPE when output stdio[*] option Duplex aborts with more writes', testStreamEpipeFail, destroyOptionStream, noopDuplex(), 3, false);\ntest('Throws EPIPE when subprocess.stdout aborts with more writes', testStreamEpipeFail, destroySubprocessStream, noopWritable(), 1, false);\ntest('Throws EPIPE when subprocess.stdout Duplex aborts with more writes', testStreamEpipeFail, destroySubprocessStream, noopDuplex(), 1, false);\ntest('Throws EPIPE when subprocess.stderr aborts with more writes', testStreamEpipeFail, destroySubprocessStream, noopWritable(), 2, false);\ntest('Throws EPIPE when subprocess.stderr Duplex aborts with more writes', testStreamEpipeFail, destroySubprocessStream, noopDuplex(), 2, false);\ntest('Throws EPIPE when output subprocess.stdio[*] aborts with more writes', testStreamEpipeFail, destroySubprocessStream, noopWritable(), 3, false);\ntest('Throws EPIPE when output subprocess.stdio[*] Duplex aborts with more writes', testStreamEpipeFail, destroySubprocessStream, noopDuplex(), 3, false);\ntest('Throws EPIPE when stdout option ends with more writes, with a transform', testStreamEpipeFail, endOptionStream, noopWritable(), 1, true);\ntest('Throws EPIPE when stdout option aborts with more writes, with a transform', testStreamEpipeFail, destroyOptionStream, noopWritable(), 1, true);\ntest('Throws EPIPE when stdout option Duplex aborts with more writes, with a transform', testStreamEpipeFail, destroyOptionStream, noopDuplex(), 1, true);\ntest('Throws EPIPE when stderr option ends with more writes, with a transform', testStreamEpipeFail, endOptionStream, noopWritable(), 2, true);\ntest('Throws EPIPE when stderr option aborts with more writes, with a transform', testStreamEpipeFail, destroyOptionStream, noopWritable(), 2, true);\ntest('Throws EPIPE when stderr option Duplex aborts with more writes, with a transform', testStreamEpipeFail, destroyOptionStream, noopDuplex(), 2, true);\ntest('Throws EPIPE when output stdio[*] option ends with more writes, with a transform', testStreamEpipeFail, endOptionStream, noopWritable(), 3, true);\ntest('Throws EPIPE when output stdio[*] option aborts with more writes, with a transform', testStreamEpipeFail, destroyOptionStream, noopWritable(), 3, true);\ntest('Throws EPIPE when output stdio[*] option Duplex aborts with more writes, with a transform', testStreamEpipeFail, destroyOptionStream, noopDuplex(), 3, true);\ntest('Throws EPIPE when subprocess.stdout aborts with more writes, with a transform', testStreamEpipeFail, destroySubprocessStream, noopWritable(), 1, true);\ntest('Throws EPIPE when subprocess.stdout Duplex aborts with more writes, with a transform', testStreamEpipeFail, destroySubprocessStream, noopDuplex(), 1, true);\ntest('Throws EPIPE when subprocess.stderr aborts with more writes, with a transform', testStreamEpipeFail, destroySubprocessStream, noopWritable(), 2, true);\ntest('Throws EPIPE when subprocess.stderr Duplex aborts with more writes, with a transform', testStreamEpipeFail, destroySubprocessStream, noopDuplex(), 2, true);\ntest('Throws EPIPE when output subprocess.stdio[*] aborts with more writes, with a transform', testStreamEpipeFail, destroySubprocessStream, noopWritable(), 3, true);\ntest('Throws EPIPE when output subprocess.stdio[*] Duplex aborts with more writes, with a transform', testStreamEpipeFail, destroySubprocessStream, noopDuplex(), 3, true);\n"
  },
  {
    "path": "test/resolve/wait-error.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {noopReadable, noopWritable, noopDuplex} from '../helpers/stream.js';\nimport {destroyOptionStream, destroySubprocessStream, getStreamStdio} from '../helpers/wait.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testStreamError = async (t, streamMethod, stream, fdNumber, useTransform) => {\n\tconst subprocess = execa('empty.js', getStreamStdio(fdNumber, stream, useTransform));\n\tconst cause = new Error('test');\n\tstreamMethod({\n\t\tstream,\n\t\tsubprocess,\n\t\tfdNumber,\n\t\terror: cause,\n\t});\n\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.exitCode, 0);\n\tt.is(error.signal, undefined);\n\tt.false(error.isTerminated);\n\tt.true(error.failed);\n\tt.true(stream.destroyed);\n};\n\ntest('Throws stream error when stdin option errors', testStreamError, destroyOptionStream, noopReadable(), 0, false);\ntest('Throws stream error when stdin option Duplex errors', testStreamError, destroyOptionStream, noopDuplex(), 0, false);\ntest('Throws stream error when stdout option errors', testStreamError, destroyOptionStream, noopWritable(), 1, false);\ntest('Throws stream error when stdout option Duplex errors', testStreamError, destroyOptionStream, noopDuplex(), 1, false);\ntest('Throws stream error when stderr option errors', testStreamError, destroyOptionStream, noopWritable(), 2, false);\ntest('Throws stream error when stderr option Duplex errors', testStreamError, destroyOptionStream, noopDuplex(), 2, false);\ntest('Throws stream error when output stdio[*] option errors', testStreamError, destroyOptionStream, noopWritable(), 3, false);\ntest('Throws stream error when output stdio[*] Duplex option errors', testStreamError, destroyOptionStream, noopDuplex(), 3, false);\ntest('Throws stream error when input stdio[*] option errors', testStreamError, destroyOptionStream, noopReadable(), 3, false);\ntest('Throws stream error when subprocess.stdin errors', testStreamError, destroySubprocessStream, noopReadable(), 0, false);\ntest('Throws stream error when subprocess.stdin Duplex errors', testStreamError, destroySubprocessStream, noopDuplex(), 0, false);\ntest('Throws stream error when subprocess.stdout errors', testStreamError, destroySubprocessStream, noopWritable(), 1, false);\ntest('Throws stream error when subprocess.stdout Duplex errors', testStreamError, destroySubprocessStream, noopDuplex(), 1, false);\ntest('Throws stream error when subprocess.stderr errors', testStreamError, destroySubprocessStream, noopWritable(), 2, false);\ntest('Throws stream error when subprocess.stderr Duplex errors', testStreamError, destroySubprocessStream, noopDuplex(), 2, false);\ntest('Throws stream error when output subprocess.stdio[*] errors', testStreamError, destroySubprocessStream, noopWritable(), 3, false);\ntest('Throws stream error when output subprocess.stdio[*] Duplex errors', testStreamError, destroySubprocessStream, noopDuplex(), 3, false);\ntest('Throws stream error when input subprocess.stdio[*] errors', testStreamError, destroySubprocessStream, noopReadable(), 3, false);\ntest('Throws stream error when stdin option errors, with a transform', testStreamError, destroyOptionStream, noopReadable(), 0, true);\ntest('Throws stream error when stdin option Duplex errors, with a transform', testStreamError, destroyOptionStream, noopDuplex(), 0, true);\ntest('Throws stream error when stdout option errors, with a transform', testStreamError, destroyOptionStream, noopWritable(), 1, true);\ntest('Throws stream error when stdout option Duplex errors, with a transform', testStreamError, destroyOptionStream, noopDuplex(), 1, true);\ntest('Throws stream error when stderr option errors, with a transform', testStreamError, destroyOptionStream, noopWritable(), 2, true);\ntest('Throws stream error when stderr option Duplex errors, with a transform', testStreamError, destroyOptionStream, noopDuplex(), 2, true);\ntest('Throws stream error when output stdio[*] option errors, with a transform', testStreamError, destroyOptionStream, noopWritable(), 3, true);\ntest('Throws stream error when output stdio[*] Duplex option errors, with a transform', testStreamError, destroyOptionStream, noopDuplex(), 3, true);\ntest('Throws stream error when input stdio[*] option errors, with a transform', testStreamError, destroyOptionStream, noopReadable(), 3, true);\ntest('Throws stream error when subprocess.stdin errors, with a transform', testStreamError, destroySubprocessStream, noopReadable(), 0, true);\ntest('Throws stream error when subprocess.stdin Duplex errors, with a transform', testStreamError, destroySubprocessStream, noopDuplex(), 0, true);\ntest('Throws stream error when subprocess.stdout errors, with a transform', testStreamError, destroySubprocessStream, noopWritable(), 1, true);\ntest('Throws stream error when subprocess.stdout Duplex errors, with a transform', testStreamError, destroySubprocessStream, noopDuplex(), 1, true);\ntest('Throws stream error when subprocess.stderr errors, with a transform', testStreamError, destroySubprocessStream, noopWritable(), 2, true);\ntest('Throws stream error when subprocess.stderr Duplex errors, with a transform', testStreamError, destroySubprocessStream, noopDuplex(), 2, true);\ntest('Throws stream error when output subprocess.stdio[*] errors, with a transform', testStreamError, destroySubprocessStream, noopWritable(), 3, true);\ntest('Throws stream error when output subprocess.stdio[*] Duplex errors, with a transform', testStreamError, destroySubprocessStream, noopDuplex(), 3, true);\ntest('Throws stream error when input subprocess.stdio[*] errors, with a transform', testStreamError, destroySubprocessStream, noopReadable(), 3, true);\n"
  },
  {
    "path": "test/resolve/wait-subprocess.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst testIgnore = async (t, fdNumber, execaMethod) => {\n\tconst result = await execaMethod('noop.js', getStdio(fdNumber, 'ignore'));\n\tt.is(result.stdio[fdNumber], undefined);\n};\n\ntest('stdout is undefined if ignored', testIgnore, 1, execa);\ntest('stderr is undefined if ignored', testIgnore, 2, execa);\ntest('stdio[*] is undefined if ignored', testIgnore, 3, execa);\ntest('stdout is undefined if ignored - sync', testIgnore, 1, execaSync);\ntest('stderr is undefined if ignored - sync', testIgnore, 2, execaSync);\ntest('stdio[*] is undefined if ignored - sync', testIgnore, 3, execaSync);\n\nconst testSubprocessEventsCleanup = async (t, fixtureName) => {\n\tconst subprocess = execa(fixtureName, {reject: false});\n\tt.deepEqual(subprocess.eventNames().map(String).sort(), ['error', 'exit', 'spawn']);\n\tawait subprocess;\n\tt.deepEqual(subprocess.eventNames(), []);\n};\n\ntest('subprocess listeners are cleaned up on success', testSubprocessEventsCleanup, 'empty.js');\ntest('subprocess listeners are cleaned up on failure', testSubprocessEventsCleanup, 'fail.js');\n\ntest('Aborting stdout should not abort stderr nor all', async t => {\n\tconst subprocess = execa('empty.js', {all: true});\n\n\tsubprocess.stdout.destroy();\n\tt.false(subprocess.stdout.readable);\n\tt.true(subprocess.stderr.readable);\n\tt.true(subprocess.all.readable);\n\n\tawait subprocess;\n\n\tt.false(subprocess.stdout.readableEnded);\n\tt.is(subprocess.stdout.errored, null);\n\tt.true(subprocess.stdout.destroyed);\n\tt.true(subprocess.stderr.readableEnded);\n\tt.is(subprocess.stderr.errored, null);\n\tt.true(subprocess.stderr.destroyed);\n\tt.true(subprocess.all.readableEnded);\n\tt.is(subprocess.all.errored, null);\n\tt.true(subprocess.all.destroyed);\n});\n"
  },
  {
    "path": "test/return/duration.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getEarlyErrorSubprocess, getEarlyErrorSubprocessSync} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst assertDurationMs = (t, durationMs) => {\n\tt.is(typeof durationMs, 'number');\n\tt.true(Number.isFinite(durationMs));\n\tt.not(durationMs, 0);\n\tt.true(durationMs > 0);\n};\n\ntest('result.durationMs', async t => {\n\tconst {durationMs} = await execa('empty.js');\n\tassertDurationMs(t, durationMs);\n});\n\ntest('result.durationMs - sync', t => {\n\tconst {durationMs} = execaSync('empty.js');\n\tassertDurationMs(t, durationMs);\n});\n\ntest('error.durationMs', async t => {\n\tconst {durationMs} = await t.throwsAsync(execa('fail.js'));\n\tassertDurationMs(t, durationMs);\n});\n\ntest('error.durationMs - sync', t => {\n\tconst {durationMs} = t.throws(() => {\n\t\texecaSync('fail.js');\n\t});\n\tassertDurationMs(t, durationMs);\n});\n\ntest('error.durationMs - early validation', async t => {\n\tconst {durationMs} = await t.throwsAsync(getEarlyErrorSubprocess());\n\tassertDurationMs(t, durationMs);\n});\n\ntest('error.durationMs - early validation, sync', t => {\n\tconst {durationMs} = t.throws(getEarlyErrorSubprocessSync);\n\tassertDurationMs(t, durationMs);\n});\n\ntest('error.durationMs - unpipeSignal', async t => {\n\tconst {durationMs} = await t.throwsAsync(execa('noop.js').pipe('stdin.js', {signal: AbortSignal.abort()}));\n\tassertDurationMs(t, durationMs);\n});\n\ntest('error.durationMs - pipe validation', async t => {\n\tconst {durationMs} = await t.throwsAsync(execa('noop.js').pipe(false));\n\tassertDurationMs(t, durationMs);\n});\n\ntest.serial('result.durationMs is accurate', async t => {\n\tconst minDurationMs = 1e3;\n\tconst {durationMs} = await execa('delay.js', [minDurationMs]);\n\tt.true(durationMs >= minDurationMs);\n});\n"
  },
  {
    "path": "test/return/early-error.js",
    "content": "import {arch} from 'node:os';\nimport process from 'node:process';\nimport test from 'ava';\nimport {execa, execaSync, $} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {\n\tearlyErrorOptions,\n\tgetEarlyErrorSubprocess,\n\tgetEarlyErrorSubprocessSync,\n\texpectedEarlyError,\n\texpectedEarlyErrorSync,\n} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst isWindows = process.platform === 'win32';\nconst ENOENT_REGEXP = isWindows ? /failed with exit code 1/ : /spawn.* ENOENT/;\n\ntest('execaSync() throws error if ENOENT', t => {\n\tt.throws(() => {\n\t\texecaSync('foo');\n\t}, {message: ENOENT_REGEXP});\n});\n\nconst testEarlyErrorShape = async (t, reject) => {\n\tconst subprocess = getEarlyErrorSubprocess({reject});\n\tt.notThrows(() => {\n\t\t// eslint-disable-next-line promise/prefer-await-to-then\n\t\tsubprocess.catch(() => {});\n\t\tsubprocess.unref();\n\t\tsubprocess.on('error', () => {});\n\t});\n};\n\ntest('child_process.spawn() early errors have correct shape', testEarlyErrorShape, true);\ntest('child_process.spawn() early errors have correct shape - reject false', testEarlyErrorShape, false);\n\ntest('child_process.spawn() early errors are propagated', async t => {\n\tawait t.throwsAsync(getEarlyErrorSubprocess(), expectedEarlyError);\n});\n\ntest('child_process.spawn() early errors are returned', async t => {\n\tconst {failed} = await getEarlyErrorSubprocess({reject: false});\n\tt.true(failed);\n});\n\ntest('child_process.spawnSync() early errors are propagated with a correct shape', t => {\n\tt.throws(getEarlyErrorSubprocessSync, expectedEarlyErrorSync);\n});\n\ntest('child_process.spawnSync() early errors are propagated with a correct shape - reject false', t => {\n\tconst {failed} = getEarlyErrorSubprocessSync({reject: false});\n\tt.true(failed);\n});\n\nif (!isWindows) {\n\ttest('execa() rejects if running non-executable', async t => {\n\t\tawait t.throwsAsync(execa('non-executable.js'));\n\t});\n\n\ttest('execa() rejects with correct error and doesn\\'t throw if running non-executable with input', async t => {\n\t\tawait t.throwsAsync(execa('non-executable.js', {input: 'Hey!'}), {message: /EACCES/});\n\t});\n\n\tif (arch() === 'x64') {\n\t\ttest('write to fast-exit subprocess', async t => {\n\t\t// Try-catch here is necessary, because this test is not 100% accurate\n\t\t// Sometimes subprocess can manage to accept input before exiting\n\t\t\ttry {\n\t\t\t\tawait execa(`fast-exit-${process.platform}`, [], {input: 'data'});\n\t\t\t\tt.pass();\n\t\t\t} catch (error) {\n\t\t\t\tt.is(error.code, 'EPIPE');\n\t\t\t}\n\t\t});\n\t}\n}\n\nconst testEarlyErrorPipe = async (t, getSubprocess) => {\n\tawait t.throwsAsync(getSubprocess(), expectedEarlyError);\n};\n\ntest('child_process.spawn() early errors on source can use .pipe()', testEarlyErrorPipe, () => getEarlyErrorSubprocess().pipe(execa('empty.js')));\ntest('child_process.spawn() early errors on destination can use .pipe()', testEarlyErrorPipe, () => execa('empty.js').pipe(getEarlyErrorSubprocess()));\ntest('child_process.spawn() early errors on source and destination can use .pipe()', testEarlyErrorPipe, () => getEarlyErrorSubprocess().pipe(getEarlyErrorSubprocess()));\ntest('child_process.spawn() early errors can use .pipe() multiple times', testEarlyErrorPipe, () => getEarlyErrorSubprocess().pipe(getEarlyErrorSubprocess()).pipe(getEarlyErrorSubprocess()));\ntest('child_process.spawn() early errors can use .pipe``', testEarlyErrorPipe, () => $(earlyErrorOptions)`empty.js`.pipe(earlyErrorOptions)`empty.js`);\ntest('child_process.spawn() early errors can use .pipe`` multiple times', testEarlyErrorPipe, () => $(earlyErrorOptions)`empty.js`.pipe(earlyErrorOptions)`empty.js`.pipe`empty.js`);\n\nconst testEarlyErrorConvertor = async (t, streamMethod) => {\n\tconst subprocess = getEarlyErrorSubprocess();\n\tconst stream = subprocess[streamMethod]();\n\tstream.on('close', () => {});\n\tstream.read?.();\n\tstream.write?.('.');\n\tawait t.throwsAsync(subprocess);\n};\n\ntest('child_process.spawn() early errors can use .readable()', testEarlyErrorConvertor, 'readable');\ntest('child_process.spawn() early errors can use .writable()', testEarlyErrorConvertor, 'writable');\ntest('child_process.spawn() early errors can use .duplex()', testEarlyErrorConvertor, 'duplex');\n\nconst testEarlyErrorStream = async (t, getStreamProperty, options) => {\n\tconst subprocess = getEarlyErrorSubprocess(options);\n\tconst stream = getStreamProperty(subprocess);\n\tstream.on('close', () => {});\n\tstream.read?.();\n\tstream.end?.();\n\tawait t.throwsAsync(subprocess);\n};\n\ntest('child_process.spawn() early errors can use .stdin', testEarlyErrorStream, ({stdin}) => stdin);\ntest('child_process.spawn() early errors can use .stdout', testEarlyErrorStream, ({stdout}) => stdout);\ntest('child_process.spawn() early errors can use .stderr', testEarlyErrorStream, ({stderr}) => stderr);\ntest('child_process.spawn() early errors can use .stdio[1]', testEarlyErrorStream, ({stdio}) => stdio[1]);\ntest('child_process.spawn() early errors can use .stdio[3]', testEarlyErrorStream, ({stdio}) => stdio[3], fullStdio);\ntest('child_process.spawn() early errors can use .all', testEarlyErrorStream, ({all}) => all, {all: true});\n"
  },
  {
    "path": "test/return/final-error.js",
    "content": "import test from 'ava';\nimport {\n\texeca,\n\texecaSync,\n\tExecaError,\n\tExecaSyncError,\n} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getEarlyErrorSubprocess, getEarlyErrorSubprocessSync} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testUnusualError = async (t, error, expectedOriginalMessage = String(error)) => {\n\tconst subprocess = execa('empty.js');\n\tsubprocess.emit('error', error);\n\tconst {originalMessage, shortMessage, message} = await t.throwsAsync(subprocess);\n\tt.is(originalMessage, expectedOriginalMessage === '' ? undefined : expectedOriginalMessage);\n\tt.true(shortMessage.includes(expectedOriginalMessage));\n\tt.is(message, shortMessage);\n};\n\ntest('error instance can be null', testUnusualError, null);\ntest('error instance can be false', testUnusualError, false);\ntest('error instance can be a string', testUnusualError, 'test');\ntest('error instance can be a number', testUnusualError, 0);\ntest('error instance can be a BigInt', testUnusualError, 0n);\ntest('error instance can be a symbol', testUnusualError, Symbol('test'));\ntest('error instance can be a function', testUnusualError, () => {});\ntest('error instance can be an array', testUnusualError, ['test', 'test']);\n// eslint-disable-next-line unicorn/error-message\ntest('error instance can be an error with an empty message', testUnusualError, new Error(''), '');\ntest('error instance can be undefined', testUnusualError, undefined, 'undefined');\n\ntest('error instance can be a plain object', async t => {\n\tconst subprocess = execa('empty.js');\n\tsubprocess.emit('error', {message: foobarString});\n\tawait t.throwsAsync(subprocess, {message: new RegExp(foobarString)});\n});\n\nconst runAndFail = (t, fixtureName, argument, error) => {\n\tconst subprocess = execa(fixtureName, [argument]);\n\tsubprocess.emit('error', error);\n\treturn t.throwsAsync(subprocess);\n};\n\nconst testErrorCopy = async (t, getPreviousArgument, argument = 'two') => {\n\tconst fixtureName = 'empty.js';\n\tconst firstArgument = 'foo';\n\n\tconst previousArgument = await getPreviousArgument(t, fixtureName);\n\tconst previousError = await runAndFail(t, fixtureName, firstArgument, previousArgument);\n\tconst error = await runAndFail(t, fixtureName, argument, previousError);\n\tconst message = `Command failed: ${fixtureName} ${argument}\\n${foobarString}`;\n\n\tt.not(error, previousError);\n\tt.is(error.cause, previousError);\n\tt.is(error.command, `${fixtureName} ${argument}`);\n\tt.is(error.message, message);\n\tt.true(error.stack.includes(message));\n\tt.is(error.shortMessage, message);\n\tt.is(error.originalMessage, foobarString);\n};\n\ntest('error instance can be shared', testErrorCopy, () => new Error(foobarString));\ntest('error TypeError can be shared', testErrorCopy, () => new TypeError(foobarString));\ntest('error string can be shared', testErrorCopy, () => foobarString);\ntest('error copy can be shared', testErrorCopy, (t, fixtureName) => runAndFail(t, fixtureName, 'bar', new Error(foobarString)));\ntest('error with same message can be shared', testErrorCopy, () => new Error(foobarString), 'foo');\n\ntest('error.cause is not set if error.exitCode is not 0', async t => {\n\tconst {exitCode, cause} = await t.throwsAsync(execa('fail.js'));\n\tt.is(exitCode, 2);\n\tt.is(cause, undefined);\n});\n\ntest('error.cause is not set if error.isTerminated', async t => {\n\tconst subprocess = execa('forever.js');\n\tsubprocess.kill();\n\tconst {isTerminated, cause} = await t.throwsAsync(subprocess);\n\tt.true(isTerminated);\n\tt.is(cause, undefined);\n});\n\ntest('error.cause is not set if error.timedOut', async t => {\n\tconst {timedOut, cause} = await t.throwsAsync(execa('forever.js', {timeout: 1}));\n\tt.true(timedOut);\n\tt.is(cause, undefined);\n});\n\ntest('error.cause is set on error event', async t => {\n\tconst subprocess = execa('empty.js');\n\tconst error = new Error(foobarString);\n\tsubprocess.emit('error', error);\n\tconst {cause} = await t.throwsAsync(subprocess);\n\tt.is(cause, error);\n});\n\ntest('error.cause is set if error.isCanceled', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('forever.js', {cancelSignal: controller.signal});\n\tconst cause = new Error('test');\n\tcontroller.abort(cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.true(error.isCanceled);\n\tt.true(error.isTerminated);\n\tt.is(error.signal, 'SIGTERM');\n\tt.is(error.cause, cause);\n});\n\ntest('error.cause is not set if error.isTerminated with .kill(error)', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst error = new Error('test');\n\tsubprocess.kill(error);\n\tconst {isTerminated, cause} = await t.throwsAsync(subprocess);\n\tt.true(isTerminated);\n\tt.is(cause, error);\n});\n\ntest('Error is instanceof ExecaError', async t => {\n\tawait t.throwsAsync(execa('fail.js'), {instanceOf: ExecaError});\n});\n\ntest('Early error is instanceof ExecaError', async t => {\n\tawait t.throwsAsync(getEarlyErrorSubprocess(), {instanceOf: ExecaError});\n});\n\ntest('Error is instanceof ExecaSyncError', t => {\n\tt.throws(() => {\n\t\texecaSync('fail.js');\n\t}, {instanceOf: ExecaSyncError});\n});\n\ntest('Early error is instanceof ExecaSyncError', t => {\n\tt.throws(() => {\n\t\tgetEarlyErrorSubprocessSync();\n\t}, {instanceOf: ExecaSyncError});\n});\n\ntest('Pipe error is instanceof ExecaError', async t => {\n\tawait t.throwsAsync(execa('empty.js').pipe(false), {instanceOf: ExecaError});\n});\n\nconst assertNameShape = (t, error) => {\n\tt.false(Object.hasOwn(error, 'name'));\n\tt.true(Object.hasOwn(Object.getPrototypeOf(error), 'name'));\n\tt.false(propertyIsEnumerable.call(Object.getPrototypeOf(error), 'name'));\n};\n\nconst {propertyIsEnumerable} = Object.prototype;\n\ntest('error.name is properly set', async t => {\n\tconst error = await t.throwsAsync(execa('fail.js'));\n\tt.is(error.name, 'ExecaError');\n\tassertNameShape(t, error);\n});\n\ntest('error.name is properly set - sync', async t => {\n\tconst error = await t.throws(() => {\n\t\texecaSync('fail.js');\n\t});\n\tt.is(error.name, 'ExecaSyncError');\n\tassertNameShape(t, error);\n});\n"
  },
  {
    "path": "test/return/message.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio, getStdio} from '../helpers/stdio.js';\nimport {foobarString, foobarObject, foobarObjectInspect} from '../helpers/input.js';\nimport {QUOTE} from '../helpers/verbose.js';\nimport {noopGenerator, outputObjectGenerator} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\ntest('error.message contains the command', async t => {\n\tawait t.throwsAsync(execa('exit.js', ['2', 'foo', 'bar']), {message: /exit.js 2 foo bar/});\n});\n\n// eslint-disable-next-line max-params\nconst testStdioMessage = async (t, encoding, all, objectMode, execaMethod) => {\n\tconst {exitCode, message} = await execaMethod('echo-fail.js', {\n\t\t...getStdio(1, noopGenerator(objectMode, false, true), 4),\n\t\tencoding,\n\t\tall,\n\t\treject: false,\n\t});\n\tt.is(exitCode, 1);\n\tconst output = all ? 'stdout\\nstderr' : 'stderr\\n\\nstdout';\n\tt.true(message.endsWith(`echo-fail.js\\n\\n${output}\\n\\nfd3`));\n};\n\ntest('error.message contains stdout/stderr/stdio if available', testStdioMessage, 'utf8', false, false, execa);\ntest('error.message contains stdout/stderr/stdio even with encoding \"buffer\"', testStdioMessage, 'buffer', false, false, execa);\ntest('error.message contains all if available', testStdioMessage, 'utf8', true, false, execa);\ntest('error.message contains all even with encoding \"buffer\"', testStdioMessage, 'buffer', true, false, execa);\ntest('error.message contains stdout/stderr/stdio if available, objectMode', testStdioMessage, 'utf8', false, true, execa);\ntest('error.message contains stdout/stderr/stdio even with encoding \"buffer\", objectMode', testStdioMessage, 'buffer', false, true, execa);\ntest('error.message contains all if available, objectMode', testStdioMessage, 'utf8', true, true, execa);\ntest('error.message contains all even with encoding \"buffer\", objectMode', testStdioMessage, 'buffer', true, true, execa);\ntest('error.message contains stdout/stderr/stdio if available, sync', testStdioMessage, 'utf8', false, false, execaSync);\ntest('error.message contains stdout/stderr/stdio even with encoding \"buffer\", sync', testStdioMessage, 'buffer', false, false, execaSync);\ntest('error.message contains all if available, sync', testStdioMessage, 'utf8', true, false, execaSync);\ntest('error.message contains all even with encoding \"buffer\", sync', testStdioMessage, 'buffer', true, false, execaSync);\ntest('error.message contains stdout/stderr/stdio if available, objectMode, sync', testStdioMessage, 'utf8', false, true, execaSync);\ntest('error.message contains stdout/stderr/stdio even with encoding \"buffer\", objectMode, sync', testStdioMessage, 'buffer', false, true, execaSync);\ntest('error.message contains all if available, objectMode, sync', testStdioMessage, 'utf8', true, true, execaSync);\ntest('error.message contains all even with encoding \"buffer\", objectMode, sync', testStdioMessage, 'buffer', true, true, execaSync);\n\nconst testLinesMessage = async (t, encoding, stripFinalNewline, execaMethod) => {\n\tconst {failed, message} = await execaMethod('noop-fail.js', ['1', `${foobarString}\\n${foobarString}\\n`], {\n\t\tlines: true,\n\t\tencoding,\n\t\tstripFinalNewline,\n\t\treject: false,\n\t});\n\tt.true(failed);\n\tt.true(message.endsWith(`noop-fail.js 1 ${QUOTE}${foobarString}\\\\n${foobarString}\\\\n${QUOTE}\\n\\n${foobarString}\\n${foobarString}`));\n};\n\ntest('error.message handles \"lines: true\"', testLinesMessage, 'utf8', false, execa);\ntest('error.message handles \"lines: true\", stripFinalNewline', testLinesMessage, 'utf8', true, execa);\ntest('error.message handles \"lines: true\", buffer', testLinesMessage, 'buffer', false, execa);\ntest('error.message handles \"lines: true\", buffer, stripFinalNewline', testLinesMessage, 'buffer', true, execa);\ntest('error.message handles \"lines: true\", sync', testLinesMessage, 'utf8', false, execaSync);\ntest('error.message handles \"lines: true\", stripFinalNewline, sync', testLinesMessage, 'utf8', true, execaSync);\ntest('error.message handles \"lines: true\", buffer, sync', testLinesMessage, 'buffer', false, execaSync);\ntest('error.message handles \"lines: true\", buffer, stripFinalNewline, sync', testLinesMessage, 'buffer', true, execaSync);\n\nconst testPartialIgnoreMessage = async (t, fdNumber, stdioOption, output) => {\n\tconst {message} = await t.throwsAsync(execa('echo-fail.js', getStdio(fdNumber, stdioOption, 4)));\n\tt.true(message.endsWith(`echo-fail.js\\n\\n${output}\\n\\nfd3`));\n};\n\ntest('error.message does not contain stdout if not available', testPartialIgnoreMessage, 1, 'ignore', 'stderr');\ntest('error.message does not contain stderr if not available', testPartialIgnoreMessage, 2, 'ignore', 'stdout');\ntest('error.message does not contain stdout if it is an object', testPartialIgnoreMessage, 1, outputObjectGenerator(), 'stderr');\ntest('error.message does not contain stderr if it is an object', testPartialIgnoreMessage, 2, outputObjectGenerator(), 'stdout');\n\nconst testFullIgnoreMessage = async (t, options, resultProperty) => {\n\tconst {[resultProperty]: message} = await t.throwsAsync(execa('echo-fail.js', options));\n\tt.false(message.includes('stderr'));\n\tt.false(message.includes('stdout'));\n\tt.false(message.includes('fd3'));\n};\n\ntest('error.message does not contain stdout/stderr/stdio if not available', testFullIgnoreMessage, {stdio: 'ignore'}, 'message');\ntest('error.shortMessage does not contain stdout/stderr/stdio', testFullIgnoreMessage, fullStdio, 'shortMessage');\n\nconst testErrorMessageConsistent = async (t, stdout) => {\n\tconst {message} = await t.throwsAsync(execa('noop-both-fail-strict.js', [stdout, 'stderr']));\n\tt.true(message.endsWith(' stderr\\n\\nstderr\\n\\nstdout'));\n};\n\ntest('error.message newlines are consistent - no newline', testErrorMessageConsistent, 'stdout');\ntest('error.message newlines are consistent - newline', testErrorMessageConsistent, 'stdout\\n');\n\ntest('Original error.message is kept', async t => {\n\tconst {originalMessage} = await t.throwsAsync(execa('noop.js', {uid: true}));\n\tt.is(originalMessage, 'The \"options.uid\" property must be int32. Received type boolean (true)');\n});\n\nconst testIpcOutput = async (t, doubles, ipcInput, returnedMessage) => {\n\tconst fixtureName = doubles ? 'ipc-echo-twice-fail.js' : 'ipc-echo-fail.js';\n\tconst {exitCode, message, ipcOutput} = await t.throwsAsync(execa(fixtureName, {ipcInput}));\n\tt.is(exitCode, 1);\n\tt.true(message.endsWith(`\\n\\n${doubles ? `${returnedMessage}\\n${returnedMessage}` : returnedMessage}`));\n\tt.deepEqual(ipcOutput, doubles ? [ipcInput, ipcInput] : [ipcInput]);\n};\n\ntest('error.message contains IPC messages, single string', testIpcOutput, false, foobarString, foobarString);\ntest('error.message contains IPC messages, two strings', testIpcOutput, true, foobarString, foobarString);\ntest('error.message contains IPC messages, single object', testIpcOutput, false, foobarObject, foobarObjectInspect);\ntest('error.message contains IPC messages, two objects', testIpcOutput, true, foobarObject, foobarObjectInspect);\ntest('error.message contains IPC messages, multiline string', testIpcOutput, false, `${foobarString}\\n${foobarString}`, `${foobarString}\\n${foobarString}`);\ntest('error.message contains IPC messages, control characters', testIpcOutput, false, '\\0', '\\\\u0000');\n\ntest('error.message does not contain IPC messages, buffer false', async t => {\n\tconst {exitCode, message, ipcOutput} = await t.throwsAsync(execa('ipc-echo-fail.js', {ipcInput: foobarString, buffer: false}));\n\tt.is(exitCode, 1);\n\tt.true(message.endsWith('ipc-echo-fail.js'));\n\tt.deepEqual(ipcOutput, []);\n});\n"
  },
  {
    "path": "test/return/output.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio, getStdio} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\nimport {\n\tgetEarlyErrorSubprocess,\n\tgetEarlyErrorSubprocessSync,\n\texpectedEarlyError,\n\texpectedEarlyErrorSync,\n} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testOutput = async (t, fdNumber, execaMethod) => {\n\tconst {stdout, stderr, stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], fullStdio);\n\tt.is(stdio[fdNumber], foobarString);\n\n\tif (fdNumber === 1) {\n\t\tt.is(stdio[fdNumber], stdout);\n\t} else if (fdNumber === 2) {\n\t\tt.is(stdio[fdNumber], stderr);\n\t}\n};\n\ntest('can return stdout', testOutput, 1, execa);\ntest('can return stderr', testOutput, 2, execa);\ntest('can return output stdio[*]', testOutput, 3, execa);\ntest('can return stdout, sync', testOutput, 1, execaSync);\ntest('can return stderr, sync', testOutput, 2, execaSync);\ntest('can return output stdio[*], sync', testOutput, 3, execaSync);\n\nconst testNoStdin = async (t, execaMethod) => {\n\tconst {stdio} = await execaMethod('noop.js', [foobarString]);\n\tt.is(stdio[0], undefined);\n};\n\ntest('cannot return stdin', testNoStdin, execa);\ntest('cannot return stdin, sync', testNoStdin, execaSync);\n\ntest('cannot return input stdio[*]', async t => {\n\tconst {stdio} = await execa('stdin-fd.js', ['3'], getStdio(3, [[foobarString]]));\n\tt.is(stdio[3], undefined);\n});\n\ntest('do not try to consume streams twice', async t => {\n\tconst subprocess = execa('noop.js', ['foo']);\n\tconst {stdout} = await subprocess;\n\tconst {stdout: stdout2} = await subprocess;\n\tt.is(stdout, 'foo');\n\tt.is(stdout2, 'foo');\n});\n\nconst testEmptyErrorStdio = async (t, execaMethod) => {\n\tconst {failed, stdout, stderr, stdio} = await execaMethod('fail.js', {reject: false});\n\tt.true(failed);\n\tt.is(stdout, '');\n\tt.is(stderr, '');\n\tt.deepEqual(stdio, [undefined, '', '']);\n};\n\ntest('empty error.stdout/stderr/stdio', testEmptyErrorStdio, execa);\ntest('empty error.stdout/stderr/stdio, sync', testEmptyErrorStdio, execaSync);\n\nconst testUndefinedErrorStdio = async (t, execaMethod) => {\n\tconst {stdout, stderr, stdio} = await execaMethod('empty.js', {stdio: 'ignore'});\n\tt.is(stdout, undefined);\n\tt.is(stderr, undefined);\n\tt.deepEqual(stdio, [undefined, undefined, undefined]);\n};\n\ntest('undefined error.stdout/stderr/stdio', testUndefinedErrorStdio, execa);\ntest('undefined error.stdout/stderr/stdio, sync', testUndefinedErrorStdio, execaSync);\n\nconst testEmptyAll = async (t, options, expectedValue, execaMethod) => {\n\tconst {all} = await execaMethod('empty.js', options);\n\tt.is(all, expectedValue);\n};\n\ntest('empty error.all', testEmptyAll, {all: true}, '', execa);\ntest('undefined error.all', testEmptyAll, {}, undefined, execa);\ntest('ignored error.all', testEmptyAll, {all: true, stdio: 'ignore'}, undefined, execa);\ntest('empty error.all, sync', testEmptyAll, {all: true}, '', execaSync);\ntest('undefined error.all, sync', testEmptyAll, {}, undefined, execaSync);\ntest('ignored error.all, sync', testEmptyAll, {all: true, stdio: 'ignore'}, undefined, execaSync);\n\ntest('empty error.stdio[0] even with input', async t => {\n\tconst {stdio} = await t.throwsAsync(execa('fail.js', {input: 'test'}));\n\tt.is(stdio[0], undefined);\n});\n\nconst validateSpawnErrorStdio = (t, {stdout, stderr, stdio, all}) => {\n\tt.is(stdout, undefined);\n\tt.is(stderr, undefined);\n\tt.is(all, undefined);\n\tt.deepEqual(stdio, [undefined, undefined, undefined]);\n};\n\ntest('stdout/stderr/all/stdio on subprocess spawning errors', async t => {\n\tconst error = await t.throwsAsync(getEarlyErrorSubprocess({all: true}));\n\tt.like(error, expectedEarlyError);\n\tvalidateSpawnErrorStdio(t, error);\n});\n\ntest('stdout/stderr/all/stdio on subprocess spawning errors, sync', t => {\n\tconst error = t.throws(() => getEarlyErrorSubprocessSync({all: true}));\n\tt.like(error, expectedEarlyErrorSync);\n\tvalidateSpawnErrorStdio(t, error);\n});\n\nconst testErrorOutput = async (t, execaMethod) => {\n\tconst {failed, stdout, stderr, stdio} = await execaMethod('echo-fail.js', {...fullStdio, reject: false});\n\tt.true(failed);\n\tt.is(stdout, 'stdout');\n\tt.is(stderr, 'stderr');\n\tt.deepEqual(stdio, [undefined, 'stdout', 'stderr', 'fd3']);\n};\n\ntest('error.stdout/stderr/stdio is defined', testErrorOutput, execa);\ntest('error.stdout/stderr/stdio is defined, sync', testErrorOutput, execaSync);\n\ntest('ipc on subprocess spawning errors', async t => {\n\tconst error = await t.throwsAsync(getEarlyErrorSubprocess({ipc: true}));\n\tt.like(error, expectedEarlyError);\n\tt.deepEqual(error.ipcOutput, []);\n});\n\nconst testEarlyErrorNoIpc = async (t, options) => {\n\tconst error = await t.throwsAsync(getEarlyErrorSubprocess(options));\n\tt.like(error, expectedEarlyError);\n\tt.deepEqual(error.ipcOutput, []);\n};\n\ntest('ipc on subprocess spawning errors, ipc false', testEarlyErrorNoIpc, {ipc: false});\ntest('ipc on subprocess spawning errors, buffer false', testEarlyErrorNoIpc, {buffer: false});\n"
  },
  {
    "path": "test/return/reject.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\ntest('skip throwing when using reject option', async t => {\n\tconst {exitCode} = await execa('fail.js', {reject: false});\n\tt.is(exitCode, 2);\n});\n\ntest('skip throwing when using reject option in sync mode', t => {\n\tconst {exitCode} = execaSync('fail.js', {reject: false});\n\tt.is(exitCode, 2);\n});\n"
  },
  {
    "path": "test/return/result.js",
    "content": "import process from 'node:process';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\n\nconst isWindows = process.platform === 'win32';\n\nsetFixtureDirectory();\n\nconst testSuccessShape = async (t, execaMethod) => {\n\tconst result = await execaMethod('empty.js', {...fullStdio, all: true});\n\tt.deepEqual(Reflect.ownKeys(result), [\n\t\t'command',\n\t\t'escapedCommand',\n\t\t'cwd',\n\t\t'durationMs',\n\t\t'failed',\n\t\t'timedOut',\n\t\t'isCanceled',\n\t\t'isGracefullyCanceled',\n\t\t'isTerminated',\n\t\t'isMaxBuffer',\n\t\t'isForcefullyTerminated',\n\t\t'exitCode',\n\t\t'stdout',\n\t\t'stderr',\n\t\t'all',\n\t\t'stdio',\n\t\t'ipcOutput',\n\t\t'pipedFrom',\n\t]);\n};\n\ntest('Return value properties are not missing and are ordered', testSuccessShape, execa);\ntest('Return value properties are not missing and are ordered, sync', testSuccessShape, execaSync);\n\nconst testErrorShape = async (t, execaMethod) => {\n\tconst error = await execaMethod('fail.js', {...fullStdio, all: true, reject: false});\n\tt.is(error.exitCode, 2);\n\tt.deepEqual(Reflect.ownKeys(error), [\n\t\t'stack',\n\t\t'message',\n\t\t'shortMessage',\n\t\t'command',\n\t\t'escapedCommand',\n\t\t'cwd',\n\t\t'durationMs',\n\t\t'failed',\n\t\t'timedOut',\n\t\t'isCanceled',\n\t\t'isGracefullyCanceled',\n\t\t'isTerminated',\n\t\t'isMaxBuffer',\n\t\t'isForcefullyTerminated',\n\t\t'exitCode',\n\t\t'stdout',\n\t\t'stderr',\n\t\t'all',\n\t\t'stdio',\n\t\t'ipcOutput',\n\t\t'pipedFrom',\n\t]);\n};\n\ntest('Error properties are not missing and are ordered', testErrorShape, execa);\ntest('Error properties are not missing and are ordered, sync', testErrorShape, execaSync);\n\ntest('failed is false on success', async t => {\n\tconst {failed} = await execa('noop.js', ['foo']);\n\tt.false(failed);\n});\n\ntest('failed is true on failure', async t => {\n\tconst {failed} = await t.throwsAsync(execa('fail.js'));\n\tt.true(failed);\n});\n\ntest('error.isTerminated is true if subprocess was killed directly', async t => {\n\tconst subprocess = execa('forever.js', {killSignal: 'SIGINT'});\n\n\tsubprocess.kill();\n\n\tconst {isTerminated, signal, originalMessage, message, shortMessage} = await t.throwsAsync(subprocess, {message: /was killed with SIGINT/});\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGINT');\n\tt.is(originalMessage, undefined);\n\tt.is(shortMessage, 'Command was killed with SIGINT (User interruption with CTRL-C): forever.js');\n\tt.is(message, shortMessage);\n});\n\ntest('error.isTerminated is true if subprocess was killed indirectly', async t => {\n\tconst subprocess = execa('forever.js', {killSignal: 'SIGHUP'});\n\n\tprocess.kill(subprocess.pid, 'SIGINT');\n\n\t// `subprocess.kill()` is emulated by Node.js on Windows\n\tif (isWindows) {\n\t\tconst {isTerminated, signal} = await t.throwsAsync(subprocess, {message: /failed with exit code 1/});\n\t\tt.is(isTerminated, false);\n\t\tt.is(signal, undefined);\n\t} else {\n\t\tconst {isTerminated, signal} = await t.throwsAsync(subprocess, {message: /was killed with SIGINT/});\n\t\tt.is(isTerminated, true);\n\t\tt.is(signal, 'SIGINT');\n\t}\n});\n\ntest('result.isTerminated is false if not killed', async t => {\n\tconst {isTerminated} = await execa('noop.js');\n\tt.false(isTerminated);\n});\n\ntest('result.isTerminated is false if not killed and subprocess.kill() was called', async t => {\n\tconst subprocess = execa('noop.js');\n\tsubprocess.kill(0);\n\tt.true(subprocess.killed);\n\tconst {isTerminated} = await subprocess;\n\tt.false(isTerminated);\n});\n\ntest('result.isTerminated is false if not killed, in sync mode', t => {\n\tconst {isTerminated} = execaSync('noop.js');\n\tt.false(isTerminated);\n});\n\ntest('result.isTerminated is false on subprocess error', async t => {\n\tconst {isTerminated} = await t.throwsAsync(execa('wrong command'));\n\tt.false(isTerminated);\n});\n\ntest('result.isTerminated is false on subprocess error, in sync mode', t => {\n\tconst {isTerminated} = t.throws(() => {\n\t\texecaSync('wrong command');\n\t});\n\tt.false(isTerminated);\n});\n\ntest('error.code is undefined on success', async t => {\n\tconst {code} = await execa('noop.js');\n\tt.is(code, undefined);\n});\n\ntest('error.code is defined on failure if applicable', async t => {\n\tconst {code} = await t.throwsAsync(execa('noop.js', {uid: true}));\n\tt.is(code, 'ERR_INVALID_ARG_TYPE');\n});\n"
  },
  {
    "path": "test/stdio/direction.js",
    "content": "import {readFile, writeFile, rm} from 'node:fs/promises';\nimport process from 'node:process';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testInputOutput = (t, stdioOption, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(3, [new ReadableStream(), stdioOption]));\n\t}, {message: /readable and writable/});\n};\n\ntest('Cannot pass both readable and writable values to stdio[*] - WritableStream', testInputOutput, new WritableStream(), execa);\ntest('Cannot pass both readable and writable values to stdio[*] - 1', testInputOutput, 1, execa);\ntest('Cannot pass both readable and writable values to stdio[*] - 2', testInputOutput, 2, execa);\ntest('Cannot pass both readable and writable values to stdio[*] - process.stdout', testInputOutput, process.stdout, execa);\ntest('Cannot pass both readable and writable values to stdio[*] - process.stderr', testInputOutput, process.stderr, execa);\ntest('Cannot pass both readable and writable values to stdio[*] - WritableStream - sync', testInputOutput, new WritableStream(), execaSync);\ntest('Cannot pass both readable and writable values to stdio[*] - 1 - sync', testInputOutput, 1, execaSync);\ntest('Cannot pass both readable and writable values to stdio[*] - 2 - sync', testInputOutput, 2, execaSync);\ntest('Cannot pass both readable and writable values to stdio[*] - process.stdout - sync', testInputOutput, process.stdout, execaSync);\ntest('Cannot pass both readable and writable values to stdio[*] - process.stderr - sync', testInputOutput, process.stderr, execaSync);\n\nconst testAmbiguousDirection = async (t, execaMethod) => {\n\tconst [filePathOne, filePathTwo] = [tempfile(), tempfile()];\n\tawait execaMethod('noop-fd.js', ['3', foobarString], getStdio(3, [{file: filePathOne}, {file: filePathTwo}]));\n\tt.deepEqual(\n\t\tawait Promise.all([readFile(filePathOne, 'utf8'), readFile(filePathTwo, 'utf8')]),\n\t\t[foobarString, foobarString],\n\t);\n\tawait Promise.all([rm(filePathOne), rm(filePathTwo)]);\n};\n\ntest('stdio[*] default direction is output', testAmbiguousDirection, execa);\ntest('stdio[*] default direction is output - sync', testAmbiguousDirection, execaSync);\n\nconst testAmbiguousMultiple = async (t, fdNumber) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [{file: filePath}, ['foo', 'bar']]));\n\tt.is(stdout, `${foobarString}${foobarString}`);\n\tawait rm(filePath);\n};\n\ntest('stdin ambiguous direction is influenced by other values', testAmbiguousMultiple, 0);\ntest('stdio[*] ambiguous direction is influenced by other values', testAmbiguousMultiple, 3);\n"
  },
  {
    "path": "test/stdio/duplex.js",
    "content": "import {createHash} from 'node:crypto';\nimport {promisify} from 'node:util';\nimport {createGzip, gunzip} from 'node:zlib';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tfoobarString,\n\tfoobarObject,\n\tfoobarUppercase,\n\tfoobarUppercaseHex,\n} from '../helpers/input.js';\nimport {uppercaseEncodingDuplex, getOutputDuplex} from '../helpers/duplex.js';\n\nsetFixtureDirectory();\n\ntest('Can use crypto.createHash()', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: {transform: createHash('sha1')}, encoding: 'hex'});\n\tconst expectedStdout = createHash('sha1').update(foobarString).digest('hex');\n\tt.is(stdout, expectedStdout);\n});\n\ntest('Can use zlib.createGzip()', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: {transform: createGzip()}, encoding: 'buffer'});\n\tconst decompressedStdout = await promisify(gunzip)(stdout);\n\tt.is(decompressedStdout.toString(), foobarString);\n});\n\ntest('Can use encoding \"hex\"', async t => {\n\tconst {transform} = uppercaseEncodingDuplex('hex')();\n\tt.is(transform.readableEncoding, 'hex');\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: {transform}});\n\tt.is(stdout, foobarUppercaseHex);\n});\n\ntest('Cannot use objectMode: true with duplex.readableObjectMode: false', t => {\n\tt.throws(() => {\n\t\texeca('noop-fd.js', ['1', foobarString], {stdout: uppercaseEncodingDuplex(undefined, false)(true)});\n\t}, {message: /cannot be `false` if `new Duplex\\({objectMode: true}\\)`/});\n});\n\ntest('Cannot use objectMode: false with duplex.readableObjectMode: true', t => {\n\tt.throws(() => {\n\t\texeca('noop-fd.js', ['1', foobarString], {stdout: uppercaseEncodingDuplex(undefined, true)(false)});\n\t}, {message: /can only be `true` if `new Duplex\\({objectMode: true}\\)`/});\n});\n\nconst testObjectModeFalse = async (t, objectMode) => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: uppercaseEncodingDuplex(undefined, objectMode)(false)});\n\tt.is(stdout, foobarUppercase);\n};\n\ntest('Can use objectMode: false with duplex.readableObjectMode: false', testObjectModeFalse, false);\ntest('Can use objectMode: undefined with duplex.readableObjectMode: false', testObjectModeFalse, undefined);\n\nconst testObjectModeTrue = async (t, objectMode) => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: getOutputDuplex(foobarObject, objectMode)(true)});\n\tt.deepEqual(stdout, [foobarObject]);\n};\n\ntest('Can use objectMode: true with duplex.readableObjectMode: true', testObjectModeTrue, true);\ntest('Can use objectMode: undefined with duplex.readableObjectMode: true', testObjectModeTrue, undefined);\n"
  },
  {
    "path": "test/stdio/duplicate.js",
    "content": "import {once} from 'node:events';\nimport {createReadStream, createWriteStream} from 'node:fs';\nimport {readFile, writeFile, rm} from 'node:fs/promises';\nimport {Readable, Writable} from 'node:stream';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {\n\tuppercaseGenerator,\n\tappendGenerator,\n\tappendAsyncGenerator,\n\tcasedSuffix,\n} from '../helpers/generator.js';\nimport {appendDuplex} from '../helpers/duplex.js';\nimport {appendWebTransform} from '../helpers/web-transform.js';\nimport {foobarString, foobarUint8Array, foobarUppercase} from '../helpers/input.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {getAbsolutePath} from '../helpers/file-path.js';\nimport {noopDuplex} from '../helpers/stream.js';\n\nsetFixtureDirectory();\n\nconst getNativeStream = stream => stream;\nconst getNonNativeStream = stream => ['pipe', stream];\nconst getWebWritableStream = stream => Writable.toWeb(stream);\n\nconst getDummyDuplex = () => ({transform: noopDuplex()});\nconst getDummyWebTransformStream = () => new TransformStream();\n\nconst getDummyPath = async () => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, '');\n\treturn filePath;\n};\n\nconst getDummyFilePath = async () => ({file: await getDummyPath()});\nconst getDummyFileURL = async () => pathToFileURL((await getDummyPath()));\nconst duplexName = 'a Duplex stream';\nconst webTransformName = 'a web TransformStream';\nconst filePathName = 'a file path string';\nconst fileURLName = 'a file URL';\n\nconst getDifferentInputs = stdioOption => ({stdio: [stdioOption, 'pipe', 'pipe', stdioOption]});\nconst getDifferentOutputs = stdioOption => ({stdout: stdioOption, stderr: stdioOption});\nconst getDifferentInputsOutputs = stdioOption => ({stdin: stdioOption, stdout: stdioOption});\nconst differentInputsName = '`stdin` and `stdio[3]`';\nconst differentOutputsName = '`stdout` and `stderr`';\nconst differentInputsOutputsName = '`stdin` and `stdout`';\n\ntest('Can use multiple \"pipe\" on same input file descriptor', async t => {\n\tconst subprocess = execa('stdin.js', {stdin: ['pipe', 'pipe']});\n\tsubprocess.stdin.end(foobarString);\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, foobarString);\n});\n\nconst testTwoPipeOutput = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', [foobarString], {stdout: ['pipe', 'pipe']});\n\tt.is(stdout, foobarString);\n};\n\ntest('Can use multiple \"pipe\" on same output file descriptor', testTwoPipeOutput, execa);\ntest('Can use multiple \"pipe\" on same output file descriptor, sync', testTwoPipeOutput, execaSync);\n\ntest('Can repeat same stream on same input file descriptor', async t => {\n\tconst stream = Readable.from([foobarString]);\n\tconst {stdout} = await execa('stdin.js', {stdin: ['pipe', stream, stream]});\n\tt.is(stdout, foobarString);\n});\n\ntest('Can repeat same stream on same output file descriptor', async t => {\n\tlet stdout = '';\n\tconst stream = new Writable({\n\t\twrite(chunk, encoding, done) {\n\t\t\tstdout += chunk.toString();\n\t\t\tdone();\n\t\t},\n\t});\n\tawait execa('noop-fd.js', ['1', foobarString], {stdout: ['pipe', stream, stream]});\n\tt.is(stdout, foobarString);\n});\n\n// eslint-disable-next-line max-params\nconst testTwoGenerators = async (t, producesTwo, execaMethod, firstGenerator, secondGenerator = firstGenerator) => {\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: [firstGenerator, secondGenerator]});\n\tconst expectedSuffix = producesTwo ? `${casedSuffix}${casedSuffix}` : casedSuffix;\n\tt.is(stdout, `${foobarString}${expectedSuffix}`);\n};\n\ntest('Can use multiple identical generators', testTwoGenerators, true, execa, appendGenerator().transform);\ntest('Can use multiple identical generators, options object', testTwoGenerators, true, execa, appendGenerator());\ntest('Can use multiple identical generators, async', testTwoGenerators, true, execa, appendAsyncGenerator().transform);\ntest('Can use multiple identical generators, options object, async', testTwoGenerators, true, execa, appendAsyncGenerator());\ntest('Can use multiple identical generators, sync', testTwoGenerators, true, execaSync, appendGenerator().transform);\ntest('Can use multiple identical generators, options object, sync', testTwoGenerators, true, execaSync, appendGenerator());\ntest('Ignore duplicate identical duplexes', testTwoGenerators, false, execa, appendDuplex());\ntest('Ignore duplicate identical webTransforms', testTwoGenerators, false, execa, appendWebTransform());\ntest('Can use multiple generators with duplexes', testTwoGenerators, true, execa, appendGenerator(false, false, true), appendDuplex());\ntest('Can use multiple generators with webTransforms', testTwoGenerators, true, execa, appendGenerator(false, false, true), appendWebTransform());\ntest('Can use multiple duplexes with webTransforms', testTwoGenerators, true, execa, appendDuplex(), appendWebTransform());\n\nconst testMultiplePipeOutput = async (t, execaMethod) => {\n\tconst {stdout, stderr} = await execaMethod('noop-both.js', [foobarString], fullStdio);\n\tt.is(stdout, foobarString);\n\tt.is(stderr, foobarString);\n};\n\ntest('Can use multiple \"pipe\" on different output file descriptors', testMultiplePipeOutput, execa);\ntest('Can use multiple \"pipe\" on different output file descriptors, sync', testMultiplePipeOutput, execaSync);\n\ntest('Can re-use same generator on different input file descriptors', async t => {\n\tconst {stdout} = await execa('stdin-fd-both.js', ['3'], getDifferentInputs([foobarUint8Array, uppercaseGenerator(false, false, true)]));\n\tt.is(stdout, `${foobarUppercase}${foobarUppercase}`);\n});\n\ntest('Can re-use same generator on different output file descriptors', async t => {\n\tconst {stdout, stderr} = await execa('noop-both.js', [foobarString], getDifferentOutputs(uppercaseGenerator(false, false, true)));\n\tt.is(stdout, foobarUppercase);\n\tt.is(stderr, foobarUppercase);\n});\n\ntest('Can re-use same non-native Readable stream on different input file descriptors', async t => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst stream = createReadStream(filePath);\n\tawait once(stream, 'open');\n\tconst {stdout} = await execa('stdin-fd-both.js', ['3'], getDifferentInputs([new Uint8Array(0), stream]));\n\tt.is(stdout, `${foobarString}${foobarString}`);\n\tawait rm(filePath);\n});\n\nconst testMultipleStreamOutput = async (t, getStreamOption) => {\n\tconst filePath = tempfile();\n\tconst stream = createWriteStream(filePath);\n\tawait once(stream, 'open');\n\tawait execa('noop-both.js', [foobarString], getDifferentOutputs(getStreamOption(stream)));\n\tt.is(await readFile(filePath, 'utf8'), `${foobarString}\\n${foobarString}\\n`);\n\tawait rm(filePath);\n};\n\ntest('Can re-use same native Writable stream on different output file descriptors', testMultipleStreamOutput, getNativeStream);\ntest('Can re-use same non-native Writable stream on different output file descriptors', testMultipleStreamOutput, getNonNativeStream);\ntest('Can re-use same web Writable stream on different output file descriptors', testMultipleStreamOutput, getWebWritableStream);\n\nconst testMultipleInheritOutput = async (t, isSync) => {\n\tconst {stdout} = await nestedSubprocess('noop-both.js', [foobarString], {...getDifferentOutputs(1), isSync});\n\tt.is(stdout, `${foobarString}\\n${foobarString}`);\n};\n\ntest('Can re-use same parent file descriptor on different output file descriptors', testMultipleInheritOutput, false);\ntest('Can re-use same parent file descriptor on different output file descriptors, sync', testMultipleInheritOutput, true);\n\nconst testMultipleFileInput = async (t, mapFile) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst {stdout} = await execa('stdin-fd-both.js', ['3'], getDifferentInputs([new Uint8Array(0), mapFile(filePath)]));\n\tt.is(stdout, `${foobarString}${foobarString}`);\n\tawait rm(filePath);\n};\n\ntest('Can re-use same file path on different input file descriptors', testMultipleFileInput, getAbsolutePath);\ntest('Can re-use same file URL on different input file descriptors', testMultipleFileInput, pathToFileURL);\n\nconst testMultipleFileOutput = async (t, mapFile, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait execaMethod('noop-both.js', [foobarString], getDifferentOutputs(mapFile(filePath)));\n\tt.is(await readFile(filePath, 'utf8'), `${foobarString}\\n${foobarString}\\n`);\n\tawait rm(filePath);\n};\n\ntest('Can re-use same file path on different output file descriptors', testMultipleFileOutput, getAbsolutePath, execa);\ntest('Can re-use same file path on different output file descriptors, sync', testMultipleFileOutput, getAbsolutePath, execaSync);\ntest('Can re-use same file URL on different output file descriptors', testMultipleFileOutput, pathToFileURL, execa);\ntest('Can re-use same file URL on different output file descriptors, sync', testMultipleFileOutput, pathToFileURL, execaSync);\n\nconst testMultipleFileInputOutput = async (t, mapFile, execaMethod) => {\n\tconst inputFilePath = tempfile();\n\tconst outputFilePath = tempfile();\n\tawait writeFile(inputFilePath, foobarString);\n\tawait execaMethod('stdin.js', {stdin: mapFile(inputFilePath), stdout: mapFile(outputFilePath)});\n\tt.is(await readFile(outputFilePath, 'utf8'), foobarString);\n\tawait Promise.all([rm(inputFilePath), rm(outputFilePath)]);\n};\n\ntest('Can use different file paths on different input/output file descriptors', testMultipleFileInputOutput, getAbsolutePath, execa);\ntest('Can use different file paths on different input/output file descriptors, sync', testMultipleFileInputOutput, getAbsolutePath, execaSync);\ntest('Can use different file URL on different input/output file descriptors', testMultipleFileInputOutput, pathToFileURL, execa);\ntest('Can use different file URL on different input/output file descriptors, sync', testMultipleFileInputOutput, pathToFileURL, execaSync);\n\n// eslint-disable-next-line max-params\nconst testMultipleInvalid = async (t, getDummyStream, typeName, getStdio, fdName, execaMethod) => {\n\tconst stdioOption = await getDummyStream();\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(stdioOption));\n\t}, {message: `The ${fdName} options must not target ${typeName} that is the same.`});\n\tif (stdioOption.transform !== undefined) {\n\t\tt.true(stdioOption.transform.destroyed);\n\t}\n};\n\ntest('Cannot use same Duplex on different input file descriptors', testMultipleInvalid, getDummyDuplex, duplexName, getDifferentInputs, differentInputsName, execa);\ntest('Cannot use same Duplex on different output file descriptors', testMultipleInvalid, getDummyDuplex, duplexName, getDifferentOutputs, differentOutputsName, execa);\ntest('Cannot use same Duplex on both input and output file descriptors', testMultipleInvalid, getDummyDuplex, duplexName, getDifferentInputsOutputs, differentInputsOutputsName, execa);\ntest('Cannot use same TransformStream on different input file descriptors', testMultipleInvalid, getDummyWebTransformStream, webTransformName, getDifferentInputs, differentInputsName, execa);\ntest('Cannot use same TransformStream on different output file descriptors', testMultipleInvalid, getDummyWebTransformStream, webTransformName, getDifferentOutputs, differentOutputsName, execa);\ntest('Cannot use same TransformStream on both input and output file descriptors', testMultipleInvalid, getDummyWebTransformStream, webTransformName, getDifferentInputsOutputs, differentInputsOutputsName, execa);\ntest('Cannot use same file path on both input and output file descriptors', testMultipleInvalid, getDummyFilePath, filePathName, getDifferentInputsOutputs, differentInputsOutputsName, execa);\ntest('Cannot use same file URL on both input and output file descriptors', testMultipleInvalid, getDummyFileURL, fileURLName, getDifferentInputsOutputs, differentInputsOutputsName, execa);\ntest('Cannot use same file path on both input and output file descriptors, sync', testMultipleInvalid, getDummyFilePath, filePathName, getDifferentInputsOutputs, differentInputsOutputsName, execaSync);\ntest('Cannot use same file URL on both input and output file descriptors, sync', testMultipleInvalid, getDummyFileURL, fileURLName, getDifferentInputsOutputs, differentInputsOutputsName, execaSync);\n"
  },
  {
    "path": "test/stdio/file-descriptor.js",
    "content": "import {readFile, open, rm} from 'node:fs/promises';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst testFileDescriptorOption = async (t, fdNumber, execaMethod) => {\n\tconst filePath = tempfile();\n\tconst fileDescriptor = await open(filePath, 'w');\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, fileDescriptor));\n\tt.is(await readFile(filePath, 'utf8'), 'foobar');\n\tawait rm(filePath);\n\tawait fileDescriptor.close();\n};\n\ntest('pass `stdout` to a file descriptor', testFileDescriptorOption, 1, execa);\ntest('pass `stderr` to a file descriptor', testFileDescriptorOption, 2, execa);\ntest('pass `stdio[*]` to a file descriptor', testFileDescriptorOption, 3, execa);\ntest('pass `stdout` to a file descriptor - sync', testFileDescriptorOption, 1, execaSync);\ntest('pass `stderr` to a file descriptor - sync', testFileDescriptorOption, 2, execaSync);\ntest('pass `stdio[*]` to a file descriptor - sync', testFileDescriptorOption, 3, execaSync);\n\nconst testStdinWrite = async (t, fdNumber) => {\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, 'pipe'));\n\tsubprocess.stdio[fdNumber].end('unicorns');\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, 'unicorns');\n};\n\ntest('you can write to subprocess.stdin', testStdinWrite, 0);\ntest('you can write to subprocess.stdio[*]', testStdinWrite, 3);\n"
  },
  {
    "path": "test/stdio/file-path-error.js",
    "content": "import {readFile, writeFile, rm} from 'node:fs/promises';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport {pathExists} from 'path-exists';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {identity, getStdio} from '../helpers/stdio.js';\nimport {foobarString, foobarUppercase} from '../helpers/input.js';\nimport {\n\toutputObjectGenerator,\n\tuppercaseGenerator,\n\tserializeGenerator,\n\tthrowingGenerator,\n} from '../helpers/generator.js';\nimport {getAbsolutePath} from '../helpers/file-path.js';\n\nsetFixtureDirectory();\n\nconst nonFileUrl = new URL('https://example.com');\n\nconst testStdioNonFileUrl = (t, fdNumber, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, nonFileUrl));\n\t}, {message: /pathToFileURL/});\n};\n\ntest('inputFile cannot be a non-file URL', testStdioNonFileUrl, 'inputFile', execa);\ntest('stdin cannot be a non-file URL', testStdioNonFileUrl, 0, execa);\ntest('stdout cannot be a non-file URL', testStdioNonFileUrl, 1, execa);\ntest('stderr cannot be a non-file URL', testStdioNonFileUrl, 2, execa);\ntest('stdio[*] cannot be a non-file URL', testStdioNonFileUrl, 3, execa);\ntest('inputFile cannot be a non-file URL - sync', testStdioNonFileUrl, 'inputFile', execaSync);\ntest('stdin cannot be a non-file URL - sync', testStdioNonFileUrl, 0, execaSync);\ntest('stdout cannot be a non-file URL - sync', testStdioNonFileUrl, 1, execaSync);\ntest('stderr cannot be a non-file URL - sync', testStdioNonFileUrl, 2, execaSync);\ntest('stdio[*] cannot be a non-file URL - sync', testStdioNonFileUrl, 3, execaSync);\n\nconst testInvalidInputFile = (t, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio('inputFile', false));\n\t}, {message: /a file path string or a file URL/});\n};\n\ntest('inputFile must be a file URL or string', testInvalidInputFile, execa);\ntest('inputFile must be a file URL or string - sync', testInvalidInputFile, execaSync);\n\nconst testFilePathObject = (t, fdNumber, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, foobarString));\n\t}, {message: /must be used/});\n};\n\ntest('stdin must be an object when it is a file path string', testFilePathObject, 0, execa);\ntest('stdout must be an object when it is a file path string', testFilePathObject, 1, execa);\ntest('stderr must be an object when it is a file path string', testFilePathObject, 2, execa);\ntest('stdio[*] must be an object when it is a file path string', testFilePathObject, 3, execa);\ntest('stdin be an object when it is a file path string - sync', testFilePathObject, 0, execaSync);\ntest('stdout be an object when it is a file path string - sync', testFilePathObject, 1, execaSync);\ntest('stderr be an object when it is a file path string - sync', testFilePathObject, 2, execaSync);\ntest('stdio[*] must be an object when it is a file path string - sync', testFilePathObject, 3, execaSync);\n\nconst testFileError = async (t, fixtureName, mapFile, fdNumber) => {\n\tawait t.throwsAsync(\n\t\texeca(fixtureName, [`${fdNumber}`], getStdio(fdNumber, mapFile('./unknown/file'))),\n\t\t{code: 'ENOENT'},\n\t);\n};\n\ntest.serial('inputFile file URL errors should be handled', testFileError, 'stdin-fd.js', pathToFileURL, 'inputFile');\ntest.serial('stdin file URL errors should be handled', testFileError, 'stdin-fd.js', pathToFileURL, 0);\ntest.serial('stdout file URL errors should be handled', testFileError, 'noop-fd.js', pathToFileURL, 1);\ntest.serial('stderr file URL errors should be handled', testFileError, 'noop-fd.js', pathToFileURL, 2);\ntest.serial('stdio[*] file URL errors should be handled', testFileError, 'noop-fd.js', pathToFileURL, 3);\ntest.serial('inputFile file path errors should be handled', testFileError, 'stdin-fd.js', identity, 'inputFile');\ntest.serial('stdin file path errors should be handled', testFileError, 'stdin-fd.js', getAbsolutePath, 0);\ntest.serial('stdout file path errors should be handled', testFileError, 'noop-fd.js', getAbsolutePath, 1);\ntest.serial('stderr file path errors should be handled', testFileError, 'noop-fd.js', getAbsolutePath, 2);\ntest.serial('stdio[*] file path errors should be handled', testFileError, 'noop-fd.js', getAbsolutePath, 3);\n\nconst testFileErrorSync = (t, mapFile, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, mapFile('./unknown/file')));\n\t}, {code: 'ENOENT'});\n};\n\ntest('inputFile file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, 'inputFile');\ntest('stdin file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, 0);\ntest('stdout file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, 1);\ntest('stderr file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, 2);\ntest('stdio[*] file URL errors should be handled - sync', testFileErrorSync, pathToFileURL, 3);\ntest('inputFile file path errors should be handled - sync', testFileErrorSync, identity, 'inputFile');\ntest('stdin file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, 0);\ntest('stdout file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, 1);\ntest('stderr file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, 2);\ntest('stdio[*] file path errors should be handled - sync', testFileErrorSync, getAbsolutePath, 3);\n\nconst testInputFileObject = async (t, fdNumber, mapFile, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tt.throws(() => {\n\t\texecaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [\n\t\t\tnew Uint8Array(),\n\t\t\tmapFile(filePath),\n\t\t\tserializeGenerator(true),\n\t\t]));\n\t}, {message: /cannot use both files and transforms in objectMode/});\n\tawait rm(filePath);\n};\n\ntest('stdin cannot use objectMode together with input file paths', testInputFileObject, 0, getAbsolutePath, execa);\ntest('stdin cannot use objectMode together with input file URLs', testInputFileObject, 0, pathToFileURL, execa);\ntest('stdio[*] cannot use objectMode together with input file paths', testInputFileObject, 3, getAbsolutePath, execa);\ntest('stdio[*] cannot use objectMode together with input file URLs', testInputFileObject, 3, pathToFileURL, execa);\ntest('stdin cannot use objectMode together with input file paths, sync', testInputFileObject, 0, getAbsolutePath, execaSync);\ntest('stdin cannot use objectMode together with input file URLs, sync', testInputFileObject, 0, pathToFileURL, execaSync);\n\nconst testOutputFileObject = async (t, fdNumber, mapFile, execaMethod) => {\n\tconst filePath = tempfile();\n\tt.throws(() => {\n\t\texecaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [\n\t\t\toutputObjectGenerator(),\n\t\t\tmapFile(filePath),\n\t\t]));\n\t}, {message: /cannot use both files and transforms in objectMode/});\n\tt.false(await pathExists(filePath));\n};\n\ntest('stdout cannot use objectMode together with output file paths', testOutputFileObject, 1, getAbsolutePath, execa);\ntest('stdout cannot use objectMode together with output file URLs', testOutputFileObject, 1, pathToFileURL, execa);\ntest('stderr cannot use objectMode together with output file paths', testOutputFileObject, 2, getAbsolutePath, execa);\ntest('stderr cannot use objectMode together with output file URLs', testOutputFileObject, 2, pathToFileURL, execa);\ntest('stdio[*] cannot use objectMode together with output file paths', testOutputFileObject, 3, getAbsolutePath, execa);\ntest('stdio[*] cannot use objectMode together with output file URLs', testOutputFileObject, 3, pathToFileURL, execa);\ntest('stdout cannot use objectMode together with output file paths, sync', testOutputFileObject, 1, getAbsolutePath, execaSync);\ntest('stdout cannot use objectMode together with output file URLs, sync', testOutputFileObject, 1, pathToFileURL, execaSync);\ntest('stderr cannot use objectMode together with output file paths, sync', testOutputFileObject, 2, getAbsolutePath, execaSync);\ntest('stderr cannot use objectMode together with output file URLs, sync', testOutputFileObject, 2, pathToFileURL, execaSync);\ntest('stdio[*] cannot use objectMode together with output file paths, sync', testOutputFileObject, 3, getAbsolutePath, execaSync);\ntest('stdio[*] cannot use objectMode together with output file URLs, sync', testOutputFileObject, 3, pathToFileURL, execaSync);\n\ntest('Generator error stops writing to output file', async t => {\n\tconst filePath = tempfile();\n\tconst cause = new Error(foobarString);\n\tconst error = await t.throwsAsync(execa('noop.js', {\n\t\tstdout: [throwingGenerator(cause)(), getAbsolutePath(filePath)],\n\t}));\n\tt.is(error.cause, cause);\n\tt.is(await readFile(filePath, 'utf8'), '');\n});\n\ntest('Generator error does not create output file, sync', async t => {\n\tconst filePath = tempfile();\n\tconst cause = new Error(foobarString);\n\tconst error = t.throws(() => {\n\t\texecaSync('noop.js', {\n\t\t\tstdout: [throwingGenerator(cause)(), getAbsolutePath(filePath)],\n\t\t});\n\t});\n\tt.is(error.cause, cause);\n\tt.false(await pathExists(filePath));\n});\n\ntest('Output file error still returns transformed output, sync', async t => {\n\tconst filePath = tempfile();\n\tconst {stdout} = t.throws(() => {\n\t\texecaSync('noop-fd.js', ['1', foobarString], {\n\t\t\tstdout: [uppercaseGenerator(), getAbsolutePath('./unknown/file')],\n\t\t});\n\t}, {code: 'ENOENT'});\n\tt.false(await pathExists(filePath));\n\tt.is(stdout, foobarUppercase);\n});\n"
  },
  {
    "path": "test/stdio/file-path-main.js",
    "content": "import {readFile, writeFile, rm} from 'node:fs/promises';\nimport path from 'node:path';\nimport process from 'node:process';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {identity, getStdio} from '../helpers/stdio.js';\nimport {\n\trunExeca,\n\trunExecaSync,\n\trunScript,\n\trunScriptSync,\n} from '../helpers/run.js';\nimport {foobarString, foobarUint8Array} from '../helpers/input.js';\nimport {getAbsolutePath, getRelativePath} from '../helpers/file-path.js';\n\nsetFixtureDirectory();\n\nconst getStdioInput = (fdNumberOrName, file) => {\n\tif (fdNumberOrName === 'string') {\n\t\treturn {input: foobarString};\n\t}\n\n\tif (fdNumberOrName === 'binary') {\n\t\treturn {input: foobarUint8Array};\n\t}\n\n\treturn getStdioInputFile(fdNumberOrName, file);\n};\n\nconst getStdioInputFile = (fdNumberOrName, file) => getStdio(fdNumberOrName, typeof fdNumberOrName === 'string' ? file : {file});\n\nconst testStdinFile = async (t, mapFilePath, fdNumber, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst {stdout} = await execaMethod('stdin.js', getStdio(fdNumber, mapFilePath(filePath)));\n\tt.is(stdout, foobarString);\n\tawait rm(filePath);\n};\n\ntest('inputFile can be a file URL', testStdinFile, pathToFileURL, 'inputFile', execa);\ntest('stdin can be a file URL', testStdinFile, pathToFileURL, 0, execa);\ntest('inputFile can be an absolute file path', testStdinFile, identity, 'inputFile', execa);\ntest('stdin can be an absolute file path', testStdinFile, getAbsolutePath, 0, execa);\ntest('inputFile can be a relative file path', testStdinFile, identity, 'inputFile', execa);\ntest('stdin can be a relative file path', testStdinFile, getRelativePath, 0, execa);\ntest('inputFile can be a file URL - sync', testStdinFile, pathToFileURL, 'inputFile', execaSync);\ntest('stdin can be a file URL - sync', testStdinFile, pathToFileURL, 0, execaSync);\ntest('inputFile can be an absolute file path - sync', testStdinFile, identity, 'inputFile', execaSync);\ntest('stdin can be an absolute file path - sync', testStdinFile, getAbsolutePath, 0, execaSync);\ntest('inputFile can be a relative file path - sync', testStdinFile, identity, 'inputFile', execaSync);\ntest('stdin can be a relative file path - sync', testStdinFile, getRelativePath, 0, execaSync);\n\nconst testOutputFile = async (t, mapFile, fdNumber, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, mapFile(filePath)));\n\tt.is(await readFile(filePath, 'utf8'), foobarString);\n\tawait rm(filePath);\n};\n\ntest('stdout can be a file URL', testOutputFile, pathToFileURL, 1, execa);\ntest('stderr can be a file URL', testOutputFile, pathToFileURL, 2, execa);\ntest('stdio[*] can be a file URL', testOutputFile, pathToFileURL, 3, execa);\ntest('stdout can be an absolute file path', testOutputFile, getAbsolutePath, 1, execa);\ntest('stderr can be an absolute file path', testOutputFile, getAbsolutePath, 2, execa);\ntest('stdio[*] can be an absolute file path', testOutputFile, getAbsolutePath, 3, execa);\ntest('stdout can be a relative file path', testOutputFile, getRelativePath, 1, execa);\ntest('stderr can be a relative file path', testOutputFile, getRelativePath, 2, execa);\ntest('stdio[*] can be a relative file path', testOutputFile, getRelativePath, 3, execa);\ntest('stdout can be a file URL - sync', testOutputFile, pathToFileURL, 1, execaSync);\ntest('stderr can be a file URL - sync', testOutputFile, pathToFileURL, 2, execaSync);\ntest('stdio[*] can be a file URL - sync', testOutputFile, pathToFileURL, 3, execaSync);\ntest('stdout can be an absolute file path - sync', testOutputFile, getAbsolutePath, 1, execaSync);\ntest('stderr can be an absolute file path - sync', testOutputFile, getAbsolutePath, 2, execaSync);\ntest('stdio[*] can be an absolute file path - sync', testOutputFile, getAbsolutePath, 3, execaSync);\ntest('stdout can be a relative file path - sync', testOutputFile, getRelativePath, 1, execaSync);\ntest('stderr can be a relative file path - sync', testOutputFile, getRelativePath, 2, execaSync);\ntest('stdio[*] can be a relative file path - sync', testOutputFile, getRelativePath, 3, execaSync);\n\nconst testInputFileValidUrl = async (t, fdNumber, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst currentCwd = process.cwd();\n\tprocess.chdir(path.dirname(filePath));\n\n\ttry {\n\t\tconst {stdout} = await execaMethod('stdin.js', getStdioInputFile(fdNumber, path.basename(filePath)));\n\t\tt.is(stdout, foobarString);\n\t} finally {\n\t\tprocess.chdir(currentCwd);\n\t\tawait rm(filePath);\n\t}\n};\n\ntest.serial('inputFile does not need to start with . when being a relative file path', testInputFileValidUrl, 'inputFile', execa);\ntest.serial('stdin does not need to start with . when being a relative file path', testInputFileValidUrl, 0, execa);\ntest.serial('inputFile does not need to start with . when being a relative file path - sync', testInputFileValidUrl, 'inputFile', execaSync);\ntest.serial('stdin does not need to start with . when being a relative file path - sync', testInputFileValidUrl, 0, execaSync);\n\nconst testMultipleInputs = async (t, indices, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst options = Object.assign({}, ...indices.map(fdNumber => getStdioInput(fdNumber, filePath)));\n\tconst {stdout} = await execaMethod('stdin.js', options);\n\tt.is(stdout, foobarString.repeat(indices.length));\n\tawait rm(filePath);\n};\n\ntest('inputFile can be set', testMultipleInputs, ['inputFile'], runExeca);\ntest('inputFile can be set - sync', testMultipleInputs, ['inputFile'], runExecaSync);\ntest('inputFile can be set with $', testMultipleInputs, ['inputFile'], runScript);\ntest('inputFile can be set with $.sync', testMultipleInputs, ['inputFile'], runScriptSync);\ntest('input String and inputFile can be both set', testMultipleInputs, ['inputFile', 'string'], execa);\ntest('input String and stdin can be both set', testMultipleInputs, [0, 'string'], execa);\ntest('input Uint8Array and inputFile can be both set', testMultipleInputs, ['inputFile', 'binary'], execa);\ntest('input Uint8Array and stdin can be both set', testMultipleInputs, [0, 'binary'], execa);\ntest('stdin and inputFile can be both set', testMultipleInputs, [0, 'inputFile'], execa);\ntest('input String, stdin and inputFile can be all set', testMultipleInputs, ['inputFile', 0, 'string'], execa);\ntest('input Uint8Array, stdin and inputFile can be all set', testMultipleInputs, ['inputFile', 0, 'binary'], execa);\ntest('input String and inputFile can be both set - sync', testMultipleInputs, ['inputFile', 'string'], execaSync);\ntest('input String and stdin can be both set - sync', testMultipleInputs, [0, 'string'], execaSync);\ntest('input Uint8Array and inputFile can be both set - sync', testMultipleInputs, ['inputFile', 'binary'], execaSync);\ntest('input Uint8Array and stdin can be both set - sync', testMultipleInputs, [0, 'binary'], execaSync);\ntest('stdin and inputFile can be both set - sync', testMultipleInputs, [0, 'inputFile'], execaSync);\ntest('input String, stdin and inputFile can be all set - sync', testMultipleInputs, ['inputFile', 0, 'string'], execaSync);\ntest('input Uint8Array, stdin and inputFile can be all set - sync', testMultipleInputs, ['inputFile', 0, 'binary'], execaSync);\n\nconst testMultipleOutputs = async (t, mapFile, fdNumber, execaMethod) => {\n\tconst filePath = tempfile();\n\tconst filePathTwo = tempfile();\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [mapFile(filePath), mapFile(filePathTwo)]));\n\tt.is(await readFile(filePath, 'utf8'), foobarString);\n\tt.is(await readFile(filePathTwo, 'utf8'), foobarString);\n\tawait Promise.all([rm(filePath), rm(filePathTwo)]);\n};\n\ntest('stdout can be two file URLs', testMultipleOutputs, pathToFileURL, 1, execa);\ntest('stdout can be two file paths', testMultipleOutputs, getAbsolutePath, 1, execa);\ntest('stdout can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 1, execaSync);\ntest('stdout can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 1, execaSync);\ntest('stderr can be two file URLs', testMultipleOutputs, pathToFileURL, 2, execa);\ntest('stderr can be two file paths', testMultipleOutputs, getAbsolutePath, 2, execa);\ntest('stderr can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 2, execaSync);\ntest('stderr can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 2, execaSync);\ntest('stdio[*] can be two file URLs', testMultipleOutputs, pathToFileURL, 3, execa);\ntest('stdio[*] can be two file paths', testMultipleOutputs, getAbsolutePath, 3, execa);\ntest('stdio[*] can be two file URLs - sync', testMultipleOutputs, pathToFileURL, 3, execaSync);\ntest('stdio[*] can be two file paths - sync', testMultipleOutputs, getAbsolutePath, 3, execaSync);\n\nconst testInputFileHanging = async (t, mapFilePath) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tawait t.throwsAsync(execa('stdin.js', {stdin: mapFilePath(filePath), timeout: 1}), {message: /timed out/});\n\tawait rm(filePath);\n};\n\ntest('Passing an input file path when subprocess exits does not make promise hang', testInputFileHanging, getAbsolutePath);\ntest('Passing an input file URL when subprocess exits does not make promise hang', testInputFileHanging, pathToFileURL);\n\nconst testOverwriteFile = async (t, fdNumber, execaMethod, append) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, '.');\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, {file: filePath, append}));\n\tt.is(await readFile(filePath, 'utf8'), foobarString);\n\tawait rm(filePath);\n};\n\ntest('Overwrite by default to stdout', testOverwriteFile, 1, execa, undefined);\ntest('Overwrite by default to stderr', testOverwriteFile, 2, execa, undefined);\ntest('Overwrite by default to stdio[*]', testOverwriteFile, 3, execa, undefined);\ntest('Overwrite by default to stdout - sync', testOverwriteFile, 1, execaSync, undefined);\ntest('Overwrite by default to stderr - sync', testOverwriteFile, 2, execaSync, undefined);\ntest('Overwrite by default to stdio[*] - sync', testOverwriteFile, 3, execaSync, undefined);\ntest('Overwrite with append false to stdout', testOverwriteFile, 1, execa, false);\ntest('Overwrite with append false to stderr', testOverwriteFile, 2, execa, false);\ntest('Overwrite with append false to stdio[*]', testOverwriteFile, 3, execa, false);\ntest('Overwrite with append false to stdout - sync', testOverwriteFile, 1, execaSync, false);\ntest('Overwrite with append false to stderr - sync', testOverwriteFile, 2, execaSync, false);\ntest('Overwrite with append false to stdio[*] - sync', testOverwriteFile, 3, execaSync, false);\n\nconst testAppendFile = async (t, fdNumber, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, '.');\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, {file: filePath, append: true}));\n\tt.is(await readFile(filePath, 'utf8'), `.${foobarString}`);\n\tawait rm(filePath);\n};\n\ntest('Can append to stdout', testAppendFile, 1, execa);\ntest('Can append to stderr', testAppendFile, 2, execa);\ntest('Can append to stdio[*]', testAppendFile, 3, execa);\ntest('Can append to stdout - sync', testAppendFile, 1, execaSync);\ntest('Can append to stderr - sync', testAppendFile, 2, execaSync);\ntest('Can append to stdio[*] - sync', testAppendFile, 3, execaSync);\n"
  },
  {
    "path": "test/stdio/file-path-mixed.js",
    "content": "import {readFile, writeFile, rm} from 'node:fs/promises';\nimport {pathToFileURL} from 'node:url';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {foobarString, foobarUppercase} from '../helpers/input.js';\nimport {uppercaseGenerator} from '../helpers/generator.js';\nimport {getAbsolutePath} from '../helpers/file-path.js';\n\nsetFixtureDirectory();\n\nconst testInputFileTransform = async (t, fdNumber, mapFile, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [\n\t\tnew Uint8Array(),\n\t\tmapFile(filePath),\n\t\tuppercaseGenerator(),\n\t]));\n\tt.is(stdout, foobarUppercase);\n\tawait rm(filePath);\n};\n\ntest('stdin can use generators together with input file paths', testInputFileTransform, 0, getAbsolutePath, execa);\ntest('stdin can use generators together with input file URLs', testInputFileTransform, 0, pathToFileURL, execa);\ntest('stdio[*] can use generators together with input file paths', testInputFileTransform, 3, getAbsolutePath, execa);\ntest('stdio[*] can use generators together with input file URLs', testInputFileTransform, 3, pathToFileURL, execa);\ntest('stdin can use generators together with input file paths, sync', testInputFileTransform, 0, getAbsolutePath, execaSync);\ntest('stdin can use generators together with input file URLs, sync', testInputFileTransform, 0, pathToFileURL, execaSync);\n\nconst testOutputFileTransform = async (t, fdNumber, mapFile, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [\n\t\tuppercaseGenerator(),\n\t\tmapFile(filePath),\n\t]));\n\tt.is(await readFile(filePath, 'utf8'), `${foobarUppercase}\\n`);\n\tawait rm(filePath);\n};\n\ntest('stdout can use generators together with output file paths', testOutputFileTransform, 1, getAbsolutePath, execa);\ntest('stdout can use generators together with output file URLs', testOutputFileTransform, 1, pathToFileURL, execa);\ntest('stderr can use generators together with output file paths', testOutputFileTransform, 2, getAbsolutePath, execa);\ntest('stderr can use generators together with output file URLs', testOutputFileTransform, 2, pathToFileURL, execa);\ntest('stdio[*] can use generators together with output file paths', testOutputFileTransform, 3, getAbsolutePath, execa);\ntest('stdio[*] can use generators together with output file URLs', testOutputFileTransform, 3, pathToFileURL, execa);\ntest('stdout can use generators together with output file paths, sync', testOutputFileTransform, 1, getAbsolutePath, execaSync);\ntest('stdout can use generators together with output file URLs, sync', testOutputFileTransform, 1, pathToFileURL, execaSync);\ntest('stderr can use generators together with output file paths, sync', testOutputFileTransform, 2, getAbsolutePath, execaSync);\ntest('stderr can use generators together with output file URLs, sync', testOutputFileTransform, 2, pathToFileURL, execaSync);\ntest('stdio[*] can use generators together with output file paths, sync', testOutputFileTransform, 3, getAbsolutePath, execaSync);\ntest('stdio[*] can use generators together with output file URLs, sync', testOutputFileTransform, 3, pathToFileURL, execaSync);\n\nconst testOutputFileLines = async (t, fdNumber, mapFile, execaMethod) => {\n\tconst filePath = tempfile();\n\tconst {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, foobarString], {\n\t\t...getStdio(fdNumber, mapFile(filePath)),\n\t\tlines: true,\n\t});\n\tt.deepEqual(stdio[fdNumber], [foobarString]);\n\tt.is(await readFile(filePath, 'utf8'), foobarString);\n\tawait rm(filePath);\n};\n\ntest('stdout can use \"lines: true\" together with output file paths', testOutputFileLines, 1, getAbsolutePath, execa);\ntest('stdout can use \"lines: true\" together with output file URLs', testOutputFileLines, 1, pathToFileURL, execa);\ntest('stderr can use \"lines: true\" together with output file paths', testOutputFileLines, 2, getAbsolutePath, execa);\ntest('stderr can use \"lines: true\" together with output file URLs', testOutputFileLines, 2, pathToFileURL, execa);\ntest('stdio[*] can use \"lines: true\" together with output file paths', testOutputFileLines, 3, getAbsolutePath, execa);\ntest('stdio[*] can use \"lines: true\" together with output file URLs', testOutputFileLines, 3, pathToFileURL, execa);\ntest('stdout can use \"lines: true\" together with output file paths, sync', testOutputFileLines, 1, getAbsolutePath, execaSync);\ntest('stdout can use \"lines: true\" together with output file URLs, sync', testOutputFileLines, 1, pathToFileURL, execaSync);\ntest('stderr can use \"lines: true\" together with output file paths, sync', testOutputFileLines, 2, getAbsolutePath, execaSync);\ntest('stderr can use \"lines: true\" together with output file URLs, sync', testOutputFileLines, 2, pathToFileURL, execaSync);\ntest('stdio[*] can use \"lines: true\" together with output file paths, sync', testOutputFileLines, 3, getAbsolutePath, execaSync);\ntest('stdio[*] can use \"lines: true\" together with output file URLs, sync', testOutputFileLines, 3, pathToFileURL, execaSync);\n\nconst testOutputFileNoBuffer = async (t, buffer, execaMethod) => {\n\tconst filePath = tempfile();\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {\n\t\tstdout: getAbsolutePath(filePath),\n\t\tbuffer,\n\t});\n\tt.is(stdout, undefined);\n\tt.is(await readFile(filePath, 'utf8'), foobarString);\n\tawait rm(filePath);\n};\n\ntest('stdout can use \"buffer: false\" together with output file paths', testOutputFileNoBuffer, false, execa);\ntest('stdout can use \"buffer: false\" together with output file paths, fd-specific', testOutputFileNoBuffer, {stdout: false}, execa);\ntest('stdout can use \"buffer: false\" together with output file paths, sync', testOutputFileNoBuffer, false, execaSync);\ntest('stdout can use \"buffer: false\" together with output file paths, fd-specific, sync', testOutputFileNoBuffer, {stdout: false}, execaSync);\n"
  },
  {
    "path": "test/stdio/handle-invalid.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst testEmptyArray = (t, fdNumber, optionName, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, []));\n\t}, {message: `The \\`${optionName}\\` option must not be an empty array.`});\n};\n\ntest('Cannot pass an empty array to stdin', testEmptyArray, 0, 'stdin', execa);\ntest('Cannot pass an empty array to stdout', testEmptyArray, 1, 'stdout', execa);\ntest('Cannot pass an empty array to stderr', testEmptyArray, 2, 'stderr', execa);\ntest('Cannot pass an empty array to stdio[*]', testEmptyArray, 3, 'stdio[3]', execa);\ntest('Cannot pass an empty array to stdin - sync', testEmptyArray, 0, 'stdin', execaSync);\ntest('Cannot pass an empty array to stdout - sync', testEmptyArray, 1, 'stdout', execaSync);\ntest('Cannot pass an empty array to stderr - sync', testEmptyArray, 2, 'stderr', execaSync);\ntest('Cannot pass an empty array to stdio[*] - sync', testEmptyArray, 3, 'stdio[3]', execaSync);\n\nconst testInvalidValueSync = (t, fdNumber, stdioOption) => {\n\tconst {message} = t.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, stdioOption));\n\t});\n\tt.true(message.includes(`cannot be \"${stdioOption}\" with synchronous methods`));\n};\n\ntest('stdin cannot be \"ipc\", sync', testInvalidValueSync, 0, 'ipc');\ntest('stdout cannot be \"ipc\", sync', testInvalidValueSync, 1, 'ipc');\ntest('stderr cannot be \"ipc\", sync', testInvalidValueSync, 2, 'ipc');\ntest('stdio[*] cannot be \"ipc\", sync', testInvalidValueSync, 3, 'ipc');\ntest('stdin cannot be \"overlapped\", sync', testInvalidValueSync, 0, 'overlapped');\ntest('stdout cannot be \"overlapped\", sync', testInvalidValueSync, 1, 'overlapped');\ntest('stderr cannot be \"overlapped\", sync', testInvalidValueSync, 2, 'overlapped');\ntest('stdio[*] cannot be \"overlapped\", sync', testInvalidValueSync, 3, 'overlapped');\n\nconst testInvalidArrayValue = (t, invalidStdio, fdNumber, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, ['pipe', invalidStdio]));\n\t}, {message: /must not include/});\n};\n\ntest('Cannot pass \"ignore\" and another value to stdin', testInvalidArrayValue, 'ignore', 0, execa);\ntest('Cannot pass \"ignore\" and another value to stdout', testInvalidArrayValue, 'ignore', 1, execa);\ntest('Cannot pass \"ignore\" and another value to stderr', testInvalidArrayValue, 'ignore', 2, execa);\ntest('Cannot pass \"ignore\" and another value to stdio[*]', testInvalidArrayValue, 'ignore', 3, execa);\ntest('Cannot pass \"ignore\" and another value to stdin - sync', testInvalidArrayValue, 'ignore', 0, execaSync);\ntest('Cannot pass \"ignore\" and another value to stdout - sync', testInvalidArrayValue, 'ignore', 1, execaSync);\ntest('Cannot pass \"ignore\" and another value to stderr - sync', testInvalidArrayValue, 'ignore', 2, execaSync);\ntest('Cannot pass \"ignore\" and another value to stdio[*] - sync', testInvalidArrayValue, 'ignore', 3, execaSync);\ntest('Cannot pass \"ipc\" and another value to stdin', testInvalidArrayValue, 'ipc', 0, execa);\ntest('Cannot pass \"ipc\" and another value to stdout', testInvalidArrayValue, 'ipc', 1, execa);\ntest('Cannot pass \"ipc\" and another value to stderr', testInvalidArrayValue, 'ipc', 2, execa);\ntest('Cannot pass \"ipc\" and another value to stdio[*]', testInvalidArrayValue, 'ipc', 3, execa);\ntest('Cannot pass \"ipc\" and another value to stdin - sync', testInvalidArrayValue, 'ipc', 0, execaSync);\ntest('Cannot pass \"ipc\" and another value to stdout - sync', testInvalidArrayValue, 'ipc', 1, execaSync);\ntest('Cannot pass \"ipc\" and another value to stderr - sync', testInvalidArrayValue, 'ipc', 2, execaSync);\ntest('Cannot pass \"ipc\" and another value to stdio[*] - sync', testInvalidArrayValue, 'ipc', 3, execaSync);\n"
  },
  {
    "path": "test/stdio/handle-normal.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUint8Array} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testInputOverlapped = async (t, fdNumber) => {\n\tconst {stdout} = await execa('stdin-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, [foobarUint8Array, 'overlapped', 'pipe']));\n\tt.is(stdout, foobarString);\n};\n\ntest('stdin can be [\"overlapped\", \"pipe\"]', testInputOverlapped, 0);\ntest('stdio[*] input can be [\"overlapped\", \"pipe\"]', testInputOverlapped, 3);\n\nconst testOutputOverlapped = async (t, fdNumber) => {\n\tconst {stdio} = await execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, ['overlapped', 'pipe']));\n\tt.is(stdio[fdNumber], foobarString);\n};\n\ntest('stdout can be [\"overlapped\", \"pipe\"]', testOutputOverlapped, 1);\ntest('stderr can be [\"overlapped\", \"pipe\"]', testOutputOverlapped, 2);\ntest('stdio[*] output can be [\"overlapped\", \"pipe\"]', testOutputOverlapped, 3);\n\nconst testFd3Undefined = async (t, stdioOption, options) => {\n\tconst subprocess = execa('empty.js', {...getStdio(3, stdioOption), ...options});\n\tt.is(subprocess.stdio.length, 4);\n\tt.is(subprocess.stdio[3], null);\n\n\tconst {stdio} = await subprocess;\n\tt.is(stdio.length, 4);\n\tt.is(stdio[3], undefined);\n};\n\ntest('stdio[*] undefined means \"ignore\"', testFd3Undefined, undefined, {});\ntest('stdio[*] null means \"ignore\"', testFd3Undefined, null, {});\ntest('stdio[*] [undefined] means \"ignore\"', testFd3Undefined, [undefined], {});\ntest('stdio[*] [null] means \"ignore\"', testFd3Undefined, [null], {});\ntest('stdio[*] undefined means \"ignore\", \"lines: true\"', testFd3Undefined, undefined, {lines: true});\ntest('stdio[*] null means \"ignore\", \"lines: true\"', testFd3Undefined, null, {lines: true});\ntest('stdio[*] [undefined] means \"ignore\", \"lines: true\"', testFd3Undefined, [undefined], {lines: true});\ntest('stdio[*] [null] means \"ignore\", \"lines: true\"', testFd3Undefined, [null], {lines: true});\ntest('stdio[*] undefined means \"ignore\", \"encoding: hex\"', testFd3Undefined, undefined, {encoding: 'hex'});\ntest('stdio[*] null means \"ignore\", \"encoding: hex\"', testFd3Undefined, null, {encoding: 'hex'});\ntest('stdio[*] [undefined] means \"ignore\", \"encoding: hex\"', testFd3Undefined, [undefined], {encoding: 'hex'});\ntest('stdio[*] [null] means \"ignore\", \"encoding: hex\"', testFd3Undefined, [null], {encoding: 'hex'});\n"
  },
  {
    "path": "test/stdio/handle-options.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst testNoPipeOption = async (t, stdioOption, fdNumber) => {\n\tconst subprocess = execa('empty.js', getStdio(fdNumber, stdioOption));\n\tt.is(subprocess.stdio[fdNumber], null);\n\tawait subprocess;\n};\n\ntest('stdin can be \"ignore\"', testNoPipeOption, 'ignore', 0);\ntest('stdin can be [\"ignore\"]', testNoPipeOption, ['ignore'], 0);\ntest('stdin can be [\"ignore\", \"ignore\"]', testNoPipeOption, ['ignore', 'ignore'], 0);\ntest('stdin can be \"ipc\"', testNoPipeOption, 'ipc', 0);\ntest('stdin can be [\"ipc\"]', testNoPipeOption, ['ipc'], 0);\ntest('stdin can be \"inherit\"', testNoPipeOption, 'inherit', 0);\ntest('stdin can be [\"inherit\"]', testNoPipeOption, ['inherit'], 0);\ntest('stdin can be 0', testNoPipeOption, 0, 0);\ntest('stdin can be [0]', testNoPipeOption, [0], 0);\ntest('stdout can be \"ignore\"', testNoPipeOption, 'ignore', 1);\ntest('stdout can be [\"ignore\"]', testNoPipeOption, ['ignore'], 1);\ntest('stdout can be [\"ignore\", \"ignore\"]', testNoPipeOption, ['ignore', 'ignore'], 1);\ntest('stdout can be \"ipc\"', testNoPipeOption, 'ipc', 1);\ntest('stdout can be [\"ipc\"]', testNoPipeOption, ['ipc'], 1);\ntest('stdout can be \"inherit\"', testNoPipeOption, 'inherit', 1);\ntest('stdout can be [\"inherit\"]', testNoPipeOption, ['inherit'], 1);\ntest('stdout can be 1', testNoPipeOption, 1, 1);\ntest('stdout can be [1]', testNoPipeOption, [1], 1);\ntest('stderr can be \"ignore\"', testNoPipeOption, 'ignore', 2);\ntest('stderr can be [\"ignore\"]', testNoPipeOption, ['ignore'], 2);\ntest('stderr can be [\"ignore\", \"ignore\"]', testNoPipeOption, ['ignore', 'ignore'], 2);\ntest('stderr can be \"ipc\"', testNoPipeOption, 'ipc', 2);\ntest('stderr can be [\"ipc\"]', testNoPipeOption, ['ipc'], 2);\ntest('stderr can be \"inherit\"', testNoPipeOption, 'inherit', 2);\ntest('stderr can be [\"inherit\"]', testNoPipeOption, ['inherit'], 2);\ntest('stderr can be 2', testNoPipeOption, 2, 2);\ntest('stderr can be [2]', testNoPipeOption, [2], 2);\ntest('stdio[*] can be \"ignore\"', testNoPipeOption, 'ignore', 3);\ntest('stdio[*] can be [\"ignore\"]', testNoPipeOption, ['ignore'], 3);\ntest('stdio[*] can be [\"ignore\", \"ignore\"]', testNoPipeOption, ['ignore', 'ignore'], 3);\ntest('stdio[*] can be \"ipc\"', testNoPipeOption, 'ipc', 3);\ntest('stdio[*] can be [\"ipc\"]', testNoPipeOption, ['ipc'], 3);\ntest('stdio[*] can be \"inherit\"', testNoPipeOption, 'inherit', 3);\ntest('stdio[*] can be [\"inherit\"]', testNoPipeOption, ['inherit'], 3);\ntest('stdio[*] can be 3', testNoPipeOption, 3, 3);\ntest('stdio[*] can be [3]', testNoPipeOption, [3], 3);\n"
  },
  {
    "path": "test/stdio/iterable.js",
    "content": "import {once} from 'node:events';\nimport {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {\n\tfoobarString,\n\tfoobarObject,\n\tfoobarObjectString,\n\tfoobarArray,\n} from '../helpers/input.js';\nimport {\n\tnoopGenerator,\n\tserializeGenerator,\n\tinfiniteGenerator,\n\tthrowingGenerator,\n} from '../helpers/generator.js';\n\nconst stringGenerator = function * () {\n\tyield * foobarArray;\n};\n\nconst textEncoder = new TextEncoder();\nconst binaryFoo = textEncoder.encode('foo');\nconst binaryBar = textEncoder.encode('bar');\nconst binaryArray = [binaryFoo, binaryBar];\n\nconst binaryGenerator = function * () {\n\tyield * binaryArray;\n};\n\nconst mixedArray = [foobarArray[0], binaryArray[1]];\n\nconst mixedGenerator = function * () {\n\tyield * mixedArray;\n};\n\nconst asyncGenerator = async function * () {\n\tawait setImmediate();\n\tyield * foobarArray;\n};\n\nsetFixtureDirectory();\n\nconst testIterable = async (t, stdioOption, fdNumber, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));\n\tt.is(stdout, 'foobar');\n};\n\ntest.serial('stdin option can be an array of strings', testIterable, [foobarArray], 0, execa);\ntest.serial('stdin option can be an array of strings - sync', testIterable, [foobarArray], 0, execaSync);\ntest.serial('stdio[*] option can be an array of strings', testIterable, [foobarArray], 3, execa);\ntest.serial('stdin option can be an array of Uint8Arrays', testIterable, [binaryArray], 0, execa);\ntest.serial('stdin option can be an array of Uint8Arrays - sync', testIterable, [binaryArray], 0, execaSync);\ntest.serial('stdio[*] option can be an array of Uint8Arrays', testIterable, [binaryArray], 3, execa);\ntest.serial('stdin option can be an iterable of strings', testIterable, stringGenerator(), 0, execa);\ntest.serial('stdin option can be an iterable of strings - sync', testIterable, stringGenerator(), 0, execaSync);\ntest.serial('stdio[*] option can be an iterable of strings', testIterable, stringGenerator(), 3, execa);\ntest.serial('stdin option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 0, execa);\ntest.serial('stdin option can be an iterable of Uint8Arrays - sync', testIterable, binaryGenerator(), 0, execaSync);\ntest.serial('stdio[*] option can be an iterable of Uint8Arrays', testIterable, binaryGenerator(), 3, execa);\ntest.serial('stdin option can be an iterable of strings + Uint8Arrays', testIterable, mixedGenerator(), 0, execa);\ntest.serial('stdin option can be an iterable of strings + Uint8Arrays - sync', testIterable, mixedGenerator(), 0, execaSync);\ntest.serial('stdio[*] option can be an iterable of strings + Uint8Arrays', testIterable, mixedGenerator(), 3, execa);\ntest.serial('stdin option can be an async iterable', testIterable, asyncGenerator(), 0, execa);\ntest.serial('stdio[*] option can be an async iterable', testIterable, asyncGenerator(), 3, execa);\n\nconst foobarObjectGenerator = function * () {\n\tyield foobarObject;\n};\n\nconst foobarAsyncObjectGenerator = async function * () {\n\tyield foobarObject;\n};\n\nconst testObjectIterable = async (t, stdioOption, fdNumber, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stdioOption, serializeGenerator(true)]));\n\tt.is(stdout, foobarObjectString);\n};\n\ntest('stdin option can be an array of objects', testObjectIterable, [foobarObject], 0, execa);\ntest('stdio[*] option can be an array of objects', testObjectIterable, [foobarObject], 3, execa);\ntest('stdin option can be an iterable of objects', testObjectIterable, foobarObjectGenerator(), 0, execa);\ntest('stdio[*] option can be an iterable of objects', testObjectIterable, foobarObjectGenerator(), 3, execa);\ntest('stdin option can be an async iterable of objects', testObjectIterable, foobarAsyncObjectGenerator(), 0, execa);\ntest('stdio[*] option can be an async iterable of objects', testObjectIterable, foobarAsyncObjectGenerator(), 3, execa);\ntest('stdin option can be an array of objects - sync', testObjectIterable, [foobarObject], 0, execaSync);\ntest('stdin option can be an iterable of objects - sync', testObjectIterable, foobarObjectGenerator(), 0, execaSync);\n\nconst testIterableNoGeneratorsSync = (t, stdioOption, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, stdioOption));\n\t}, {message: /must be used to serialize/});\n};\n\ntest('stdin option cannot be an array of objects without generators - sync', testIterableNoGeneratorsSync, [[foobarObject]], 0);\ntest('stdin option cannot be an iterable of objects without generators - sync', testIterableNoGeneratorsSync, foobarObjectGenerator(), 0);\n\nconst testIterableNoSerializeSync = (t, stdioOption, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, [stdioOption, noopGenerator()]));\n\t}, {message: /The `stdin` option's transform must use \"objectMode: true\" to receive as input: object/});\n};\n\ntest('stdin option cannot be an array of objects without serializing - sync', testIterableNoSerializeSync, [foobarObject], 0);\ntest('stdin option cannot be an iterable of objects without serializing - sync', testIterableNoSerializeSync, foobarObjectGenerator(), 0);\n\nconst testIterableSync = (t, stdioOption, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, stdioOption));\n\t}, {message: /an iterable with synchronous methods/});\n};\n\ntest('stdio[*] option cannot be an array of strings - sync', testIterableSync, [foobarArray], 3);\ntest('stdio[*] option cannot be an array of Uint8Arrays - sync', testIterableSync, [binaryArray], 3);\ntest('stdio[*] option cannot be an array of objects - sync', testIterableSync, [[foobarObject]], 3);\ntest('stdio[*] option cannot be an iterable of strings - sync', testIterableSync, stringGenerator(), 3);\ntest('stdio[*] option cannot be an iterable of Uint8Arrays - sync', testIterableSync, binaryGenerator(), 3);\ntest('stdio[*] option cannot be an iterable of objects - sync', testIterableSync, foobarObjectGenerator(), 3);\ntest('stdio[*] option cannot be multiple iterables - sync', testIterableSync, [stringGenerator(), stringGenerator()], 3);\n\nconst testAsyncIterableSync = (t, stdioOption, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, stdioOption));\n\t}, {message: /an async iterable with synchronous method/});\n};\n\ntest('stdin option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 0);\ntest('stdio[*] option cannot be an async iterable - sync', testAsyncIterableSync, asyncGenerator(), 3);\ntest('stdin option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 0);\ntest('stdio[*] option cannot be an async iterable of objects - sync', testAsyncIterableSync, foobarAsyncObjectGenerator(), 3);\n\nconst testIterableError = async (t, fdNumber) => {\n\tconst cause = new Error(foobarString);\n\tconst error = await t.throwsAsync(execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator(cause)().transform())));\n\tt.is(error.cause, cause);\n};\n\ntest('stdin option handles errors in iterables', testIterableError, 0);\ntest('stdio[*] option handles errors in iterables', testIterableError, 3);\n\nconst testIterableErrorSync = (t, fdNumber) => {\n\tconst cause = new Error(foobarString);\n\tconst error = t.throws(() => {\n\t\texecaSync('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, throwingGenerator(cause)().transform()));\n\t});\n\tt.is(error, cause);\n};\n\ntest('stdin option handles errors in iterables - sync', testIterableErrorSync, 0);\ntest('stdio[*] option handles errors in iterables - sync', testIterableErrorSync, 3);\n\nconst testNoIterableOutput = (t, stdioOption, fdNumber, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, stdioOption));\n\t}, {message: /cannot be an iterable/});\n};\n\ntest('stdout option cannot be an array of strings', testNoIterableOutput, [foobarArray], 1, execa);\ntest('stderr option cannot be an array of strings', testNoIterableOutput, [foobarArray], 2, execa);\ntest('stdout option cannot be an array of strings - sync', testNoIterableOutput, [foobarArray], 1, execaSync);\ntest('stderr option cannot be an array of strings - sync', testNoIterableOutput, [foobarArray], 2, execaSync);\ntest('stdout option cannot be an iterable', testNoIterableOutput, stringGenerator(), 1, execa);\ntest('stderr option cannot be an iterable', testNoIterableOutput, stringGenerator(), 2, execa);\ntest('stdout option cannot be an iterable - sync', testNoIterableOutput, stringGenerator(), 1, execaSync);\ntest('stderr option cannot be an iterable - sync', testNoIterableOutput, stringGenerator(), 2, execaSync);\n\ntest('stdin option can be an infinite iterable', async t => {\n\tconst iterable = infiniteGenerator().transform();\n\tconst subprocess = execa('stdin.js', getStdio(0, iterable));\n\tawait once(subprocess.stdout, 'data');\n\tsubprocess.kill();\n\tconst {stdout} = await t.throwsAsync(subprocess);\n\tt.true(stdout.startsWith('foo'));\n\tt.deepEqual(await iterable.next(), {value: undefined, done: true});\n});\n\nconst testMultipleIterable = async (t, stdioOption, fdNumber, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));\n\tconst expectedOutputs = [\n\t\t`${foobarArray[0]}${foobarArray[1]}${foobarArray[0]}${foobarArray[1]}`,\n\t\t`${foobarArray[0]}${foobarArray[0]}${foobarArray[1]}${foobarArray[1]}`,\n\t];\n\tt.true(expectedOutputs.includes(stdout));\n};\n\ntest('stdin option can be multiple iterables', testMultipleIterable, [stringGenerator(), stringGenerator()], 0, execa);\ntest('stdio[*] option can be multiple iterables', testMultipleIterable, [stringGenerator(), stringGenerator()], 3, execa);\ntest('stdin option can be multiple iterables - sync', testMultipleIterable, [stringGenerator(), stringGenerator()], 0, execaSync);\ntest('stdin option can be multiple mixed iterables', testMultipleIterable, [stringGenerator(), binaryGenerator()], 0, execa);\ntest('stdio[*] option can be multiple mixed iterables', testMultipleIterable, [stringGenerator(), binaryGenerator()], 3, execa);\ntest('stdin option can be multiple mixed iterables - sync', testMultipleIterable, [stringGenerator(), binaryGenerator()], 0, execaSync);\ntest('stdin option can be sync/async mixed iterables', testMultipleIterable, [stringGenerator(), asyncGenerator()], 0, execa);\ntest('stdio[*] option can be sync/async mixed iterables', testMultipleIterable, [stringGenerator(), asyncGenerator()], 3, execa);\n\ntest('stdin option iterable is canceled on subprocess error', async t => {\n\tconst iterable = infiniteGenerator().transform();\n\tawait t.throwsAsync(execa('stdin.js', {stdin: iterable, timeout: 1}), {message: /timed out/});\n\t// eslint-disable-next-line no-empty\n\tfor await (const _ of iterable) {}\n});\n"
  },
  {
    "path": "test/stdio/lines-main.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {getOutputsGenerator} from '../helpers/generator.js';\nimport {foobarString} from '../helpers/input.js';\nimport {\n\tsimpleFull,\n\tsimpleChunks,\n\tsimpleFullEndChunks,\n\tsimpleLines,\n\tsimpleFullEndLines,\n\tnoNewlinesChunks,\n\tgetSimpleChunkSubprocessAsync,\n} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testStreamLines = async (t, fdNumber, input, expectedOutput, lines, stripFinalNewline, execaMethod) => {\n\tconst {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, input], {...fullStdio, lines, stripFinalNewline});\n\tt.deepEqual(stdio[fdNumber], expectedOutput);\n};\n\ntest('\"lines: true\" splits lines, stdout', testStreamLines, 1, simpleFull, simpleLines, true, false, execa);\ntest('\"lines: true\" splits lines, stdout, fd-specific', testStreamLines, 1, simpleFull, simpleLines, {stdout: true}, false, execa);\ntest('\"lines: true\" splits lines, stderr', testStreamLines, 2, simpleFull, simpleLines, true, false, execa);\ntest('\"lines: true\" splits lines, stderr, fd-specific', testStreamLines, 2, simpleFull, simpleLines, {stderr: true}, false, execa);\ntest('\"lines: true\" splits lines, stdio[*]', testStreamLines, 3, simpleFull, simpleLines, true, false, execa);\ntest('\"lines: true\" splits lines, stdio[*], fd-specific', testStreamLines, 3, simpleFull, simpleLines, {fd3: true}, false, execa);\ntest('\"lines: true\" splits lines, stdout, stripFinalNewline', testStreamLines, 1, simpleFull, noNewlinesChunks, true, true, execa);\ntest('\"lines: true\" splits lines, stdout, stripFinalNewline, fd-specific', testStreamLines, 1, simpleFull, noNewlinesChunks, true, {stdout: true}, execa);\ntest('\"lines: true\" splits lines, stderr, stripFinalNewline', testStreamLines, 2, simpleFull, noNewlinesChunks, true, true, execa);\ntest('\"lines: true\" splits lines, stderr, stripFinalNewline, fd-specific', testStreamLines, 2, simpleFull, noNewlinesChunks, true, {stderr: true}, execa);\ntest('\"lines: true\" splits lines, stdio[*], stripFinalNewline', testStreamLines, 3, simpleFull, noNewlinesChunks, true, true, execa);\ntest('\"lines: true\" splits lines, stdio[*], stripFinalNewline, fd-specific', testStreamLines, 3, simpleFull, noNewlinesChunks, true, {fd3: true}, execa);\ntest('\"lines: true\" splits lines, stdout, sync', testStreamLines, 1, simpleFull, simpleLines, true, false, execaSync);\ntest('\"lines: true\" splits lines, stdout, fd-specific, sync', testStreamLines, 1, simpleFull, simpleLines, {stdout: true}, false, execaSync);\ntest('\"lines: true\" splits lines, stderr, sync', testStreamLines, 2, simpleFull, simpleLines, true, false, execaSync);\ntest('\"lines: true\" splits lines, stderr, fd-specific, sync', testStreamLines, 2, simpleFull, simpleLines, {stderr: true}, false, execaSync);\ntest('\"lines: true\" splits lines, stdio[*], sync', testStreamLines, 3, simpleFull, simpleLines, true, false, execaSync);\ntest('\"lines: true\" splits lines, stdio[*], fd-specific, sync', testStreamLines, 3, simpleFull, simpleLines, {fd3: true}, false, execaSync);\ntest('\"lines: true\" splits lines, stdout, stripFinalNewline, sync', testStreamLines, 1, simpleFull, noNewlinesChunks, true, true, execaSync);\ntest('\"lines: true\" splits lines, stdout, stripFinalNewline, fd-specific, sync', testStreamLines, 1, simpleFull, noNewlinesChunks, true, {stdout: true}, execaSync);\ntest('\"lines: true\" splits lines, stderr, stripFinalNewline, sync', testStreamLines, 2, simpleFull, noNewlinesChunks, true, true, execaSync);\ntest('\"lines: true\" splits lines, stderr, stripFinalNewline, fd-specific, sync', testStreamLines, 2, simpleFull, noNewlinesChunks, true, {stderr: true}, execaSync);\ntest('\"lines: true\" splits lines, stdio[*], stripFinalNewline, sync', testStreamLines, 3, simpleFull, noNewlinesChunks, true, true, execaSync);\ntest('\"lines: true\" splits lines, stdio[*], stripFinalNewline, fd-specific, sync', testStreamLines, 3, simpleFull, noNewlinesChunks, true, {fd3: true}, execaSync);\n\nconst bigArray = Array.from({length: 1e5}).fill('.\\n');\nconst bigString = bigArray.join('');\nconst bigStringNoNewlines = '.'.repeat(1e6);\nconst bigStringNoNewlinesEnd = `${bigStringNoNewlines}\\n`;\n\n// eslint-disable-next-line max-params\nconst testStreamLinesGenerator = async (t, input, expectedLines, objectMode, binary, stripFinalNewline, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: getOutputsGenerator(input)(objectMode, binary),\n\t\tlines: true,\n\t\tstripFinalNewline,\n\t});\n\tt.deepEqual(stdout, expectedLines);\n};\n\ntest('\"lines: true\" works with strings generators', testStreamLinesGenerator, simpleChunks, simpleFullEndLines, false, false, false, execa);\ntest('\"lines: true\" works with strings generators, binary', testStreamLinesGenerator, simpleChunks, simpleLines, false, true, false, execa);\ntest('\"lines: true\" works with big strings generators', testStreamLinesGenerator, [bigString], bigArray, false, false, false, execa);\ntest('\"lines: true\" works with big strings generators without newlines', testStreamLinesGenerator, [bigStringNoNewlines], [bigStringNoNewlinesEnd], false, false, false, execa);\ntest('\"lines: true\" is a noop with strings generators, objectMode', testStreamLinesGenerator, simpleFullEndChunks, simpleFullEndChunks, true, false, false, execa);\ntest('\"lines: true\" is a noop with strings generators, stripFinalNewline, objectMode', testStreamLinesGenerator, simpleFullEndChunks, simpleFullEndChunks, true, false, true, execa);\ntest('\"lines: true\" is a noop with strings generators, stripFinalNewline, fd-specific, objectMode', testStreamLinesGenerator, simpleFullEndChunks, simpleFullEndChunks, true, false, {stdout: true}, execa);\ntest('\"lines: true\" is a noop with strings generators, binary, objectMode', testStreamLinesGenerator, simpleChunks, simpleChunks, true, true, false, execa);\ntest('\"lines: true\" is a noop big strings generators, objectMode', testStreamLinesGenerator, [bigString], [bigString], true, false, false, execa);\ntest('\"lines: true\" is a noop big strings generators without newlines, objectMode', testStreamLinesGenerator, [bigStringNoNewlines], [bigStringNoNewlines], true, false, false, execa);\ntest('\"lines: true\" works with strings generators, sync', testStreamLinesGenerator, simpleChunks, simpleFullEndLines, false, false, false, execaSync);\ntest('\"lines: true\" works with strings generators, binary, sync', testStreamLinesGenerator, simpleChunks, simpleLines, false, true, false, execaSync);\ntest('\"lines: true\" works with big strings generators, sync', testStreamLinesGenerator, [bigString], bigArray, false, false, false, execaSync);\ntest('\"lines: true\" works with big strings generators without newlines, sync', testStreamLinesGenerator, [bigStringNoNewlines], [bigStringNoNewlinesEnd], false, false, false, execaSync);\ntest('\"lines: true\" is a noop with strings generators, objectMode, sync', testStreamLinesGenerator, simpleFullEndChunks, simpleFullEndChunks, true, false, false, execaSync);\ntest('\"lines: true\" is a noop with strings generators, stripFinalNewline, objectMode, sync', testStreamLinesGenerator, simpleFullEndChunks, simpleFullEndChunks, true, false, true, execaSync);\ntest('\"lines: true\" is a noop with strings generators, stripFinalNewline, fd-specific, objectMode, sync', testStreamLinesGenerator, simpleFullEndChunks, simpleFullEndChunks, true, false, {stdout: true}, execaSync);\ntest('\"lines: true\" is a noop with strings generators, binary, objectMode, sync', testStreamLinesGenerator, simpleChunks, simpleChunks, true, true, false, execaSync);\ntest('\"lines: true\" is a noop big strings generators, objectMode, sync', testStreamLinesGenerator, [bigString], [bigString], true, false, false, execaSync);\ntest('\"lines: true\" is a noop big strings generators without newlines, objectMode, sync', testStreamLinesGenerator, [bigStringNoNewlines], [bigStringNoNewlines], true, false, false, execaSync);\n\ntest('\"lines: true\" stops on stream error', async t => {\n\tconst cause = new Error(foobarString);\n\tconst error = await t.throwsAsync(getSimpleChunkSubprocessAsync({\n\t\t* stdout(line) {\n\t\t\tif (line === noNewlinesChunks[2]) {\n\t\t\t\tthrow cause;\n\t\t\t}\n\n\t\t\tyield line;\n\t\t},\n\t}));\n\tt.is(error.cause, cause);\n\tt.deepEqual(error.stdout, noNewlinesChunks.slice(0, 2));\n});\n\ntest('\"lines: true\" stops on stream error event', async t => {\n\tconst cause = new Error(foobarString);\n\tconst subprocess = getSimpleChunkSubprocessAsync();\n\tsubprocess.stdout.emit('error', cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.deepEqual(error.stdout, []);\n});\n"
  },
  {
    "path": "test/stdio/lines-max-buffer.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {simpleLines, noNewlinesChunks, getSimpleChunkSubprocessAsync} from '../helpers/lines.js';\nimport {assertErrorMessage} from '../helpers/max-buffer.js';\n\nsetFixtureDirectory();\n\nconst maxBuffer = simpleLines.length - 1;\n\nconst testBelowMaxBuffer = async (t, lines) => {\n\tconst {isMaxBuffer, stdout} = await getSimpleChunkSubprocessAsync({lines, maxBuffer: maxBuffer + 1});\n\tt.false(isMaxBuffer);\n\tt.deepEqual(stdout, noNewlinesChunks);\n};\n\ntest('\"lines: true\" can be below \"maxBuffer\"', testBelowMaxBuffer, true);\ntest('\"lines: true\" can be below \"maxBuffer\", fd-specific', testBelowMaxBuffer, {stdout: true});\n\nconst testAboveMaxBuffer = async (t, lines) => {\n\tconst {isMaxBuffer, shortMessage, stdout} = await t.throwsAsync(getSimpleChunkSubprocessAsync({lines, maxBuffer}));\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage, {length: maxBuffer, unit: 'lines'});\n\tt.deepEqual(stdout, noNewlinesChunks.slice(0, maxBuffer));\n};\n\ntest('\"lines: true\" can be above \"maxBuffer\"', testAboveMaxBuffer, true);\ntest('\"lines: true\" can be above \"maxBuffer\", fd-specific', testAboveMaxBuffer, {stdout: true});\n\nconst testMaxBufferUnit = async (t, lines) => {\n\tconst {isMaxBuffer, shortMessage, stdout} = await t.throwsAsync(execa('noop-repeat.js', ['1', '...\\n'], {lines, maxBuffer}));\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage, {length: maxBuffer, unit: 'lines'});\n\tt.deepEqual(stdout, ['...', '...']);\n};\n\ntest('\"maxBuffer\" is measured in lines with \"lines: true\"', testMaxBufferUnit, true);\ntest('\"maxBuffer\" is measured in lines with \"lines: true\", fd-specific', testMaxBufferUnit, {stdout: true});\n\nconst testMaxBufferUnitSync = (t, lines) => {\n\tconst {isMaxBuffer, shortMessage, stdout} = t.throws(() => {\n\t\texecaSync('noop-repeat.js', ['1', '...\\n'], {lines, maxBuffer});\n\t}, {code: 'ENOBUFS'});\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage, {execaMethod: execaSync, length: maxBuffer});\n\tt.deepEqual(stdout, ['..']);\n};\n\ntest('\"maxBuffer\" is measured in bytes with \"lines: true\", sync', testMaxBufferUnitSync, true);\ntest('\"maxBuffer\" is measured in bytes with \"lines: true\", fd-specific, sync', testMaxBufferUnitSync, {stdout: true});\n"
  },
  {
    "path": "test/stdio/lines-mixed.js",
    "content": "import {Writable} from 'node:stream';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {assertStreamOutput, assertStreamDataEvents, assertIterableChunks} from '../helpers/convert.js';\nimport {\n\tsimpleFull,\n\tsimpleLines,\n\tnoNewlinesChunks,\n\tgetSimpleChunkSubprocessAsync,\n} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\nconst testAsyncIteration = async (t, expectedLines, stripFinalNewline) => {\n\tconst subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});\n\tt.false(subprocess.stdout.readableObjectMode);\n\tawait assertStreamOutput(t, subprocess.stdout, simpleFull);\n\tconst {stdout} = await subprocess;\n\tt.deepEqual(stdout, expectedLines);\n};\n\ntest('\"lines: true\" works with stream async iteration', testAsyncIteration, simpleLines, false);\ntest('\"lines: true\" works with stream async iteration, stripFinalNewline', testAsyncIteration, noNewlinesChunks, true);\n\nconst testDataEvents = async (t, expectedLines, stripFinalNewline) => {\n\tconst subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});\n\tawait assertStreamDataEvents(t, subprocess.stdout, simpleFull);\n\tconst {stdout} = await subprocess;\n\tt.deepEqual(stdout, expectedLines);\n};\n\ntest('\"lines: true\" works with stream \"data\" events', testDataEvents, simpleLines, false);\ntest('\"lines: true\" works with stream \"data\" events, stripFinalNewline', testDataEvents, noNewlinesChunks, true);\n\nconst testWritableStream = async (t, expectedLines, stripFinalNewline) => {\n\tlet output = '';\n\tconst writable = new Writable({\n\t\twrite(line, encoding, done) {\n\t\t\toutput += line.toString();\n\t\t\tdone();\n\t\t},\n\t\tdecodeStrings: false,\n\t});\n\tconst {stdout} = await getSimpleChunkSubprocessAsync({stripFinalNewline, stdout: ['pipe', writable]});\n\tt.deepEqual(output, simpleFull);\n\tt.deepEqual(stdout, expectedLines);\n};\n\ntest('\"lines: true\" works with writable streams targets', testWritableStream, simpleLines, false);\ntest('\"lines: true\" works with writable streams targets, stripFinalNewline', testWritableStream, noNewlinesChunks, true);\n\nconst testIterable = async (t, expectedLines, stripFinalNewline) => {\n\tconst subprocess = getSimpleChunkSubprocessAsync({stripFinalNewline});\n\tawait assertIterableChunks(t, subprocess, noNewlinesChunks);\n\tconst {stdout} = await subprocess;\n\tt.deepEqual(stdout, expectedLines);\n};\n\ntest('\"lines: true\" works with subprocess.iterable()', testIterable, simpleLines, false);\ntest('\"lines: true\" works with subprocess.iterable(), stripFinalNewline', testIterable, noNewlinesChunks, true);\n"
  },
  {
    "path": "test/stdio/lines-noop.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getOutputsGenerator} from '../helpers/generator.js';\nimport {foobarObject} from '../helpers/input.js';\nimport {\n\tsimpleFull,\n\tsimpleFullUint8Array,\n\tsimpleFullHex,\n\tsimpleFullUtf16Uint8Array,\n\tsimpleLines,\n\tnoNewlinesChunks,\n\tgetSimpleChunkSubprocess,\n} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\nconst testStreamLinesNoop = async (t, lines, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', simpleFull], {lines});\n\tt.is(stdout, simpleFull);\n};\n\ntest('\"lines: false\" is a noop', testStreamLinesNoop, false, execa);\ntest('\"lines: false\" is a noop, fd-specific', testStreamLinesNoop, {stderr: true}, execa);\ntest('\"lines: false\" is a noop, fd-specific none', testStreamLinesNoop, {}, execa);\ntest('\"lines: false\" is a noop, sync', testStreamLinesNoop, false, execaSync);\ntest('\"lines: false\" is a noop, fd-specific, sync', testStreamLinesNoop, {stderr: true}, execaSync);\ntest('\"lines: false\" is a noop, fd-specific none, sync', testStreamLinesNoop, {}, execaSync);\n\nconst testLinesObjectMode = async (t, lines, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: getOutputsGenerator([foobarObject])(true),\n\t\tlines,\n\t});\n\tt.deepEqual(stdout, [foobarObject]);\n};\n\ntest('\"lines: true\" is a noop with objects generators, objectMode', testLinesObjectMode, true, execa);\ntest('\"lines: true\" is a noop with objects generators, fd-specific, objectMode', testLinesObjectMode, {stdout: true}, execa);\ntest('\"lines: true\" is a noop with objects generators, objectMode, sync', testLinesObjectMode, true, execaSync);\ntest('\"lines: true\" is a noop with objects generators, fd-specific, objectMode, sync', testLinesObjectMode, {stdout: true}, execaSync);\n\n// eslint-disable-next-line max-params\nconst testEncoding = async (t, input, expectedOutput, encoding, lines, stripFinalNewline, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin.js', {\n\t\tlines,\n\t\tstripFinalNewline,\n\t\tencoding,\n\t\tinput,\n\t});\n\tt.deepEqual(stdout, expectedOutput);\n};\n\ntest('\"lines: true\" is a noop with \"encoding: utf16\"', testEncoding, simpleFullUtf16Uint8Array, simpleLines, 'utf16le', true, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", fd-specific', testEncoding, simpleFullUtf16Uint8Array, simpleLines, 'utf16le', {stdout: true}, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", stripFinalNewline', testEncoding, simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, true, execa);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", stripFinalNewline, fd-specific', testEncoding, simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, {stdout: true}, execa);\ntest('\"lines: true\" is a noop with \"encoding: buffer\"', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', true, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", fd-specific', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', {stdout: true}, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", stripFinalNewline', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', true, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", stripFinalNewline, fd-specific', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', true, {stdout: false}, execa);\ntest('\"lines: true\" is a noop with \"encoding: hex\"', testEncoding, simpleFull, simpleFullHex, 'hex', true, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: hex\", fd-specific', testEncoding, simpleFull, simpleFullHex, 'hex', {stdout: true}, false, execa);\ntest('\"lines: true\" is a noop with \"encoding: hex\", stripFinalNewline', testEncoding, simpleFull, simpleFullHex, 'hex', true, true, execa);\ntest('\"lines: true\" is a noop with \"encoding: hex\", stripFinalNewline, fd-specific', testEncoding, simpleFull, simpleFullHex, 'hex', true, {stdout: true}, execa);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", sync', testEncoding, simpleFullUtf16Uint8Array, simpleLines, 'utf16le', true, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", fd-specific, sync', testEncoding, simpleFullUtf16Uint8Array, simpleLines, 'utf16le', {stdout: true}, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", stripFinalNewline, sync', testEncoding, simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, true, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: utf16\", stripFinalNewline, fd-specific, sync', testEncoding, simpleFullUtf16Uint8Array, noNewlinesChunks, 'utf16le', true, {stdout: true}, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", sync', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', true, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", fd-specific, sync', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', {stdout: true}, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", stripFinalNewline, sync', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', true, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: buffer\", stripFinalNewline, fd-specific, sync', testEncoding, simpleFull, simpleFullUint8Array, 'buffer', true, {stdout: false}, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: hex\", sync', testEncoding, simpleFull, simpleFullHex, 'hex', true, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: hex\", fd-specific, sync', testEncoding, simpleFull, simpleFullHex, 'hex', {stdout: true}, false, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: hex\", stripFinalNewline, sync', testEncoding, simpleFull, simpleFullHex, 'hex', true, true, execaSync);\ntest('\"lines: true\" is a noop with \"encoding: hex\", stripFinalNewline, fd-specific, sync', testEncoding, simpleFull, simpleFullHex, 'hex', true, {stdout: true}, execaSync);\n\nconst testLinesNoBuffer = async (t, lines, buffer, execaMethod) => {\n\tconst {stdout} = await getSimpleChunkSubprocess(execaMethod, {lines, buffer});\n\tt.is(stdout, undefined);\n};\n\ntest('\"lines: true\" is a noop with \"buffer: false\"', testLinesNoBuffer, true, false, execa);\ntest('\"lines: true\" is a noop with \"buffer: false\", fd-specific buffer', testLinesNoBuffer, true, {stdout: false}, execa);\ntest('\"lines: true\" is a noop with \"buffer: false\", fd-specific lines', testLinesNoBuffer, {stdout: true}, false, execa);\ntest('\"lines: true\" is a noop with \"buffer: false\", sync', testLinesNoBuffer, true, false, execaSync);\ntest('\"lines: true\" is a noop with \"buffer: false\", fd-specific buffer, sync', testLinesNoBuffer, true, {stdout: false}, execaSync);\ntest('\"lines: true\" is a noop with \"buffer: false\", fd-specific lines, sync', testLinesNoBuffer, {stdout: true}, false, execaSync);\n"
  },
  {
    "path": "test/stdio/native-fd.js",
    "content": "import {platform} from 'node:process';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {getStdio, fullStdio} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\n\nsetFixtureDirectory();\n\nconst isLinux = platform === 'linux';\nconst isWindows = platform === 'win32';\n\nconst testFd3InheritOutput = async (t, stdioOption, isSync) => {\n\tconst {stdio} = await nestedSubprocess('noop-fd.js', ['3', foobarString], {...getStdio(3, stdioOption), isSync}, fullStdio);\n\tt.is(stdio[3], foobarString);\n};\n\ntest('stdio[*] output can use \"inherit\"', testFd3InheritOutput, 'inherit', false);\ntest('stdio[*] output can use [\"inherit\"]', testFd3InheritOutput, ['inherit'], false);\ntest('stdio[*] output can use \"inherit\", sync', testFd3InheritOutput, 'inherit', true);\ntest('stdio[*] output can use [\"inherit\"], sync', testFd3InheritOutput, ['inherit'], true);\n\nif (isLinux) {\n\tconst testOverflowStream = async (t, fdNumber, stdioOption, isSync) => {\n\t\tconst {stdout} = await nestedSubprocess('empty.js', {...getStdio(fdNumber, stdioOption), isSync}, fullStdio);\n\t\tt.is(stdout, '');\n\t};\n\n\ttest('stdin can use 4+', testOverflowStream, 0, 4, false);\n\ttest('stdin can use [4+]', testOverflowStream, 0, [4], false);\n\ttest('stdout can use 4+', testOverflowStream, 1, 4, false);\n\ttest('stdout can use [4+]', testOverflowStream, 1, [4], false);\n\ttest('stderr can use 4+', testOverflowStream, 2, 4, false);\n\ttest('stderr can use [4+]', testOverflowStream, 2, [4], false);\n\ttest('stdio[*] can use 4+', testOverflowStream, 3, 4, false);\n\ttest('stdio[*] can use [4+]', testOverflowStream, 3, [4], false);\n\ttest('stdin can use 4+, sync', testOverflowStream, 0, 4, true);\n\ttest('stdin can use [4+], sync', testOverflowStream, 0, [4], true);\n\ttest('stdout can use 4+, sync', testOverflowStream, 1, 4, true);\n\ttest('stdout can use [4+], sync', testOverflowStream, 1, [4], true);\n\ttest('stderr can use 4+, sync', testOverflowStream, 2, 4, true);\n\ttest('stderr can use [4+], sync', testOverflowStream, 2, [4], true);\n\ttest('stdio[*] can use 4+, sync', testOverflowStream, 3, 4, true);\n\ttest('stdio[*] can use [4+], sync', testOverflowStream, 3, [4], true);\n}\n\nconst testOverflowStreamArray = (t, fdNumber, stdioOption) => {\n\tt.throws(() => {\n\t\texeca('empty.js', getStdio(fdNumber, stdioOption));\n\t}, {message: /no such standard stream/});\n};\n\ntest('stdin cannot use 4+ and another value', testOverflowStreamArray, 0, [4, 'pipe']);\ntest('stdout cannot use 4+ and another value', testOverflowStreamArray, 1, [4, 'pipe']);\ntest('stderr cannot use 4+ and another value', testOverflowStreamArray, 2, [4, 'pipe']);\ntest('stdio[*] cannot use 4+ and another value', testOverflowStreamArray, 3, [4, 'pipe']);\ntest('stdio[*] cannot use \"inherit\" and another value', testOverflowStreamArray, 3, ['inherit', 'pipe']);\n\nconst getInvalidFdCode = () => {\n\tif (isLinux) {\n\t\treturn 'EINVAL';\n\t}\n\n\treturn isWindows ? 'EBADF' : 'ENXIO';\n};\n\nconst testOverflowStreamArraySync = (t, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('noop-fd.js', [fdNumber, foobarString], getStdio(fdNumber, [4, 'pipe']));\n\t}, {code: getInvalidFdCode()});\n};\n\ntest('stdout cannot use 4+ and another value, sync', testOverflowStreamArraySync, 1);\ntest('stderr cannot use 4+ and another value, sync', testOverflowStreamArraySync, 2);\ntest('stdio[*] cannot use 4+ and another value, sync', testOverflowStreamArraySync, 3);\n"
  },
  {
    "path": "test/stdio/native-inherit-pipe.js",
    "content": "import {readFile, rm} from 'node:fs/promises';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa} from '../../index.js';\nimport {getStdio, fullStdio} from '../helpers/stdio.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\n\nsetFixtureDirectory();\n\nconst testInheritStdin = async (t, stdioOption, isSync) => {\n\tconst {stdout} = await execa('nested-multiple-stdin.js', [JSON.stringify(stdioOption), `${isSync}`], {input: foobarString});\n\tt.is(stdout, `${foobarString}${foobarString}`);\n};\n\ntest('stdin can be [\"inherit\", \"pipe\"]', testInheritStdin, ['inherit', 'pipe'], false);\ntest('stdin can be [0, \"pipe\"]', testInheritStdin, [0, 'pipe'], false);\ntest('stdin can be [process.stdin, \"pipe\"]', testInheritStdin, ['stdin', 'pipe'], false);\ntest.serial('stdin can be [\"inherit\", \"pipe\"], sync', testInheritStdin, ['inherit', 'pipe'], true);\ntest.serial('stdin can be [0, \"pipe\"], sync', testInheritStdin, [0, 'pipe'], true);\ntest.serial('stdin can be [process.stdin, \"pipe\"], sync', testInheritStdin, ['stdin', 'pipe'], true);\n\n// eslint-disable-next-line max-params\nconst testInheritStdioOutput = async (t, fdNumber, outerFdNumber, stdioOption, isSync, encoding) => {\n\tconst {stdio} = await execa('nested-multiple-stdio-output.js', [JSON.stringify(stdioOption), `${fdNumber}`, `${outerFdNumber}`, `${isSync}`, encoding], fullStdio);\n\tt.is(stdio[fdNumber], foobarString);\n\tt.is(stdio[outerFdNumber], `nested ${foobarString}`);\n};\n\ntest('stdout can be [\"inherit\", \"pipe\"]', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], false, 'utf8');\ntest('stdout can be [1, \"pipe\"]', testInheritStdioOutput, 1, 2, [1, 'pipe'], false, 'utf8');\ntest('stdout can be [process.stdout, \"pipe\"]', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], false, 'utf8');\ntest('stderr can be [\"inherit\", \"pipe\"]', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], false, 'utf8');\ntest('stderr can be [2, \"pipe\"]', testInheritStdioOutput, 2, 1, [2, 'pipe'], false, 'utf8');\ntest('stderr can be [process.stderr, \"pipe\"]', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], false, 'utf8');\ntest('stdout can be [\"inherit\", \"pipe\"], encoding \"buffer\"', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], false, 'buffer');\ntest('stdout can be [1, \"pipe\"], encoding \"buffer\"', testInheritStdioOutput, 1, 2, [1, 'pipe'], false, 'buffer');\ntest('stdout can be [process.stdout, \"pipe\"], encoding \"buffer\"', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], false, 'buffer');\ntest('stderr can be [\"inherit\", \"pipe\"], encoding \"buffer\"', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], false, 'buffer');\ntest('stderr can be [2, \"pipe\"], encoding \"buffer\"', testInheritStdioOutput, 2, 1, [2, 'pipe'], false, 'buffer');\ntest('stderr can be [process.stderr, \"pipe\"], encoding \"buffer\"', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], false, 'buffer');\ntest('stdout can be [\"inherit\", \"pipe\"], sync', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], true, 'utf8');\ntest('stdout can be [1, \"pipe\"], sync', testInheritStdioOutput, 1, 2, [1, 'pipe'], true, 'utf8');\ntest('stdout can be [process.stdout, \"pipe\"], sync', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], true, 'utf8');\ntest('stderr can be [\"inherit\", \"pipe\"], sync', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], true, 'utf8');\ntest('stderr can be [2, \"pipe\"], sync', testInheritStdioOutput, 2, 1, [2, 'pipe'], true, 'utf8');\ntest('stderr can be [process.stderr, \"pipe\"], sync', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], true, 'utf8');\ntest('stdio[*] output can be [\"inherit\", \"pipe\"], sync', testInheritStdioOutput, 3, 1, ['inherit', 'pipe'], true, 'utf8');\ntest('stdio[*] output can be [3, \"pipe\"], sync', testInheritStdioOutput, 3, 1, [3, 'pipe'], true, 'utf8');\ntest('stdout can be [\"inherit\", \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 1, 2, ['inherit', 'pipe'], true, 'buffer');\ntest('stdout can be [1, \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 1, 2, [1, 'pipe'], true, 'buffer');\ntest('stdout can be [process.stdout, \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 1, 2, ['stdout', 'pipe'], true, 'buffer');\ntest('stderr can be [\"inherit\", \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 2, 1, ['inherit', 'pipe'], true, 'buffer');\ntest('stderr can be [2, \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 2, 1, [2, 'pipe'], true, 'buffer');\ntest('stderr can be [process.stderr, \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 2, 1, ['stderr', 'pipe'], true, 'buffer');\ntest('stdio[*] output can be [\"inherit\", \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 3, 1, ['inherit', 'pipe'], true, 'buffer');\ntest('stdio[*] output can be [3, \"pipe\"], encoding \"buffer\", sync', testInheritStdioOutput, 3, 1, [3, 'pipe'], true, 'buffer');\n\nconst testInheritNoBuffer = async (t, stdioOption, isSync) => {\n\tconst filePath = tempfile();\n\tawait nestedSubprocess('nested-write.js', [filePath, foobarString], {stdin: stdioOption, buffer: false, isSync}, {input: foobarString});\n\tt.is(await readFile(filePath, 'utf8'), `${foobarString} ${foobarString}`);\n\tawait rm(filePath);\n};\n\ntest('stdin can be [\"inherit\", \"pipe\"], buffer: false', testInheritNoBuffer, ['inherit', 'pipe'], false);\ntest('stdin can be [0, \"pipe\"], buffer: false', testInheritNoBuffer, [0, 'pipe'], false);\ntest.serial('stdin can be [\"inherit\", \"pipe\"], buffer: false, sync', testInheritNoBuffer, ['inherit', 'pipe'], true);\ntest.serial('stdin can be [0, \"pipe\"], buffer: false, sync', testInheritNoBuffer, [0, 'pipe'], true);\n\ntest('stdin can use [\"inherit\", \"pipe\"] in a TTY', async t => {\n\tconst stdioOption = [['inherit', 'pipe'], 'inherit', 'pipe'];\n\tconst {stdout} = await execa('nested-sync-tty.js', [JSON.stringify({stdio: stdioOption}), 'false', 'stdin-fd.js', '0'], {input: foobarString});\n\tt.is(stdout, foobarString);\n});\n\nconst testNoTtyInput = async (t, fdNumber, optionName) => {\n\tconst stdioOption = ['pipe', 'inherit', 'pipe'];\n\tstdioOption[fdNumber] = [[''], 'inherit', 'pipe'];\n\tconst {message} = await t.throwsAsync(execa('nested-sync-tty.js', [JSON.stringify({stdio: stdioOption}), 'true', 'stdin-fd.js', `${fdNumber}`], fullStdio));\n\tt.true(message.includes(`The \\`${optionName}: 'inherit'\\` option is invalid: it cannot be a TTY`));\n};\n\ntest('stdin cannot use [\"inherit\", \"pipe\"] in a TTY, sync', testNoTtyInput, 0, 'stdin');\ntest('stdio[*] input cannot use [\"inherit\", \"pipe\"] in a TTY, sync', testNoTtyInput, 3, 'stdio[3]');\n\nconst testTtyOutput = async (t, fdNumber, isSync) => {\n\tconst {stdio} = await execa('nested-sync-tty.js', [JSON.stringify(getStdio(fdNumber, ['inherit', 'pipe'])), `${isSync}`, 'noop-fd.js', `${fdNumber}`, foobarString], fullStdio);\n\tt.is(stdio[fdNumber], foobarString);\n};\n\ntest('stdout can use [\"inherit\", \"pipe\"] in a TTY', testTtyOutput, 1, false);\ntest('stderr can use [\"inherit\", \"pipe\"] in a TTY', testTtyOutput, 2, false);\ntest('stdout can use [\"inherit\", \"pipe\"] in a TTY, sync', testTtyOutput, 1, true);\ntest('stderr can use [\"inherit\", \"pipe\"] in a TTY, sync', testTtyOutput, 2, true);\ntest('stdio[*] output can use [\"inherit\", \"pipe\"] in a TTY, sync', testTtyOutput, 3, true);\n"
  },
  {
    "path": "test/stdio/native-redirect.js",
    "content": "import test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testRedirect = async (t, stdioOption, fdNumber, isInput, isSync) => {\n\tconst {fixtureName, ...options} = isInput\n\t\t? {fixtureName: 'stdin-fd.js', input: foobarString}\n\t\t: {fixtureName: 'noop-fd.js'};\n\tconst {stdio} = await execa('nested-stdio.js', [JSON.stringify(stdioOption), `${fdNumber}`, `${isSync}`, fixtureName, foobarString], options);\n\tconst resultFdNumber = isStderrDescriptor(stdioOption) ? 2 : 1;\n\tt.is(stdio[resultFdNumber], foobarString);\n};\n\nconst isStderrDescriptor = stdioOption => stdioOption === 2\n\t|| stdioOption === 'stderr'\n\t|| (Array.isArray(stdioOption) && isStderrDescriptor(stdioOption[0]));\n\ntest.serial('stdio[*] can be 0', testRedirect, 0, 3, true, false);\ntest.serial('stdio[*] can be [0]', testRedirect, [0], 3, true, false);\ntest.serial('stdio[*] can be [0, \"pipe\"]', testRedirect, [0, 'pipe'], 3, true, false);\ntest.serial('stdio[*] can be process.stdin', testRedirect, 'stdin', 3, true, false);\ntest.serial('stdio[*] can be [process.stdin]', testRedirect, ['stdin'], 3, true, false);\ntest.serial('stdio[*] can be [process.stdin, \"pipe\"]', testRedirect, ['stdin', 'pipe'], 3, true, false);\ntest('stdout can be 2', testRedirect, 2, 1, false, false);\ntest('stdout can be [2]', testRedirect, [2], 1, false, false);\ntest('stdout can be [2, \"pipe\"]', testRedirect, [2, 'pipe'], 1, false, false);\ntest('stdout can be process.stderr', testRedirect, 'stderr', 1, false, false);\ntest('stdout can be [process.stderr]', testRedirect, ['stderr'], 1, false, false);\ntest('stdout can be [process.stderr, \"pipe\"]', testRedirect, ['stderr', 'pipe'], 1, false, false);\ntest('stderr can be 1', testRedirect, 1, 2, false, false);\ntest('stderr can be [1]', testRedirect, [1], 2, false, false);\ntest('stderr can be [1, \"pipe\"]', testRedirect, [1, 'pipe'], 2, false, false);\ntest('stderr can be process.stdout', testRedirect, 'stdout', 2, false, false);\ntest('stderr can be [process.stdout]', testRedirect, ['stdout'], 2, false, false);\ntest('stderr can be [process.stdout, \"pipe\"]', testRedirect, ['stdout', 'pipe'], 2, false, false);\ntest('stdio[*] can be 1', testRedirect, 1, 3, false, false);\ntest('stdio[*] can be [1]', testRedirect, [1], 3, false, false);\ntest('stdio[*] can be [1, \"pipe\"]', testRedirect, [1, 'pipe'], 3, false, false);\ntest('stdio[*] can be 2', testRedirect, 2, 3, false, false);\ntest('stdio[*] can be [2]', testRedirect, [2], 3, false, false);\ntest('stdio[*] can be [2, \"pipe\"]', testRedirect, [2, 'pipe'], 3, false, false);\ntest('stdio[*] can be process.stdout', testRedirect, 'stdout', 3, false, false);\ntest('stdio[*] can be [process.stdout]', testRedirect, ['stdout'], 3, false, false);\ntest('stdio[*] can be [process.stdout, \"pipe\"]', testRedirect, ['stdout', 'pipe'], 3, false, false);\ntest('stdio[*] can be process.stderr', testRedirect, 'stderr', 3, false, false);\ntest('stdio[*] can be [process.stderr]', testRedirect, ['stderr'], 3, false, false);\ntest('stdio[*] can be [process.stderr, \"pipe\"]', testRedirect, ['stderr', 'pipe'], 3, false, false);\ntest('stdout can be 2, sync', testRedirect, 2, 1, false, true);\ntest('stdout can be [2], sync', testRedirect, [2], 1, false, true);\ntest('stdout can be [2, \"pipe\"], sync', testRedirect, [2, 'pipe'], 1, false, true);\ntest('stdout can be process.stderr, sync', testRedirect, 'stderr', 1, false, true);\ntest('stdout can be [process.stderr], sync', testRedirect, ['stderr'], 1, false, true);\ntest('stdout can be [process.stderr, \"pipe\"], sync', testRedirect, ['stderr', 'pipe'], 1, false, true);\ntest('stderr can be 1, sync', testRedirect, 1, 2, false, true);\ntest('stderr can be [1], sync', testRedirect, [1], 2, false, true);\ntest('stderr can be [1, \"pipe\"], sync', testRedirect, [1, 'pipe'], 2, false, true);\ntest('stderr can be process.stdout, sync', testRedirect, 'stdout', 2, false, true);\ntest('stderr can be [process.stdout], sync', testRedirect, ['stdout'], 2, false, true);\ntest('stderr can be [process.stdout, \"pipe\"], sync', testRedirect, ['stdout', 'pipe'], 2, false, true);\ntest('stdio[*] can be 1, sync', testRedirect, 1, 3, false, true);\ntest('stdio[*] can be [1], sync', testRedirect, [1], 3, false, true);\ntest('stdio[*] can be [1, \"pipe\"], sync', testRedirect, [1, 'pipe'], 3, false, true);\ntest('stdio[*] can be 2, sync', testRedirect, 2, 3, false, true);\ntest('stdio[*] can be [2], sync', testRedirect, [2], 3, false, true);\ntest('stdio[*] can be [2, \"pipe\"], sync', testRedirect, [2, 'pipe'], 3, false, true);\ntest('stdio[*] can be process.stdout, sync', testRedirect, 'stdout', 3, false, true);\ntest('stdio[*] can be [process.stdout], sync', testRedirect, ['stdout'], 3, false, true);\ntest('stdio[*] can be [process.stdout, \"pipe\"], sync', testRedirect, ['stdout', 'pipe'], 3, false, true);\ntest('stdio[*] can be process.stderr, sync', testRedirect, 'stderr', 3, false, true);\ntest('stdio[*] can be [process.stderr], sync', testRedirect, ['stderr'], 3, false, true);\ntest('stdio[*] can be [process.stderr, \"pipe\"], sync', testRedirect, ['stderr', 'pipe'], 3, false, true);\n"
  },
  {
    "path": "test/stdio/node-stream-custom.js",
    "content": "import {createReadStream, createWriteStream} from 'node:fs';\nimport {readFile, writeFile, rm} from 'node:fs/promises';\nimport {Writable, PassThrough} from 'node:stream';\nimport {text} from 'node:stream/consumers';\nimport {setImmediate} from 'node:timers/promises';\nimport {callbackify} from 'node:util';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\nimport {noopReadable, noopWritable} from '../helpers/stream.js';\nimport {getEarlyErrorSubprocess, expectedEarlyError} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testLazyFileReadable = async (t, fdNumber) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, 'foobar');\n\tconst stream = createReadStream(filePath);\n\n\tconst {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe']));\n\tt.is(stdout, 'foobar');\n\n\tawait rm(filePath);\n};\n\ntest('stdin can be [Readable, \"pipe\"] without a file descriptor', testLazyFileReadable, 0);\ntest('stdio[*] can be [Readable, \"pipe\"] without a file descriptor', testLazyFileReadable, 3);\n\nconst testLazyFileReadableSync = (t, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [noopReadable(), 'pipe']));\n\t}, {message: /cannot both be an array and include a stream/});\n};\n\ntest('stdin cannot be [Readable, \"pipe\"] without a file descriptor, sync', testLazyFileReadableSync, 0);\ntest('stdio[*] cannot be [Readable, \"pipe\"] without a file descriptor, sync', testLazyFileReadableSync, 3);\n\nconst testLazyFileWritable = async (t, fdNumber) => {\n\tconst filePath = tempfile();\n\tconst stream = createWriteStream(filePath);\n\n\tawait execa('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, [stream, 'pipe']));\n\tt.is(await readFile(filePath, 'utf8'), 'foobar');\n\n\tawait rm(filePath);\n};\n\ntest('stdout can be [Writable, \"pipe\"] without a file descriptor', testLazyFileWritable, 1);\ntest('stderr can be [Writable, \"pipe\"] without a file descriptor', testLazyFileWritable, 2);\ntest('stdio[*] can be [Writable, \"pipe\"] without a file descriptor', testLazyFileWritable, 3);\n\nconst testLazyFileWritableSync = (t, fdNumber) => {\n\tt.throws(() => {\n\t\texecaSync('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [noopWritable(), 'pipe']));\n\t}, {message: /cannot both be an array and include a stream/});\n};\n\ntest('stdout cannot be [Writable, \"pipe\"] without a file descriptor, sync', testLazyFileWritableSync, 1);\ntest('stderr cannot be [Writable, \"pipe\"] without a file descriptor, sync', testLazyFileWritableSync, 2);\ntest('stdio[*] cannot be [Writable, \"pipe\"] without a file descriptor, sync', testLazyFileWritableSync, 3);\n\ntest('Waits for custom streams destroy on subprocess errors', async t => {\n\tlet waitedForDestroy = false;\n\tconst stream = new Writable({\n\t\tdestroy: callbackify(async error => {\n\t\t\tawait setImmediate();\n\t\t\twaitedForDestroy = true;\n\t\t\treturn error;\n\t\t}),\n\t});\n\tconst {timedOut} = await t.throwsAsync(execa('forever.js', {stdout: [stream, 'pipe'], timeout: 1}));\n\tt.true(timedOut);\n\tt.true(waitedForDestroy);\n});\n\ntest('Handles custom streams destroy errors on subprocess success', async t => {\n\tconst cause = new Error('test');\n\tconst stream = new Writable({\n\t\tdestroy(destroyError, done) {\n\t\t\tdone(destroyError ?? cause);\n\t\t},\n\t});\n\tconst error = await t.throwsAsync(execa('empty.js', {stdout: [stream, 'pipe']}));\n\tt.is(error.cause, cause);\n});\n\nconst testStreamEarlyExit = async (t, stream, streamName) => {\n\tconst error = await t.throwsAsync(getEarlyErrorSubprocess({[streamName]: [stream, 'pipe']}));\n\tt.like(error, expectedEarlyError);\n\tt.true(stream.destroyed);\n};\n\ntest('Input streams are canceled on early subprocess exit', testStreamEarlyExit, noopReadable(), 'stdin');\ntest('Output streams are canceled on early subprocess exit', testStreamEarlyExit, noopWritable(), 'stdout');\n\nconst testInputDuplexStream = async (t, fdNumber) => {\n\tconst stream = new PassThrough();\n\tstream.end(foobarString);\n\tconst {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));\n\tt.is(stdout, foobarString);\n};\n\ntest('Can pass Duplex streams to stdin', testInputDuplexStream, 0);\ntest('Can pass Duplex streams to input stdio[*]', testInputDuplexStream, 3);\n\nconst testOutputDuplexStream = async (t, fdNumber) => {\n\tconst stream = new PassThrough();\n\tconst [output] = await Promise.all([\n\t\ttext(stream),\n\t\texeca('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe'])),\n\t]);\n\tt.is(output, foobarString);\n};\n\ntest('Can pass Duplex streams to stdout', testOutputDuplexStream, 1);\ntest('Can pass Duplex streams to stderr', testOutputDuplexStream, 2);\ntest('Can pass Duplex streams to output stdio[*]', testOutputDuplexStream, 3);\n\nconst testInputStreamAbort = async (t, fdNumber) => {\n\tconst stream = new PassThrough();\n\tstream.destroy();\n\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));\n\tawait subprocess;\n\tt.true(subprocess.stdio[fdNumber].writableEnded);\n};\n\ntest('subprocess.stdin is ended when an input stream aborts', testInputStreamAbort, 0);\ntest('subprocess.stdio[*] is ended when an input stream aborts', testInputStreamAbort, 3);\n\nconst testInputStreamError = async (t, fdNumber) => {\n\tconst stream = new PassThrough();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tconst subprocess = execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, new Uint8Array()]));\n\tt.like(await t.throwsAsync(subprocess), {cause});\n\tt.true(subprocess.stdio[fdNumber].writableEnded);\n};\n\ntest('subprocess.stdin is ended when an input stream errors', testInputStreamError, 0);\ntest('subprocess.stdio[*] is ended when an input stream errors', testInputStreamError, 3);\n\nconst testOutputStreamError = async (t, fdNumber) => {\n\tconst stream = new PassThrough();\n\tconst cause = new Error(foobarString);\n\tstream.destroy(cause);\n\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, [stream, 'pipe']));\n\tt.like(await t.throwsAsync(subprocess), {cause});\n\tt.true(subprocess.stdio[fdNumber].readableAborted);\n\tt.is(subprocess.stdio[fdNumber].errored, null);\n};\n\ntest('subprocess.stdout is aborted when an output stream errors', testOutputStreamError, 1);\ntest('subprocess.stderr is aborted when an output stream errors', testOutputStreamError, 2);\ntest('subprocess.stdio[*] is aborted when an output stream errors', testOutputStreamError, 3);\n"
  },
  {
    "path": "test/stdio/node-stream-native.js",
    "content": "import {once} from 'node:events';\nimport {createReadStream, createWriteStream} from 'node:fs';\nimport {readFile, writeFile, rm} from 'node:fs/promises';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {foobarString} from '../helpers/input.js';\nimport {\n\tnoopReadable,\n\tnoopWritable,\n\tnoopDuplex,\n\tsimpleReadable,\n} from '../helpers/stream.js';\n\nsetFixtureDirectory();\n\nconst testNoFileStreamSync = async (t, fdNumber, stream) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, stream));\n\t}, {code: 'ERR_INVALID_ARG_VALUE'});\n};\n\ntest('stdin cannot be a Node.js Readable without a file descriptor - sync', testNoFileStreamSync, 0, noopReadable());\ntest('stdin cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 0, noopDuplex());\ntest('stdout cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 1, noopWritable());\ntest('stdout cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 1, noopDuplex());\ntest('stderr cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 2, noopWritable());\ntest('stderr cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 2, noopDuplex());\ntest('stdio[*] cannot be a Node.js Readable without a file descriptor - sync', testNoFileStreamSync, 3, noopReadable());\ntest('stdio[*] cannot be a Node.js Writable without a file descriptor - sync', testNoFileStreamSync, 3, noopWritable());\ntest('stdio[*] cannot be a Node.js Duplex without a file descriptor - sync', testNoFileStreamSync, 3, noopDuplex());\n\ntest('input can be a Node.js Readable without a file descriptor', async t => {\n\tconst {stdout} = await execa('stdin.js', {input: simpleReadable()});\n\tt.is(stdout, foobarString);\n});\n\ntest('input cannot be a Node.js Readable without a file descriptor - sync', t => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', {input: simpleReadable()});\n\t}, {message: 'The `input` option cannot be a Node.js stream with synchronous methods.'});\n});\n\nconst testNoFileStream = async (t, fdNumber, stream) => {\n\tawait t.throwsAsync(execa('empty.js', getStdio(fdNumber, stream)), {code: 'ERR_INVALID_ARG_VALUE'});\n};\n\ntest('stdin cannot be a Node.js Readable without a file descriptor', testNoFileStream, 0, noopReadable());\ntest('stdin cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 0, noopDuplex());\ntest('stdout cannot be a Node.js Writable without a file descriptor', testNoFileStream, 1, noopWritable());\ntest('stdout cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 1, noopDuplex());\ntest('stderr cannot be a Node.js Writable without a file descriptor', testNoFileStream, 2, noopWritable());\ntest('stderr cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 2, noopDuplex());\ntest('stdio[*] cannot be a Node.js Readable without a file descriptor', testNoFileStream, 3, noopReadable());\ntest('stdio[*] cannot be a Node.js Writable without a file descriptor', testNoFileStream, 3, noopWritable());\ntest('stdio[*] cannot be a Node.js Duplex without a file descriptor', testNoFileStream, 3, noopDuplex());\n\nconst createFileReadStream = async () => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, 'foobar');\n\tconst stream = createReadStream(filePath);\n\tawait once(stream, 'open');\n\treturn {stream, filePath};\n};\n\nconst createFileWriteStream = async () => {\n\tconst filePath = tempfile();\n\tconst stream = createWriteStream(filePath);\n\tawait once(stream, 'open');\n\treturn {stream, filePath};\n};\n\nconst assertFileStreamError = async (t, subprocess, stream, filePath) => {\n\tconst cause = new Error('test');\n\tstream.destroy(cause);\n\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.exitCode, 0);\n\tt.is(error.signal, undefined);\n\n\tawait rm(filePath);\n};\n\nconst testFileReadable = async (t, fdNumber, execaMethod) => {\n\tconst {stream, filePath} = await createFileReadStream();\n\n\tconst fdNumberString = fdNumber === 'input' ? '0' : `${fdNumber}`;\n\tconst {stdout} = await execaMethod('stdin-fd.js', [fdNumberString], getStdio(fdNumber, stream));\n\tt.is(stdout, 'foobar');\n\n\tawait rm(filePath);\n};\n\ntest('input can be a Node.js Readable with a file descriptor', testFileReadable, 'input', execa);\ntest('stdin can be a Node.js Readable with a file descriptor', testFileReadable, 0, execa);\ntest('stdio[*] can be a Node.js Readable with a file descriptor', testFileReadable, 3, execa);\ntest('stdin can be a Node.js Readable with a file descriptor - sync', testFileReadable, 0, execaSync);\ntest('stdio[*] can be a Node.js Readable with a file descriptor - sync', testFileReadable, 3, execaSync);\n\nconst testFileReadableError = async (t, fdNumber) => {\n\tconst {stream, filePath} = await createFileReadStream();\n\n\tconst fdNumberString = fdNumber === 'input' ? '0' : `${fdNumber}`;\n\tconst subprocess = execa('stdin-fd.js', [fdNumberString], getStdio(fdNumber, stream));\n\n\tawait assertFileStreamError(t, subprocess, stream, filePath);\n};\n\ntest.serial('input handles errors from a Node.js Readable with a file descriptor', testFileReadableError, 'input');\ntest.serial('stdin handles errors from a Node.js Readable with a file descriptor', testFileReadableError, 0);\ntest.serial('stdio[*] handles errors from a Node.js Readable with a file descriptor', testFileReadableError, 3);\n\nconst testFileReadableOpen = async (t, fdNumber, useSingle, execaMethod) => {\n\tconst {stream, filePath} = await createFileReadStream();\n\tt.deepEqual(stream.eventNames(), []);\n\n\tconst stdioOption = useSingle ? stream : [stream, 'pipe'];\n\tawait execaMethod('empty.js', getStdio(fdNumber, stdioOption));\n\n\tt.is(stream.readable, useSingle && fdNumber !== 'input');\n\tt.deepEqual(stream.eventNames(), []);\n\n\tawait rm(filePath);\n};\n\ntest('input closes a Node.js Readable with a file descriptor', testFileReadableOpen, 'input', true, execa);\ntest('stdin leaves open a single Node.js Readable with a file descriptor', testFileReadableOpen, 0, true, execa);\ntest('stdin closes a combined Node.js Readable with a file descriptor', testFileReadableOpen, 0, false, execa);\ntest('stdio[*] leaves open a single Node.js Readable with a file descriptor', testFileReadableOpen, 3, true, execa);\ntest('stdin leaves open a single Node.js Readable with a file descriptor - sync', testFileReadableOpen, 0, true, execaSync);\ntest('stdio[*] leaves open a single Node.js Readable with a file descriptor - sync', testFileReadableOpen, 3, true, execaSync);\n\nconst testFileWritable = async (t, fdNumber, execaMethod) => {\n\tconst {stream, filePath} = await createFileWriteStream();\n\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, stream));\n\tt.is(await readFile(filePath, 'utf8'), 'foobar');\n\n\tawait rm(filePath);\n};\n\ntest('stdout can be a Node.js Writable with a file descriptor', testFileWritable, 1, execa);\ntest('stderr can be a Node.js Writable with a file descriptor', testFileWritable, 2, execa);\ntest('stdio[*] can be a Node.js Writable with a file descriptor', testFileWritable, 3, execa);\ntest('stdout can be a Node.js Writable with a file descriptor - sync', testFileWritable, 1, execaSync);\ntest('stderr can be a Node.js Writable with a file descriptor - sync', testFileWritable, 2, execaSync);\ntest('stdio[*] can be a Node.js Writable with a file descriptor - sync', testFileWritable, 3, execaSync);\n\nconst testFileWritableError = async (t, fdNumber) => {\n\tconst {stream, filePath} = await createFileWriteStream();\n\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, stream));\n\n\tawait assertFileStreamError(t, subprocess, stream, filePath);\n};\n\ntest.serial('stdout handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 1);\ntest.serial('stderr handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 2);\ntest.serial('stdio[*] handles errors from a Node.js Writable with a file descriptor', testFileWritableError, 3);\n\nconst testFileWritableOpen = async (t, fdNumber, useSingle, execaMethod) => {\n\tconst {stream, filePath} = await createFileWriteStream();\n\tt.deepEqual(stream.eventNames(), []);\n\n\tconst stdioOption = useSingle ? stream : [stream, 'pipe'];\n\tawait execaMethod('empty.js', getStdio(fdNumber, stdioOption));\n\n\tt.is(stream.writable, useSingle);\n\tt.deepEqual(stream.eventNames(), []);\n\n\tawait rm(filePath);\n};\n\ntest('stdout leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 1, true, execa);\ntest('stdout closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 1, false, execa);\ntest('stderr leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 2, true, execa);\ntest('stderr closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 2, false, execa);\ntest('stdio[*] leaves open a single Node.js Writable with a file descriptor', testFileWritableOpen, 3, true, execa);\ntest('stdio[*] closes a combined Node.js Writable with a file descriptor', testFileWritableOpen, 3, false, execa);\ntest('stdout leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 1, true, execaSync);\ntest('stderr leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 2, true, execaSync);\ntest('stdio[*] leaves open a single Node.js Writable with a file descriptor - sync', testFileWritableOpen, 3, true, execaSync);\n"
  },
  {
    "path": "test/stdio/stdio-option.js",
    "content": "import {inspect} from 'node:util';\nimport test from 'ava';\nimport {normalizeStdioOption} from '../../lib/stdio/stdio-option.js';\n\nconst stdioMacro = (t, input, expected) => {\n\tif (expected instanceof Error) {\n\t\tt.throws(() => {\n\t\t\tnormalizeStdioOption(input);\n\t\t}, {message: expected.message});\n\t\treturn;\n\t}\n\n\tt.deepEqual(normalizeStdioOption(input), expected);\n};\n\nstdioMacro.title = (_, input) => `execa() ${(inspect(input))}`;\n\ntest(stdioMacro, {stdio: 'inherit'}, ['inherit', 'inherit', 'inherit']);\ntest(stdioMacro, {stdio: 'pipe'}, ['pipe', 'pipe', 'pipe']);\ntest(stdioMacro, {stdio: 'ignore'}, ['ignore', 'ignore', 'ignore']);\n\ntest(stdioMacro, {}, ['pipe', 'pipe', 'pipe']);\ntest(stdioMacro, {stdio: []}, ['pipe', 'pipe', 'pipe']);\ntest(stdioMacro, {stdio: [0]}, [0, 'pipe', 'pipe']);\ntest(stdioMacro, {stdio: [0, 1]}, [0, 1, 'pipe']);\ntest(stdioMacro, {stdio: [0, 1, 2]}, [0, 1, 2]);\ntest(stdioMacro, {stdio: [0, 1, 2, 3]}, [0, 1, 2, 3]);\ntest(stdioMacro, {stdio: [undefined, 1, 2]}, ['pipe', 1, 2]);\ntest(stdioMacro, {stdio: [null, 1, 2]}, ['pipe', 1, 2]);\ntest(stdioMacro, {stdio: [0, undefined, 2]}, [0, 'pipe', 2]);\ntest(stdioMacro, {stdio: [0, null, 2]}, [0, 'pipe', 2]);\ntest(stdioMacro, {stdio: [0, 1, undefined]}, [0, 1, 'pipe']);\ntest(stdioMacro, {stdio: [0, 1, null]}, [0, 1, 'pipe']);\ntest(stdioMacro, {stdio: [0, 1, 2, undefined]}, [0, 1, 2, 'ignore']);\ntest(stdioMacro, {stdio: [0, 1, 2, null]}, [0, 1, 2, 'ignore']);\n\ntest(stdioMacro, {stdin: 'pipe'}, ['pipe', 'pipe', 'pipe']);\ntest(stdioMacro, {stdout: 'ignore'}, ['pipe', 'ignore', 'pipe']);\ntest(stdioMacro, {stderr: 'inherit'}, ['pipe', 'pipe', 'inherit']);\ntest(stdioMacro, {stdin: 'pipe', stdout: 'ignore', stderr: 'inherit'}, ['pipe', 'ignore', 'inherit']);\ntest(stdioMacro, {stdin: 'pipe', stdout: 'ignore'}, ['pipe', 'ignore', 'pipe']);\ntest(stdioMacro, {stdin: 'pipe', stderr: 'inherit'}, ['pipe', 'pipe', 'inherit']);\ntest(stdioMacro, {stdout: 'ignore', stderr: 'inherit'}, ['pipe', 'ignore', 'inherit']);\ntest(stdioMacro, {stdin: 0, stdout: 1, stderr: 2}, [0, 1, 2]);\ntest(stdioMacro, {stdin: 0, stdout: 1}, [0, 1, 'pipe']);\ntest(stdioMacro, {stdin: 0, stderr: 2}, [0, 'pipe', 2]);\ntest(stdioMacro, {stdout: 1, stderr: 2}, ['pipe', 1, 2]);\n\ntest(stdioMacro, {stdio: {foo: 'bar'}}, new TypeError('Expected `stdio` to be of type `string` or `Array`, got `object`'));\n\ntest(stdioMacro, {stdin: 'inherit', stdio: 'pipe'}, new Error('It\\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));\ntest(stdioMacro, {stdin: 'inherit', stdio: ['pipe']}, new Error('It\\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));\ntest(stdioMacro, {stdin: 'inherit', stdio: [undefined, 'pipe']}, new Error('It\\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));\ntest(stdioMacro, {stdin: 0, stdio: 'pipe'}, new Error('It\\'s not possible to provide `stdio` in combination with one of `stdin`, `stdout`, `stderr`'));\n"
  },
  {
    "path": "test/stdio/type-invalid.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {noopGenerator} from '../helpers/generator.js';\nimport {generatorsMap} from '../helpers/map.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst testInvalidGenerator = (t, fdNumber, stdioOption, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, {...noopGenerator(), ...stdioOption}));\n\t}, {message: 'final' in stdioOption ? /must be a generator/ : /must be a generator, a Duplex stream or a web TransformStream/});\n};\n\ntest('Cannot use invalid \"transform\" with stdin', testInvalidGenerator, 0, {transform: true}, execa);\ntest('Cannot use invalid \"transform\" with stdout', testInvalidGenerator, 1, {transform: true}, execa);\ntest('Cannot use invalid \"transform\" with stderr', testInvalidGenerator, 2, {transform: true}, execa);\ntest('Cannot use invalid \"transform\" with stdio[*]', testInvalidGenerator, 3, {transform: true}, execa);\ntest('Cannot use invalid \"final\" with stdin', testInvalidGenerator, 0, {final: true}, execa);\ntest('Cannot use invalid \"final\" with stdout', testInvalidGenerator, 1, {final: true}, execa);\ntest('Cannot use invalid \"final\" with stderr', testInvalidGenerator, 2, {final: true}, execa);\ntest('Cannot use invalid \"final\" with stdio[*]', testInvalidGenerator, 3, {final: true}, execa);\ntest('Cannot use invalid \"transform\" with stdin, sync', testInvalidGenerator, 0, {transform: true}, execaSync);\ntest('Cannot use invalid \"transform\" with stdout, sync', testInvalidGenerator, 1, {transform: true}, execaSync);\ntest('Cannot use invalid \"transform\" with stderr, sync', testInvalidGenerator, 2, {transform: true}, execaSync);\ntest('Cannot use invalid \"transform\" with stdio[*], sync', testInvalidGenerator, 3, {transform: true}, execaSync);\ntest('Cannot use invalid \"final\" with stdin, sync', testInvalidGenerator, 0, {final: true}, execaSync);\ntest('Cannot use invalid \"final\" with stdout, sync', testInvalidGenerator, 1, {final: true}, execaSync);\ntest('Cannot use invalid \"final\" with stderr, sync', testInvalidGenerator, 2, {final: true}, execaSync);\ntest('Cannot use invalid \"final\" with stdio[*], sync', testInvalidGenerator, 3, {final: true}, execaSync);\n\n// eslint-disable-next-line max-params\nconst testInvalidBinary = (t, fdNumber, optionName, type, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: 'true'}));\n\t}, {message: /a boolean/});\n};\n\ntest('Cannot use invalid \"binary\" with stdin', testInvalidBinary, 0, 'binary', 'generator', execa);\ntest('Cannot use invalid \"binary\" with stdout', testInvalidBinary, 1, 'binary', 'generator', execa);\ntest('Cannot use invalid \"binary\" with stderr', testInvalidBinary, 2, 'binary', 'generator', execa);\ntest('Cannot use invalid \"binary\" with stdio[*]', testInvalidBinary, 3, 'binary', 'generator', execa);\ntest('Cannot use invalid \"objectMode\" with stdin, generators', testInvalidBinary, 0, 'objectMode', 'generator', execa);\ntest('Cannot use invalid \"objectMode\" with stdout, generators', testInvalidBinary, 1, 'objectMode', 'generator', execa);\ntest('Cannot use invalid \"objectMode\" with stderr, generators', testInvalidBinary, 2, 'objectMode', 'generator', execa);\ntest('Cannot use invalid \"objectMode\" with stdio[*], generators', testInvalidBinary, 3, 'objectMode', 'generator', execa);\ntest('Cannot use invalid \"binary\" with stdin, sync', testInvalidBinary, 0, 'binary', 'generator', execaSync);\ntest('Cannot use invalid \"binary\" with stdout, sync', testInvalidBinary, 1, 'binary', 'generator', execaSync);\ntest('Cannot use invalid \"binary\" with stderr, sync', testInvalidBinary, 2, 'binary', 'generator', execaSync);\ntest('Cannot use invalid \"binary\" with stdio[*], sync', testInvalidBinary, 3, 'binary', 'generator', execaSync);\ntest('Cannot use invalid \"objectMode\" with stdin, generators, sync', testInvalidBinary, 0, 'objectMode', 'generator', execaSync);\ntest('Cannot use invalid \"objectMode\" with stdout, generators, sync', testInvalidBinary, 1, 'objectMode', 'generator', execaSync);\ntest('Cannot use invalid \"objectMode\" with stderr, generators, sync', testInvalidBinary, 2, 'objectMode', 'generator', execaSync);\ntest('Cannot use invalid \"objectMode\" with stdio[*], generators, sync', testInvalidBinary, 3, 'objectMode', 'generator', execaSync);\ntest('Cannot use invalid \"objectMode\" with stdin, duplexes', testInvalidBinary, 0, 'objectMode', 'duplex', execa);\ntest('Cannot use invalid \"objectMode\" with stdout, duplexes', testInvalidBinary, 1, 'objectMode', 'duplex', execa);\ntest('Cannot use invalid \"objectMode\" with stderr, duplexes', testInvalidBinary, 2, 'objectMode', 'duplex', execa);\ntest('Cannot use invalid \"objectMode\" with stdio[*], duplexes', testInvalidBinary, 3, 'objectMode', 'duplex', execa);\ntest('Cannot use invalid \"objectMode\" with stdin, webTransforms', testInvalidBinary, 0, 'objectMode', 'webTransform', execa);\ntest('Cannot use invalid \"objectMode\" with stdout, webTransforms', testInvalidBinary, 1, 'objectMode', 'webTransform', execa);\ntest('Cannot use invalid \"objectMode\" with stderr, webTransforms', testInvalidBinary, 2, 'objectMode', 'webTransform', execa);\ntest('Cannot use invalid \"objectMode\" with stdio[*], webTransforms', testInvalidBinary, 3, 'objectMode', 'webTransform', execa);\n"
  },
  {
    "path": "test/stdio/type-undefined.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {uppercaseGenerator} from '../helpers/generator.js';\nimport {uppercaseBufferDuplex} from '../helpers/duplex.js';\nimport {uppercaseBufferWebTransform} from '../helpers/web-transform.js';\nimport {generatorsMap} from '../helpers/map.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testUndefinedOption = (t, fdNumber, optionName, type, optionValue) => {\n\tt.throws(() => {\n\t\texeca('empty.js', getStdio(fdNumber, {...generatorsMap[type].uppercase(), [optionName]: optionValue}));\n\t}, {message: /can only be defined when using a generator/});\n};\n\ntest('Cannot use \"binary\" with duplexes and stdin', testUndefinedOption, 0, 'binary', 'duplex', true);\ntest('Cannot use \"binary\" with duplexes and stdout', testUndefinedOption, 1, 'binary', 'duplex', true);\ntest('Cannot use \"binary\" with duplexes and stderr', testUndefinedOption, 2, 'binary', 'duplex', true);\ntest('Cannot use \"binary\" with duplexes and stdio[*]', testUndefinedOption, 3, 'binary', 'duplex', true);\ntest('Cannot use \"final\" with duplexes and stdin', testUndefinedOption, 0, 'final', 'duplex', uppercaseBufferDuplex().transform);\ntest('Cannot use \"final\" with duplexes and stdout', testUndefinedOption, 1, 'final', 'duplex', uppercaseBufferDuplex().transform);\ntest('Cannot use \"final\" with duplexes and stderr', testUndefinedOption, 2, 'final', 'duplex', uppercaseBufferDuplex().transform);\ntest('Cannot use \"final\" with duplexes and stdio[*]', testUndefinedOption, 3, 'final', 'duplex', uppercaseBufferDuplex().transform);\ntest('Cannot use \"binary\" with webTransforms and stdin', testUndefinedOption, 0, 'binary', 'webTransform', true);\ntest('Cannot use \"binary\" with webTransforms and stdout', testUndefinedOption, 1, 'binary', 'webTransform', true);\ntest('Cannot use \"binary\" with webTransforms and stderr', testUndefinedOption, 2, 'binary', 'webTransform', true);\ntest('Cannot use \"binary\" with webTransforms and stdio[*]', testUndefinedOption, 3, 'binary', 'webTransform', true);\ntest('Cannot use \"final\" with webTransforms and stdin', testUndefinedOption, 0, 'final', 'webTransform', uppercaseBufferWebTransform().transform);\ntest('Cannot use \"final\" with webTransforms and stdout', testUndefinedOption, 1, 'final', 'webTransform', uppercaseBufferWebTransform().transform);\ntest('Cannot use \"final\" with webTransforms and stderr', testUndefinedOption, 2, 'final', 'webTransform', uppercaseBufferWebTransform().transform);\ntest('Cannot use \"final\" with webTransforms and stdio[*]', testUndefinedOption, 3, 'final', 'webTransform', uppercaseBufferWebTransform().transform);\n\nconst testUndefinedFinal = (t, fdNumber, type, useTransform) => {\n\tt.throws(() => {\n\t\texeca('empty.js', getStdio(fdNumber, {\n\t\t\ttransform: useTransform ? uppercaseGenerator().transform : undefined,\n\t\t\tfinal: generatorsMap[type].uppercase().transform,\n\t\t}));\n\t}, {message: type === 'duplex' ? /must not be a Duplex/ : /must not be a web TransformStream/});\n};\n\ntest('Cannot use \"final\" with duplexes and stdin, without transform', testUndefinedFinal, 0, 'duplex', false);\ntest('Cannot use \"final\" with duplexes and stdout, without transform', testUndefinedFinal, 1, 'duplex', false);\ntest('Cannot use \"final\" with duplexes and stderr, without transform', testUndefinedFinal, 2, 'duplex', false);\ntest('Cannot use \"final\" with duplexes and stdio[*], without transform', testUndefinedFinal, 3, 'duplex', false);\ntest('Cannot use \"final\" with duplexes and stdin, with transform', testUndefinedFinal, 0, 'duplex', true);\ntest('Cannot use \"final\" with duplexes and stdout, with transform', testUndefinedFinal, 1, 'duplex', true);\ntest('Cannot use \"final\" with duplexes and stderr, with transform', testUndefinedFinal, 2, 'duplex', true);\ntest('Cannot use \"final\" with duplexes and stdio[*], with transform', testUndefinedFinal, 3, 'duplex', true);\ntest('Cannot use \"final\" with webTransforms and stdin, without transform', testUndefinedFinal, 0, 'webTransform', false);\ntest('Cannot use \"final\" with webTransforms and stdout, without transform', testUndefinedFinal, 1, 'webTransform', false);\ntest('Cannot use \"final\" with webTransforms and stderr, without transform', testUndefinedFinal, 2, 'webTransform', false);\ntest('Cannot use \"final\" with webTransforms and stdio[*], without transform', testUndefinedFinal, 3, 'webTransform', false);\ntest('Cannot use \"final\" with webTransforms and stdin, with transform', testUndefinedFinal, 0, 'webTransform', true);\ntest('Cannot use \"final\" with webTransforms and stdout, with transform', testUndefinedFinal, 1, 'webTransform', true);\ntest('Cannot use \"final\" with webTransforms and stderr, with transform', testUndefinedFinal, 2, 'webTransform', true);\ntest('Cannot use \"final\" with webTransforms and stdio[*], with transform', testUndefinedFinal, 3, 'webTransform', true);\n\nconst testSyncMethodsDuplex = (t, fdNumber, type) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, generatorsMap[type].uppercase()));\n\t}, {message: type === 'duplex' ? /cannot be a Duplex stream/ : /cannot be a web TransformStream/});\n};\n\ntest('Cannot use duplexes with sync methods and stdin', testSyncMethodsDuplex, 0, 'duplex');\ntest('Cannot use duplexes with sync methods and stdout', testSyncMethodsDuplex, 1, 'duplex');\ntest('Cannot use duplexes with sync methods and stderr', testSyncMethodsDuplex, 2, 'duplex');\ntest('Cannot use duplexes with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'duplex');\ntest('Cannot use webTransforms with sync methods and stdin', testSyncMethodsDuplex, 0, 'webTransform');\ntest('Cannot use webTransforms with sync methods and stdout', testSyncMethodsDuplex, 1, 'webTransform');\ntest('Cannot use webTransforms with sync methods and stderr', testSyncMethodsDuplex, 2, 'webTransform');\ntest('Cannot use webTransforms with sync methods and stdio[*]', testSyncMethodsDuplex, 3, 'webTransform');\n"
  },
  {
    "path": "test/stdio/typed-array.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {foobarUint8Array, foobarBuffer, foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testUint8Array = async (t, fdNumber, stdioOption, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, stdioOption));\n\tt.is(stdout, foobarString);\n};\n\ntest('stdin option can be a Uint8Array', testUint8Array, 0, foobarUint8Array, execa);\ntest('stdio[*] option can be a Uint8Array', testUint8Array, 3, foobarUint8Array, execa);\ntest('stdin option can be a Uint8Array - sync', testUint8Array, 0, foobarUint8Array, execaSync);\ntest('stdin option can be a Buffer', testUint8Array, 0, foobarBuffer, execa);\ntest('stdio[*] option can be a Buffer', testUint8Array, 3, foobarBuffer, execa);\ntest('stdin option can be a Buffer - sync', testUint8Array, 0, foobarBuffer, execaSync);\n\nconst testNoUint8ArrayOutput = (t, fdNumber, stdioOption, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', getStdio(fdNumber, stdioOption));\n\t}, {message: /cannot be a Uint8Array/});\n};\n\ntest('stdout option cannot be a Uint8Array', testNoUint8ArrayOutput, 1, foobarUint8Array, execa);\ntest('stderr option cannot be a Uint8Array', testNoUint8ArrayOutput, 2, foobarUint8Array, execa);\ntest('stdout option cannot be a Uint8Array - sync', testNoUint8ArrayOutput, 1, foobarUint8Array, execaSync);\ntest('stderr option cannot be a Uint8Array - sync', testNoUint8ArrayOutput, 2, foobarUint8Array, execaSync);\ntest('stdout option cannot be a Buffer', testNoUint8ArrayOutput, 1, foobarBuffer, execa);\ntest('stderr option cannot be a Buffer', testNoUint8ArrayOutput, 2, foobarBuffer, execa);\ntest('stdout option cannot be a Buffer - sync', testNoUint8ArrayOutput, 1, foobarBuffer, execaSync);\ntest('stderr option cannot be a Buffer - sync', testNoUint8ArrayOutput, 2, foobarBuffer, execaSync);\n"
  },
  {
    "path": "test/stdio/web-stream.js",
    "content": "import {Readable} from 'node:stream';\nimport {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\n\nsetFixtureDirectory();\n\nconst testReadableStream = async (t, fdNumber) => {\n\tconst readableStream = Readable.toWeb(Readable.from('foobar'));\n\tconst {stdout} = await execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, readableStream));\n\tt.is(stdout, 'foobar');\n};\n\ntest('stdin can be a ReadableStream', testReadableStream, 0);\ntest('stdio[*] can be a ReadableStream', testReadableStream, 3);\n\nconst testWritableStream = async (t, fdNumber) => {\n\tconst result = [];\n\tconst writableStream = new WritableStream({\n\t\twrite(chunk) {\n\t\t\tresult.push(chunk);\n\t\t},\n\t});\n\tawait execa('noop-fd.js', [`${fdNumber}`, 'foobar'], getStdio(fdNumber, writableStream));\n\tt.is(result.join(''), 'foobar');\n};\n\ntest('stdout can be a WritableStream', testWritableStream, 1);\ntest('stderr can be a WritableStream', testWritableStream, 2);\ntest('stdio[*] can be a WritableStream', testWritableStream, 3);\n\nconst testWebStreamSync = (t, StreamClass, fdNumber, optionName) => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', getStdio(fdNumber, new StreamClass()));\n\t}, {message: `The \\`${optionName}\\` option cannot be a web stream with synchronous methods.`});\n};\n\ntest('stdin cannot be a ReadableStream - sync', testWebStreamSync, ReadableStream, 0, 'stdin');\ntest('stdio[*] cannot be a ReadableStream - sync', testWebStreamSync, ReadableStream, 3, 'stdio[3]');\ntest('stdout cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 1, 'stdout');\ntest('stderr cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 2, 'stderr');\ntest('stdio[*] cannot be a WritableStream - sync', testWebStreamSync, WritableStream, 3, 'stdio[3]');\n\nconst testLongWritableStream = async (t, fdNumber) => {\n\tlet result = false;\n\tconst writableStream = new WritableStream({\n\t\tasync close() {\n\t\t\tawait setImmediate();\n\t\t\tresult = true;\n\t\t},\n\t});\n\tawait execa('empty.js', getStdio(fdNumber, writableStream));\n\tt.true(result);\n};\n\ntest('stdout waits for WritableStream completion', testLongWritableStream, 1);\ntest('stderr waits for WritableStream completion', testLongWritableStream, 2);\ntest('stdio[*] waits for WritableStream completion', testLongWritableStream, 3);\n\nconst testWritableStreamError = async (t, fdNumber) => {\n\tconst cause = new Error('foobar');\n\tconst writableStream = new WritableStream({\n\t\tstart(controller) {\n\t\t\tcontroller.error(cause);\n\t\t},\n\t});\n\tconst error = await t.throwsAsync(execa('noop.js', getStdio(fdNumber, writableStream)));\n\tt.is(error.cause, cause);\n};\n\ntest('stdout option handles errors in WritableStream', testWritableStreamError, 1);\ntest('stderr option handles errors in WritableStream', testWritableStreamError, 2);\ntest('stdio[*] option handles errors in WritableStream', testWritableStreamError, 3);\n\nconst testReadableStreamError = async (t, fdNumber) => {\n\tconst cause = new Error('foobar');\n\tconst readableStream = new ReadableStream({\n\t\tstart(controller) {\n\t\t\tcontroller.error(cause);\n\t\t},\n\t});\n\tconst error = await t.throwsAsync(execa('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, readableStream)));\n\tt.is(error.cause, cause);\n};\n\ntest('stdin option handles errors in ReadableStream', testReadableStreamError, 0);\ntest('stdio[*] option handles errors in ReadableStream', testReadableStreamError, 3);\n\ntest('ReadableStream with stdin is canceled on subprocess exit', async t => {\n\tlet readableStream;\n\tconst promise = new Promise(resolve => {\n\t\treadableStream = new ReadableStream({cancel: resolve});\n\t});\n\tawait t.throwsAsync(execa('stdin.js', {stdin: readableStream, timeout: 1}), {message: /timed out/});\n\tawait promise;\n});\n"
  },
  {
    "path": "test/stdio/web-transform.js",
    "content": "import {promisify} from 'node:util';\nimport {gunzip} from 'node:zlib';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUtf16Uint8Array, foobarUint8Array} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\ntest('Can use CompressionStream()', async t => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: new CompressionStream('gzip'), encoding: 'buffer'});\n\tconst decompressedStdout = await promisify(gunzip)(stdout);\n\tt.is(decompressedStdout.toString(), foobarString);\n});\n\ntest('Can use TextDecoderStream()', async t => {\n\tconst {stdout} = await execa('stdin.js', {\n\t\tinput: foobarUtf16Uint8Array,\n\t\tstdout: new TextDecoderStream('utf-16le'),\n\t\tencoding: 'buffer',\n\t});\n\tt.deepEqual(stdout, foobarUint8Array);\n});\n"
  },
  {
    "path": "test/terminate/cancel.js",
    "content": "import {once, getEventListeners} from 'node:events';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testValidCancelSignal = (t, cancelSignal) => {\n\tt.throws(() => {\n\t\texeca('empty.js', {cancelSignal});\n\t}, {message: /must be an AbortSignal/});\n};\n\ntest('cancelSignal option cannot be AbortController', testValidCancelSignal, new AbortController());\ntest('cancelSignal option cannot be {}', testValidCancelSignal, {});\ntest('cancelSignal option cannot be null', testValidCancelSignal, null);\ntest('cancelSignal option cannot be a symbol', testValidCancelSignal, Symbol('test'));\n\ntest('result.isCanceled is false when abort isn\\'t called (success)', async t => {\n\tconst {isCanceled, isGracefullyCanceled} = await execa('noop.js');\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\ntest('result.isCanceled is false when abort isn\\'t called (failure)', async t => {\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(execa('fail.js'));\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\ntest('result.isCanceled is false when abort isn\\'t called in sync mode (success)', t => {\n\tconst {isCanceled, isGracefullyCanceled} = execaSync('noop.js');\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\ntest('result.isCanceled is false when abort isn\\'t called in sync mode (failure)', t => {\n\tconst {isCanceled, isGracefullyCanceled} = t.throws(() => {\n\t\texecaSync('fail.js');\n\t});\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\nconst testCancelSuccess = async (t, options) => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('noop.js', {cancelSignal: abortController.signal, ...options});\n\tabortController.abort();\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n};\n\ntest('error.isCanceled is true when abort is used', testCancelSuccess, {});\ntest('gracefulCancel can be false with cancelSignal', testCancelSuccess, {gracefulCancel: false});\ntest('ipc can be false with cancelSignal', testCancelSuccess, {ipc: false});\ntest('serialization can be \"json\" with cancelSignal', testCancelSuccess, {ipc: true, serialization: 'json'});\n\ntest('error.isCanceled is false when kill method is used', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('noop.js', {cancelSignal: abortController.signal});\n\tsubprocess.kill();\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(subprocess);\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\ntest('calling abort is considered a signal termination', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('forever.js', {cancelSignal: abortController.signal});\n\tawait once(subprocess, 'spawn');\n\tabortController.abort();\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, signal} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n});\n\ntest('cancelSignal can already be aborted', async t => {\n\tconst cancelSignal = AbortSignal.abort();\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, signal} = await t.throwsAsync(execa('forever.js', {cancelSignal}));\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n\tt.deepEqual(getEventListeners(cancelSignal, 'abort'), []);\n});\n\ntest('calling abort does not emit the \"error\" event', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('forever.js', {cancelSignal: abortController.signal});\n\tlet error;\n\tsubprocess.once('error', errorArgument => {\n\t\terror = errorArgument;\n\t});\n\tabortController.abort();\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.is(error, undefined);\n});\n\ntest('calling abort cleans up listeners on cancelSignal, called', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('forever.js', {cancelSignal: abortController.signal});\n\tt.is(getEventListeners(abortController.signal, 'abort').length, 1);\n\tabortController.abort();\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.is(getEventListeners(abortController.signal, 'abort').length, 0);\n});\n\ntest('calling abort cleans up listeners on cancelSignal, not called', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('noop.js', {cancelSignal: abortController.signal});\n\tt.is(getEventListeners(abortController.signal, 'abort').length, 1);\n\tawait subprocess;\n\tt.is(getEventListeners(abortController.signal, 'abort').length, 0);\n});\n\ntest('calling abort cleans up listeners on cancelSignal, already aborted', async t => {\n\tconst cancelSignal = AbortSignal.abort();\n\tconst subprocess = execa('noop.js', {cancelSignal});\n\tt.is(getEventListeners(cancelSignal, 'abort').length, 0);\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.is(getEventListeners(cancelSignal, 'abort').length, 0);\n});\n\ntest('calling abort throws an error with message \"Command was canceled\"', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('noop.js', {cancelSignal: abortController.signal});\n\tabortController.abort();\n\tawait t.throwsAsync(subprocess, {message: /Command was canceled/});\n});\n\ntest('calling abort with no argument keeps error properties', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('empty.js', {cancelSignal: abortController.signal});\n\tabortController.abort();\n\tconst {cause, originalMessage, shortMessage, message} = await t.throwsAsync(subprocess);\n\tt.is(cause.message, 'This operation was aborted');\n\tt.is(cause.name, 'AbortError');\n\tt.is(originalMessage, 'This operation was aborted');\n\tt.is(shortMessage, 'Command was canceled: empty.js\\nThis operation was aborted');\n\tt.is(message, 'Command was canceled: empty.js\\nThis operation was aborted');\n});\n\ntest('calling abort with an error instance keeps error properties', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('empty.js', {cancelSignal: abortController.signal});\n\tconst error = new Error(foobarString);\n\terror.code = foobarString;\n\tabortController.abort(error);\n\tconst {cause, originalMessage, shortMessage, message, code} = await t.throwsAsync(subprocess);\n\tt.is(cause, error);\n\tt.is(originalMessage, foobarString);\n\tt.is(shortMessage, `Command was canceled: empty.js\\n${foobarString}`);\n\tt.is(message, `Command was canceled: empty.js\\n${foobarString}`);\n\tt.is(code, foobarString);\n});\n\ntest('calling abort with null keeps error properties', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('empty.js', {cancelSignal: abortController.signal});\n\tabortController.abort(null);\n\tconst {cause, originalMessage, shortMessage, message} = await t.throwsAsync(subprocess);\n\tt.is(cause, null);\n\tt.is(originalMessage, 'null');\n\tt.is(shortMessage, 'Command was canceled: empty.js\\nnull');\n\tt.is(message, 'Command was canceled: empty.js\\nnull');\n});\n\ntest('calling abort twice should show the same behaviour as calling it once', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('noop.js', {cancelSignal: abortController.signal});\n\tabortController.abort();\n\tabortController.abort();\n\tconst {isCanceled, isGracefullyCanceled} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\ntest('calling abort on a successfully completed subprocess does not make result.isCanceled true', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('noop.js', {cancelSignal: abortController.signal});\n\tconst {isCanceled, isGracefullyCanceled} = await subprocess;\n\tabortController.abort();\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n});\n\ntest('Throws when using the former \"signal\" option name', t => {\n\tconst abortController = new AbortController();\n\tt.throws(() => {\n\t\texeca('empty.js', {signal: abortController.signal});\n\t}, {message: /renamed to \"cancelSignal\"/});\n});\n\ntest('Cannot use cancelSignal, sync', t => {\n\tconst abortController = new AbortController();\n\tt.throws(() => {\n\t\texecaSync('empty.js', {cancelSignal: abortController.signal});\n\t}, {message: /The \"cancelSignal\" option cannot be used/});\n});\n"
  },
  {
    "path": "test/terminate/cleanup.js",
    "content": "import process from 'node:process';\nimport {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport isRunning from 'is-running';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {foobarString} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst isWindows = process.platform === 'win32';\n\n// When subprocess exits before current process\nconst spawnAndExit = async (t, worker, cleanup, detached) => {\n\tconst {nestedResult: {stdout}} = await nestedSubprocess('noop-fd.js', ['1', foobarString], {worker, cleanup, detached});\n\tt.is(stdout, foobarString);\n};\n\ntest('spawnAndExit', spawnAndExit, false, false, false);\ntest('spawnAndExit cleanup', spawnAndExit, false, true, false);\ntest('spawnAndExit detached', spawnAndExit, false, false, true);\ntest('spawnAndExit cleanup detached', spawnAndExit, false, true, true);\ntest('spawnAndExit, worker', spawnAndExit, true, false, false);\ntest('spawnAndExit cleanup, worker', spawnAndExit, true, true, false);\ntest('spawnAndExit detached, worker', spawnAndExit, true, false, true);\ntest('spawnAndExit cleanup detached, worker', spawnAndExit, true, true, true);\n\n// When current process exits before subprocess\nconst spawnAndKill = async (t, [signal, cleanup, detached, isKilled]) => {\n\tconst subprocess = execa('ipc-send-pid.js', [cleanup, detached], {stdio: 'ignore', ipc: true});\n\n\tconst pid = await subprocess.getOneMessage();\n\tt.true(Number.isInteger(pid));\n\tt.true(isRunning(pid));\n\n\tprocess.kill(subprocess.pid, signal);\n\n\tawait t.throwsAsync(subprocess);\n\tt.false(isRunning(subprocess.pid));\n\n\tif (isKilled) {\n\t\tawait Promise.race([\n\t\t\tsetTimeout(1e4, undefined, {ref: false}),\n\t\t\tpollForSubprocessExit(pid),\n\t\t]);\n\t\tt.is(isRunning(pid), false);\n\t} else {\n\t\tt.is(isRunning(pid), true);\n\t\tprocess.kill(pid, 'SIGKILL');\n\t}\n};\n\nconst pollForSubprocessExit = async pid => {\n\twhile (isRunning(pid)) {\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait setTimeout(100);\n\t}\n};\n\n// Without `options.cleanup`:\n//   - on Windows subprocesses are killed if `options.detached: false`, but not\n//     if `options.detached: true`\n//   - on Linux subprocesses are never killed regardless of `options.detached`\n// With `options.cleanup`, subprocesses are always killed\n//   - `options.cleanup` with SIGKILL is a noop, since it cannot be handled\ntest('spawnAndKill SIGTERM', spawnAndKill, ['SIGTERM', false, false, isWindows]);\ntest('spawnAndKill SIGKILL', spawnAndKill, ['SIGKILL', false, false, isWindows]);\ntest('spawnAndKill cleanup SIGTERM', spawnAndKill, ['SIGTERM', true, false, true]);\ntest('spawnAndKill cleanup SIGKILL', spawnAndKill, ['SIGKILL', true, false, isWindows]);\ntest('spawnAndKill detached SIGTERM', spawnAndKill, ['SIGTERM', false, true, false]);\ntest('spawnAndKill detached SIGKILL', spawnAndKill, ['SIGKILL', false, true, false]);\ntest('spawnAndKill cleanup detached SIGTERM', spawnAndKill, ['SIGTERM', true, true, false]);\ntest('spawnAndKill cleanup detached SIGKILL', spawnAndKill, ['SIGKILL', true, true, false]);\n\n// See #128\ntest('removes exit handler on exit', async t => {\n\t// @todo this relies on `signal-exit` internals\n\tconst exitListeners = globalThis[Symbol.for('signal-exit emitter')].listeners.exit;\n\n\tconst subprocess = execa('noop.js');\n\tconst listener = exitListeners.at(-1);\n\n\tawait subprocess;\n\tt.false(exitListeners.includes(listener));\n});\n\ntest('detach subprocess', async t => {\n\tconst {stdout} = await execa('detach.js');\n\tconst pid = Number(stdout);\n\tt.true(Number.isInteger(pid));\n\tt.true(isRunning(pid));\n\n\tprocess.kill(pid, 'SIGKILL');\n});\n\ntest('Cannot use \"detached\" option, sync', t => {\n\tt.throws(() => {\n\t\texecaSync('empty.js', {detached: true});\n\t}, {message: /The \"detached: true\" option cannot be used/});\n});\n"
  },
  {
    "path": "test/terminate/graceful.js",
    "content": "import {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {mockSendIoError} from '../helpers/ipc.js';\n\nsetFixtureDirectory();\n\ntest('cancelSignal cannot be undefined with gracefulCancel', t => {\n\tt.throws(() => {\n\t\texeca('empty.js', {gracefulCancel: true});\n\t}, {message: /The `cancelSignal` option must be defined/});\n});\n\ntest('ipc cannot be false with gracefulCancel', t => {\n\tt.throws(() => {\n\t\texeca('empty.js', {gracefulCancel: true, cancelSignal: AbortSignal.abort(), ipc: false});\n\t}, {message: /The `ipc` option cannot be false/});\n});\n\ntest('serialization cannot be \"json\" with gracefulCancel', t => {\n\tt.throws(() => {\n\t\texeca('empty.js', {gracefulCancel: true, cancelSignal: AbortSignal.abort(), serialization: 'json'});\n\t}, {message: /The `serialization` option cannot be 'json'/});\n});\n\ntest('Current process can send a message right away', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('ipc-echo.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tawait subprocess.sendMessage(foobarString);\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Current process can receive a message right away', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('ipc-send.js', {cancelSignal: controller.signal, gracefulCancel: true});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tconst {ipcOutput} = await subprocess;\n\tt.deepEqual(ipcOutput, [foobarString]);\n});\n\ntest('Does not disconnect during I/O errors when sending the abort reason', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('ipc-echo.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tconst error = mockSendIoError(subprocess);\n\tcontroller.abort(foobarString);\n\tawait setTimeout(0);\n\tt.true(subprocess.connected);\n\tsubprocess.kill();\n\tconst {isCanceled, isGracefullyCanceled, signal, ipcOutput, cause} = await t.throwsAsync(subprocess);\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.is(signal, 'SIGTERM');\n\tt.deepEqual(ipcOutput, []);\n\tt.is(cause, error);\n});\n\nclass AbortError extends Error {\n\tname = 'AbortError';\n}\n\ntest('Abort reason is sent to the subprocess', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-send.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tconst error = new AbortError(foobarString);\n\tcontroller.abort(error);\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, cause, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.is(cause, error);\n\tt.is(ipcOutput[0].message, error.message);\n\tt.is(ipcOutput[0].stack, error.stack);\n\tt.is(ipcOutput[0].name, 'Error');\n});\n\ntest('Abort default reason is sent to the subprocess', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('graceful-send.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tcontroller.abort();\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, cause, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tconst {reason} = controller.signal;\n\tt.is(cause.stack, reason.stack);\n\tt.is(ipcOutput[0].message, reason.message);\n\tt.is(ipcOutput[0].stack, reason.stack);\n});\n\ntest('Fail when sending non-serializable abort reason', async t => {\n\tconst controller = new AbortController();\n\tconst subprocess = execa('ipc-echo.js', {cancelSignal: controller.signal, gracefulCancel: true, forceKillAfterDelay: false});\n\tcontroller.abort(() => {});\n\tawait setTimeout(0);\n\tt.true(subprocess.connected);\n\tawait subprocess.sendMessage(foobarString);\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, exitCode, cause, ipcOutput} = await t.throwsAsync(subprocess);\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.is(exitCode, 0);\n\tt.deepEqual(ipcOutput, [foobarString]);\n\tt.is(cause.message, '`cancelSignal`\\'s `controller.abort()`\\'s argument type is invalid: the message cannot be serialized: () => {}.');\n\tt.is(cause.cause.message, '() => {} could not be cloned.');\n});\n\ntest('timeout does not use graceful cancelSignal', async t => {\n\tconst controller = new AbortController();\n\tconst {timedOut, isCanceled, isGracefullyCanceled, isTerminated, signal, exitCode, shortMessage, ipcOutput} = await t.throwsAsync(execa('graceful-send.js', {cancelSignal: controller.signal, gracefulCancel: true, timeout: 1}));\n\tt.true(timedOut);\n\tt.false(isCanceled);\n\tt.false(isGracefullyCanceled);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n\tt.is(exitCode, undefined);\n\tt.is(shortMessage, 'Command timed out after 1 milliseconds: graceful-send.js');\n\tt.deepEqual(ipcOutput, []);\n});\n\ntest('error on graceful cancelSignal on non-0 exit code', async t => {\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, isForcefullyTerminated, exitCode, shortMessage} = await t.throwsAsync(execa('wait-fail.js', {cancelSignal: AbortSignal.abort(''), gracefulCancel: true, forceKillAfterDelay: false}));\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.false(isTerminated);\n\tt.false(isForcefullyTerminated);\n\tt.is(exitCode, 2);\n\tt.is(shortMessage, 'Command was gracefully canceled with exit code 2: wait-fail.js');\n});\n\ntest('error on graceful cancelSignal on forceful termination', async t => {\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, signal, isForcefullyTerminated, exitCode, shortMessage} = await t.throwsAsync(execa('forever.js', {cancelSignal: AbortSignal.abort(''), gracefulCancel: true, forceKillAfterDelay: 1}));\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGKILL');\n\tt.true(isForcefullyTerminated);\n\tt.is(exitCode, undefined);\n\tt.is(shortMessage, 'Command was gracefully canceled and was forcefully terminated after 1 milliseconds: forever.js');\n});\n\ntest('error on graceful cancelSignal on non-forceful termination', async t => {\n\tconst subprocess = execa('ipc-send-get.js', {cancelSignal: AbortSignal.abort(''), gracefulCancel: true, forceKillAfterDelay: 1e6});\n\tt.is(await subprocess.getOneMessage(), foobarString);\n\tsubprocess.kill();\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, signal, isForcefullyTerminated, exitCode, shortMessage} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n\tt.false(isForcefullyTerminated);\n\tt.is(exitCode, undefined);\n\tt.is(shortMessage, 'Command was gracefully canceled with SIGTERM (Termination): ipc-send-get.js');\n});\n\ntest('`forceKillAfterDelay: false` with the \"cancelSignal\" option when graceful', async t => {\n\tconst subprocess = execa('forever.js', {cancelSignal: AbortSignal.abort(''), gracefulCancel: true, forceKillAfterDelay: false});\n\tawait setTimeout(6e3);\n\tsubprocess.kill('SIGKILL');\n\tconst {isCanceled, isGracefullyCanceled, isTerminated, signal, isForcefullyTerminated, exitCode, shortMessage} = await t.throwsAsync(subprocess);\n\tt.true(isCanceled);\n\tt.true(isGracefullyCanceled);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGKILL');\n\tt.false(isForcefullyTerminated);\n\tt.is(exitCode, undefined);\n\tt.is(shortMessage, 'Command was gracefully canceled with SIGKILL (Forced termination): forever.js');\n});\n\ntest('subprocess.getCancelSignal() is not defined', async t => {\n\tconst subprocess = execa('empty.js', {cancelSignal: AbortSignal.abort(''), gracefulCancel: true});\n\tt.is(subprocess.getCancelSignal, undefined);\n\tawait t.throwsAsync(subprocess);\n});\n"
  },
  {
    "path": "test/terminate/kill-error.js",
    "content": "import {once} from 'node:events';\nimport {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport isRunning from 'is-running';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\ntest('.kill(error) propagates error', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst originalMessage = 'test';\n\tconst cause = new Error(originalMessage);\n\tt.true(subprocess.kill(cause));\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.true(cause.stack.includes(import.meta.url));\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, 'SIGTERM');\n\tt.true(error.isTerminated);\n\tt.is(error.originalMessage, originalMessage);\n\tt.true(error.message.includes(originalMessage));\n\tt.true(error.message.includes('was killed with SIGTERM'));\n});\n\ntest('.kill(error) uses killSignal', async t => {\n\tconst subprocess = execa('forever.js', {killSignal: 'SIGINT'});\n\tconst cause = new Error('test');\n\tsubprocess.kill(cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.signal, 'SIGINT');\n});\n\ntest('.kill(signal, error) uses signal', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst cause = new Error('test');\n\tsubprocess.kill('SIGINT', cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.signal, 'SIGINT');\n});\n\ntest('.kill(error) is a noop if subprocess already exited', async t => {\n\tconst subprocess = execa('empty.js');\n\tawait subprocess;\n\tt.false(isRunning(subprocess.pid));\n\tt.false(subprocess.kill(new Error('test')));\n});\n\ntest('.kill(error) terminates but does not change the error if the subprocess already errored but did not exit yet', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst cause = new Error('first');\n\tsubprocess.stdout.destroy(cause);\n\tawait setImmediate();\n\tconst secondError = new Error('second');\n\tt.true(subprocess.kill(secondError));\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, 'SIGTERM');\n\tt.true(error.isTerminated);\n\tt.false(error.message.includes(secondError.message));\n});\n\ntest('.kill(error) twice in a row', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst cause = new Error('first');\n\tsubprocess.kill(cause);\n\tconst secondCause = new Error('second');\n\tsubprocess.kill(secondCause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.false(error.message.includes(secondCause.message));\n});\n\ntest('.kill(error) does not emit the \"error\" event', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst cause = new Error('test');\n\tsubprocess.kill(cause);\n\tconst error = await Promise.race([t.throwsAsync(subprocess), once(subprocess, 'error')]);\n\tt.is(error.cause, cause);\n});\n"
  },
  {
    "path": "test/terminate/kill-force.js",
    "content": "import process from 'node:process';\nimport {once, defaultMaxListeners} from 'node:events';\nimport {constants} from 'node:os';\nimport {setTimeout} from 'node:timers/promises';\nimport test from 'ava';\nimport isRunning from 'is-running';\nimport {execa} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {assertMaxListeners} from '../helpers/listeners.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getEarlyErrorSubprocess} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst isWindows = process.platform === 'win32';\n\nconst spawnNoKillable = async (forceKillAfterDelay, options) => {\n\tconst subprocess = execa('no-killable.js', {\n\t\tipc: true,\n\t\tforceKillAfterDelay,\n\t\t...options,\n\t});\n\tawait subprocess.getOneMessage();\n\treturn {subprocess};\n};\n\nconst noKillableSimpleOptions = {killSignal: 'SIGWINCH', forceKillAfterDelay: 1};\nconst spawnNoKillableSimple = options => execa('forever.js', {...noKillableSimpleOptions, ...options});\n\ntest('kill(\"SIGKILL\") should terminate cleanly', async t => {\n\tconst {subprocess} = await spawnNoKillable();\n\n\tsubprocess.kill('SIGKILL');\n\n\tconst {isTerminated, signal, isForcefullyTerminated, shortMessage} = await t.throwsAsync(subprocess);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGKILL');\n\tt.false(isForcefullyTerminated);\n\tt.is(shortMessage, 'Command was killed with SIGKILL (Forced termination): no-killable.js');\n});\n\nconst testInvalidForceKill = async (t, forceKillAfterDelay) => {\n\tt.throws(() => {\n\t\texeca('empty.js', {forceKillAfterDelay});\n\t}, {instanceOf: TypeError, message: /non-negative integer/});\n};\n\ntest('`forceKillAfterDelay` should not be NaN', testInvalidForceKill, Number.NaN);\ntest('`forceKillAfterDelay` should not be negative', testInvalidForceKill, -1);\n\n// `SIGTERM` cannot be caught on Windows, and it always aborts the subprocess (like `SIGKILL` on Unix).\n// Therefore, this feature and those tests must be different on Windows.\nif (isWindows) {\n\ttest('Can call `.kill()` with `forceKillAfterDelay` on Windows', async t => {\n\t\tconst {subprocess} = await spawnNoKillable();\n\t\tsubprocess.kill();\n\n\t\tconst {isTerminated, signal, isForcefullyTerminated, shortMessage} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGTERM');\n\t\tt.false(isForcefullyTerminated);\n\t\tt.is(shortMessage, 'Command was killed with SIGTERM (Termination): no-killable.js');\n\t});\n} else {\n\tconst testNoForceKill = async (t, forceKillAfterDelay, killArgument, options) => {\n\t\tconst {subprocess} = await spawnNoKillable(forceKillAfterDelay, options);\n\n\t\tsubprocess.kill(killArgument);\n\n\t\tawait setTimeout(6e3);\n\t\tt.true(isRunning(subprocess.pid));\n\t\tsubprocess.kill('SIGKILL');\n\n\t\tconst {isTerminated, signal, isForcefullyTerminated} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.false(isForcefullyTerminated);\n\t};\n\n\ttest('`forceKillAfterDelay: false` should not kill after a timeout', testNoForceKill, false);\n\ttest('`forceKillAfterDelay` should not kill after a timeout with other signals', testNoForceKill, true, 'SIGINT');\n\ttest('`forceKillAfterDelay` should not kill after a timeout with wrong killSignal string', testNoForceKill, true, 'SIGTERM', {killSignal: 'SIGINT'});\n\ttest('`forceKillAfterDelay` should not kill after a timeout with wrong killSignal number', testNoForceKill, true, constants.signals.SIGTERM, {killSignal: constants.signals.SIGINT});\n\n\t// eslint-disable-next-line max-params\n\tconst testForceKill = async (t, forceKillAfterDelay, killSignal, expectedDelay, expectedKillSignal, options) => {\n\t\tconst {subprocess} = await spawnNoKillable(forceKillAfterDelay, options);\n\n\t\tsubprocess.kill(killSignal);\n\n\t\tconst {isTerminated, signal, isForcefullyTerminated, shortMessage} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(isForcefullyTerminated);\n\t\tconst messageSuffix = killSignal instanceof Error ? `\\n${killSignal.message}` : '';\n\t\tconst signalDescription = expectedKillSignal === 'SIGINT' ? 'User interruption with CTRL-C' : 'Termination';\n\t\tt.is(shortMessage, `Command was killed with ${expectedKillSignal} (${signalDescription}) and was forcefully terminated after ${expectedDelay} milliseconds: no-killable.js${messageSuffix}`);\n\t};\n\n\ttest('`forceKillAfterDelay: number` should kill after a timeout', testForceKill, 50, undefined, 50, 'SIGTERM');\n\ttest('`forceKillAfterDelay: true` should kill after a timeout', testForceKill, true, undefined, 5e3, 'SIGTERM');\n\ttest('`forceKillAfterDelay: undefined` should kill after a timeout', testForceKill, undefined, undefined, 5e3, 'SIGTERM');\n\ttest('`forceKillAfterDelay` should kill after a timeout with SIGTERM', testForceKill, 50, 'SIGTERM', 50, 'SIGTERM');\n\ttest('`forceKillAfterDelay` should kill after a timeout with the killSignal string', testForceKill, 50, 'SIGINT', 50, 'SIGINT', {killSignal: 'SIGINT'});\n\ttest('`forceKillAfterDelay` should kill after a timeout with the killSignal string, mixed', testForceKill, 50, 'SIGINT', 50, 'SIGINT', {killSignal: constants.signals.SIGINT});\n\ttest('`forceKillAfterDelay` should kill after a timeout with the killSignal number', testForceKill, 50, constants.signals.SIGINT, 50, 'SIGINT', {killSignal: constants.signals.SIGINT});\n\ttest('`forceKillAfterDelay` should kill after a timeout with the killSignal number, mixed', testForceKill, 50, constants.signals.SIGINT, 50, 'SIGINT', {killSignal: 'SIGINT'});\n\ttest('`forceKillAfterDelay` should kill after a timeout with an error', testForceKill, 50, new Error('test'), 50, 'SIGTERM');\n\ttest('`forceKillAfterDelay` should kill after a timeout with an error and a killSignal', testForceKill, 50, new Error('test'), 50, 'SIGINT', {killSignal: 'SIGINT'});\n\n\ttest('`forceKillAfterDelay` works with the \"cancelSignal\" option', async t => {\n\t\tconst abortController = new AbortController();\n\t\tconst subprocess = spawnNoKillableSimple({cancelSignal: abortController.signal});\n\t\tawait once(subprocess, 'spawn');\n\t\tabortController.abort('');\n\t\tconst {isTerminated, signal, isCanceled, isGracefullyCanceled, isForcefullyTerminated, shortMessage} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(isCanceled);\n\t\tt.false(isGracefullyCanceled);\n\t\tt.true(isForcefullyTerminated);\n\t\tt.is(shortMessage, 'Command was canceled and was forcefully terminated after 1 milliseconds: forever.js');\n\t});\n\n\ttest('`forceKillAfterDelay` works with the \"timeout\" option', async t => {\n\t\tconst {isTerminated, signal, timedOut, isForcefullyTerminated, shortMessage} = await t.throwsAsync(spawnNoKillableSimple({timeout: 1}));\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(timedOut);\n\t\tt.true(isForcefullyTerminated);\n\t\tt.is(shortMessage, 'Command timed out after 1 milliseconds and was forcefully terminated after 1 milliseconds: forever.js');\n\t});\n\n\ttest('`forceKillAfterDelay` works with the \"maxBuffer\" option', async t => {\n\t\tconst subprocess = execa('noop-forever.js', ['.'], {...noKillableSimpleOptions, maxBuffer: 1});\n\t\tconst [chunk] = await once(subprocess.stdout, 'data');\n\t\tt.is(chunk.toString(), '.\\n');\n\t\tsubprocess.kill();\n\t\tconst {isTerminated, signal, isForcefullyTerminated, shortMessage} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(isForcefullyTerminated);\n\t\tt.is(shortMessage, 'Command\\'s stdout was larger than 1 characters and was forcefully terminated after 1 milliseconds: noop-forever.js .\\nmaxBuffer exceeded');\n\t});\n\n\ttest('`forceKillAfterDelay` works with the \"error\" event', async t => {\n\t\tconst subprocess = spawnNoKillableSimple();\n\t\tawait once(subprocess, 'spawn');\n\t\tconst error = new Error(foobarString);\n\t\terror.code = 'ECODE';\n\t\tsubprocess.emit('error', error);\n\t\tsubprocess.kill();\n\t\tconst {isTerminated, signal, isForcefullyTerminated, shortMessage, originalMessage, cause} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(isForcefullyTerminated);\n\t\tt.is(cause, error);\n\t\tt.is(originalMessage, error.message);\n\t\tt.is(shortMessage, `Command failed with ${error.code} and was forcefully terminated after 1 milliseconds: forever.js\\n${error.message}`);\n\t});\n\n\ttest.serial('Can call `.kill()` with `forceKillAfterDelay` many times without triggering the maxListeners warning', async t => {\n\t\tconst checkMaxListeners = assertMaxListeners(t);\n\n\t\tconst subprocess = spawnNoKillableSimple();\n\t\tfor (let index = 0; index < defaultMaxListeners + 1; index += 1) {\n\t\t\tsubprocess.kill();\n\t\t}\n\n\t\tconst {isTerminated, signal, isForcefullyTerminated} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(isForcefullyTerminated);\n\n\t\tcheckMaxListeners();\n\t});\n\n\ttest('Can call `.kill()` with `forceKillAfterDelay` multiple times', async t => {\n\t\tconst subprocess = spawnNoKillableSimple();\n\t\tsubprocess.kill();\n\t\tsubprocess.kill();\n\n\t\tconst {isTerminated, signal, isForcefullyTerminated} = await t.throwsAsync(subprocess);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGKILL');\n\t\tt.true(isForcefullyTerminated);\n\t});\n}\n\ntest('result.isForcefullyTerminated is false on success', async t => {\n\tconst {isForcefullyTerminated} = await execa('empty.js');\n\tt.false(isForcefullyTerminated);\n});\n\ntest('error.isForcefullyTerminated is false on spawn errors', async t => {\n\tconst {isForcefullyTerminated} = await t.throwsAsync(getEarlyErrorSubprocess());\n\tt.false(isForcefullyTerminated);\n});\n\ntest('error.isForcefullyTerminated is false when already terminated', async t => {\n\tconst abortController = new AbortController();\n\tconst final = async function * () {\n\t\ttry {\n\t\t\tawait setTimeout(1e6, undefined, {signal: abortController.signal});\n\t\t} catch {}\n\n\t\tyield * [];\n\t};\n\n\tconst subprocess = execa('forever.js', {stdout: {final}});\n\tsubprocess.kill();\n\tawait setTimeout(6e3);\n\tabortController.abort();\n\tconst {isForcefullyTerminated, isTerminated, signal} = await t.throwsAsync(subprocess);\n\tt.false(isForcefullyTerminated);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n});\n"
  },
  {
    "path": "test/terminate/kill-signal.js",
    "content": "import {once} from 'node:events';\nimport {platform} from 'node:process';\nimport {constants} from 'node:os';\nimport {setImmediate} from 'node:timers/promises';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {majorNodeVersion} from '../helpers/node-version.js';\n\nsetFixtureDirectory();\n\nconst isWindows = platform === 'win32';\n\nconst testKillSignal = async (t, killSignal) => {\n\tconst {isTerminated, signal} = await t.throwsAsync(execa('forever.js', {killSignal, timeout: 1}));\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGINT');\n};\n\ntest('Can use killSignal: \"SIGINT\"', testKillSignal, 'SIGINT');\ntest('Can use killSignal: 2', testKillSignal, constants.signals.SIGINT);\n\nconst testKillSignalSync = (t, killSignal) => {\n\tconst {isTerminated, signal} = t.throws(() => {\n\t\texecaSync('forever.js', {killSignal, timeout: 1});\n\t});\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGINT');\n};\n\ntest('Can use killSignal: \"SIGINT\", sync', testKillSignalSync, 'SIGINT');\ntest('Can use killSignal: 2, sync', testKillSignalSync, constants.signals.SIGINT);\n\ntest('Can call .kill(\"SIGTERM\")', async t => {\n\tconst subprocess = execa('forever.js');\n\tsubprocess.kill('SIGTERM');\n\tconst {isTerminated, signal} = await t.throwsAsync(subprocess);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n});\n\ntest('Can call .kill(15)', async t => {\n\tconst subprocess = execa('forever.js');\n\tsubprocess.kill(constants.signals.SIGTERM);\n\tconst {isTerminated, signal} = await t.throwsAsync(subprocess);\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n});\n\ntest('Can call .kill(0)', async t => {\n\tconst subprocess = execa('forever.js');\n\tt.true(subprocess.kill(0));\n\tsubprocess.kill();\n\tawait t.throwsAsync(subprocess);\n\tt.false(subprocess.kill(0));\n});\n\ntest('Can call `.kill()` multiple times', async t => {\n\tconst subprocess = execa('forever.js');\n\tsubprocess.kill();\n\tsubprocess.kill();\n\n\tconst {exitCode, isTerminated, signal, code} = await t.throwsAsync(subprocess);\n\t// On Windows, calling `subprocess.kill()` twice emits an `error` event on the subprocess.\n\t// This does not happen when passing an `error` argument, nor when passing a non-terminating signal.\n\t// There is no easy way to make this cross-platform, so we document the difference here.\n\tif (isWindows && majorNodeVersion === 22) {\n\t\tt.is(exitCode, undefined);\n\t\tt.false(isTerminated);\n\t\tt.is(signal, undefined);\n\t\tt.is(code, 'EPERM');\n\t} else {\n\t\tt.is(exitCode, undefined);\n\t\tt.true(isTerminated);\n\t\tt.is(signal, 'SIGTERM');\n\t\tt.is(code, undefined);\n\t}\n});\n\ntest('execa() returns a promise with kill()', async t => {\n\tconst subprocess = execa('noop.js', ['foo']);\n\tt.is(typeof subprocess.kill, 'function');\n\tawait subprocess;\n});\n\nconst testInvalidKillArgument = async (t, killArgument, secondKillArgument) => {\n\tconst subprocess = execa('empty.js');\n\tconst message = secondKillArgument instanceof Error || secondKillArgument === undefined\n\t\t? /error instance or a signal name/\n\t\t: /second argument is optional/;\n\tt.throws(() => {\n\t\tsubprocess.kill(killArgument, secondKillArgument);\n\t}, {message});\n\tawait subprocess;\n};\n\ntest('Cannot call .kill(errorObject)', testInvalidKillArgument, {name: '', message: '', stack: ''});\ntest('Cannot call .kill(errorArray)', testInvalidKillArgument, [new Error('test')]);\ntest('Cannot call .kill(undefined, true)', testInvalidKillArgument, undefined, true);\ntest('Cannot call .kill(\"SIGTERM\", true)', testInvalidKillArgument, 'SIGTERM', true);\ntest('Cannot call .kill(true, error)', testInvalidKillArgument, true, new Error('test'));\n\ntest('subprocess errors are handled before spawn', async t => {\n\tconst subprocess = execa('forever.js');\n\tconst cause = new Error('test');\n\tsubprocess.emit('error', cause);\n\tsubprocess.kill();\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, undefined);\n\tt.false(error.isTerminated);\n});\n\ntest('subprocess errors are handled after spawn', async t => {\n\tconst subprocess = execa('forever.js');\n\tawait once(subprocess, 'spawn');\n\tconst cause = new Error('test');\n\tsubprocess.emit('error', cause);\n\tsubprocess.kill();\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, 'SIGTERM');\n\tt.true(error.isTerminated);\n});\n\ntest('subprocess double errors are handled after spawn', async t => {\n\tconst abortController = new AbortController();\n\tconst subprocess = execa('forever.js', {cancelSignal: abortController.signal});\n\tawait once(subprocess, 'spawn');\n\tconst cause = new Error('test');\n\tsubprocess.emit('error', cause);\n\tawait setImmediate();\n\tabortController.abort();\n\tsubprocess.emit('error', cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.is(error.exitCode, undefined);\n\tt.is(error.signal, 'SIGTERM');\n\tt.true(error.isTerminated);\n});\n\ntest('subprocess errors use killSignal', async t => {\n\tconst subprocess = execa('forever.js', {killSignal: 'SIGINT'});\n\tawait once(subprocess, 'spawn');\n\tconst cause = new Error('test');\n\tsubprocess.emit('error', cause);\n\tsubprocess.kill();\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.true(error.isTerminated);\n\tt.is(error.signal, 'SIGINT');\n});\n"
  },
  {
    "path": "test/terminate/signal.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst VALIDATION_MESSAGES = {\n\tstring: 'this signal name does not exist',\n\tinteger: 'this signal integer does not exist',\n\tother: 'it must be a string or an integer',\n\trename: 'please rename it to',\n\tzero: '0 cannot be used',\n};\n\nconst validateMessage = (t, message, type) => {\n\tt.true(message.includes(VALIDATION_MESSAGES[type]));\n\n\tif (type !== 'rename' && type !== 'zero') {\n\t\tt.true(message.includes('Available signal names: \\'SIGABRT\\', '));\n\t\tt.true(message.includes('Available signal numbers: 1, '));\n\t}\n};\n\nconst testInvalidKillSignal = (t, killSignal, type, execaMethod) => {\n\tconst {message} = t.throws(() => {\n\t\texecaMethod('empty.js', {killSignal});\n\t});\n\tt.true(message.includes('Invalid option `killSignal`'));\n\tvalidateMessage(t, message, type);\n};\n\ntest('Cannot use killSignal: \"SIGOTHER\"', testInvalidKillSignal, 'SIGOTHER', 'string', execa);\ntest('Cannot use killSignal: \"Sigterm\"', testInvalidKillSignal, 'Sigterm', 'rename', execa);\ntest('Cannot use killSignal: \"sigterm\"', testInvalidKillSignal, 'sigterm', 'rename', execa);\ntest('Cannot use killSignal: -1', testInvalidKillSignal, -1, 'integer', execa);\ntest('Cannot use killSignal: 200', testInvalidKillSignal, 200, 'integer', execa);\ntest('Cannot use killSignal: 1n', testInvalidKillSignal, 1n, 'other', execa);\ntest('Cannot use killSignal: 1.5', testInvalidKillSignal, 1.5, 'other', execa);\ntest('Cannot use killSignal: Infinity', testInvalidKillSignal, Number.POSITIVE_INFINITY, 'other', execa);\ntest('Cannot use killSignal: NaN', testInvalidKillSignal, Number.NaN, 'other', execa);\ntest('Cannot use killSignal: false', testInvalidKillSignal, false, 'other', execa);\ntest('Cannot use killSignal: null', testInvalidKillSignal, null, 'other', execa);\ntest('Cannot use killSignal: symbol', testInvalidKillSignal, Symbol('test'), 'other', execa);\ntest('Cannot use killSignal: {}', testInvalidKillSignal, {}, 'other', execa);\ntest('Cannot use killSignal: 0', testInvalidKillSignal, 0, 'zero', execa);\ntest('Cannot use killSignal: \"SIGOTHER\", sync', testInvalidKillSignal, 'SIGOTHER', 'string', execaSync);\ntest('Cannot use killSignal: \"Sigterm\", sync', testInvalidKillSignal, 'Sigterm', 'rename', execaSync);\ntest('Cannot use killSignal: \"sigterm\", sync', testInvalidKillSignal, 'sigterm', 'rename', execaSync);\ntest('Cannot use killSignal: -1, sync', testInvalidKillSignal, -1, 'integer', execaSync);\ntest('Cannot use killSignal: 200, sync', testInvalidKillSignal, 200, 'integer', execaSync);\ntest('Cannot use killSignal: 1.5, sync', testInvalidKillSignal, 1.5, 'other', execaSync);\ntest('Cannot use killSignal: Infinity, sync', testInvalidKillSignal, Number.POSITIVE_INFINITY, 'other', execaSync);\ntest('Cannot use killSignal: NaN, sync', testInvalidKillSignal, Number.NaN, 'other', execaSync);\ntest('Cannot use killSignal: null, sync', testInvalidKillSignal, null, 'other', execaSync);\ntest('Cannot use killSignal: symbol, sync', testInvalidKillSignal, Symbol('test'), 'other', execaSync);\ntest('Cannot use killSignal: {}, sync', testInvalidKillSignal, {}, 'other', execaSync);\ntest('Cannot use killSignal: 0, sync', testInvalidKillSignal, 0, 'zero', execaSync);\n\nconst testInvalidSignalArgument = async (t, signal, type) => {\n\tconst subprocess = execa('empty.js');\n\tconst {message} = t.throws(() => {\n\t\tsubprocess.kill(signal);\n\t});\n\n\tif (type === 'other') {\n\t\tt.true(message.includes('must be an error instance or a signal name string/integer'));\n\t} else {\n\t\tt.true(message.includes('Invalid `subprocess.kill()`\\'s argument'));\n\t\tvalidateMessage(t, message, type);\n\t}\n\n\tawait subprocess;\n};\n\ntest('Cannot use subprocess.kill(\"SIGOTHER\")', testInvalidSignalArgument, 'SIGOTHER', 'string');\ntest('Cannot use subprocess.kill(\"Sigterm\")', testInvalidSignalArgument, 'Sigterm', 'rename');\ntest('Cannot use subprocess.kill(\"sigterm\")', testInvalidSignalArgument, 'sigterm', 'rename');\ntest('Cannot use subprocess.kill(-1)', testInvalidSignalArgument, -1, 'integer');\ntest('Cannot use subprocess.kill(200)', testInvalidSignalArgument, 200, 'integer');\ntest('Cannot use subprocess.kill(1n)', testInvalidSignalArgument, 1n, 'other');\ntest('Cannot use subprocess.kill(1.5)', testInvalidSignalArgument, 1.5, 'other');\ntest('Cannot use subprocess.kill(Infinity)', testInvalidSignalArgument, Number.POSITIVE_INFINITY, 'other');\ntest('Cannot use subprocess.kill(NaN)', testInvalidSignalArgument, Number.NaN, 'other');\ntest('Cannot use subprocess.kill(false)', testInvalidSignalArgument, false, 'other');\ntest('Cannot use subprocess.kill(null)', testInvalidSignalArgument, null, 'other');\ntest('Cannot use subprocess.kill(symbol)', testInvalidSignalArgument, Symbol('test'), 'other');\ntest('Cannot use subprocess.kill({})', testInvalidSignalArgument, {}, 'other');\n"
  },
  {
    "path": "test/terminate/timeout.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\ntest('timeout kills the subprocess if it times out', async t => {\n\tconst {isTerminated, signal, timedOut, originalMessage, shortMessage, message} = await t.throwsAsync(execa('forever.js', {timeout: 1}));\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n\tt.true(timedOut);\n\tt.is(originalMessage, undefined);\n\tt.is(shortMessage, 'Command timed out after 1 milliseconds: forever.js');\n\tt.is(message, shortMessage);\n});\n\ntest('timeout kills the subprocess if it times out, in sync mode', async t => {\n\tconst {isTerminated, signal, timedOut, originalMessage, shortMessage, message} = await t.throws(() => {\n\t\texecaSync('node', ['forever.js'], {timeout: 1, cwd: FIXTURES_DIRECTORY});\n\t});\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGTERM');\n\tt.true(timedOut);\n\tt.is(originalMessage, 'spawnSync node ETIMEDOUT');\n\tt.is(shortMessage, `Command timed out after 1 milliseconds: node forever.js\\n${originalMessage}`);\n\tt.is(message, shortMessage);\n});\n\ntest('timeout does not kill the subprocess if it does not time out', async t => {\n\tconst {timedOut} = await execa('delay.js', ['500'], {timeout: 1e8});\n\tt.false(timedOut);\n});\n\ntest('timeout uses killSignal', async t => {\n\tconst {isTerminated, signal, timedOut} = await t.throwsAsync(execa('forever.js', {timeout: 1, killSignal: 'SIGINT'}));\n\tt.true(isTerminated);\n\tt.is(signal, 'SIGINT');\n\tt.true(timedOut);\n});\n\nconst INVALID_TIMEOUT_REGEXP = /`timeout` option to be a non-negative integer/;\n\nconst testTimeoutValidation = (t, timeout, execaMethod) => {\n\tt.throws(() => {\n\t\texecaMethod('empty.js', {timeout});\n\t}, {message: INVALID_TIMEOUT_REGEXP});\n};\n\ntest('timeout must not be negative', testTimeoutValidation, -1, execa);\ntest('timeout must be an integer', testTimeoutValidation, false, execa);\ntest('timeout must not be negative - sync', testTimeoutValidation, -1, execaSync);\ntest('timeout must be an integer - sync', testTimeoutValidation, false, execaSync);\n\ntest('timedOut is false if timeout is undefined', async t => {\n\tconst {timedOut} = await execa('noop.js');\n\tt.false(timedOut);\n});\n\ntest('timedOut is false if timeout is 0', async t => {\n\tconst {timedOut} = await execa('noop.js', {timeout: 0});\n\tt.false(timedOut);\n});\n\ntest('timedOut is false if timeout is undefined and exit code is 0 in sync mode', t => {\n\tconst {timedOut} = execaSync('noop.js');\n\tt.false(timedOut);\n});\n\ntest('timedOut is false if the timeout happened after a different error occurred', async t => {\n\tconst subprocess = execa('forever.js', {timeout: 1e3});\n\tconst cause = new Error('test');\n\tsubprocess.emit('error', cause);\n\tconst error = await t.throwsAsync(subprocess);\n\tt.is(error.cause, cause);\n\tt.false(error.timedOut);\n});\n"
  },
  {
    "path": "test/transform/encoding-final.js",
    "content": "import {Buffer} from 'node:buffer';\nimport {exec} from 'node:child_process';\nimport {promisify} from 'node:util';\nimport test from 'ava';\nimport getStream from 'get-stream';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory, FIXTURES_DIRECTORY} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {foobarString, foobarUint8Array, foobarHex} from '../helpers/input.js';\n\nconst pExec = promisify(exec);\n\nsetFixtureDirectory();\n\nconst checkEncoding = async (t, encoding, fdNumber, execaMethod) => {\n\tconst {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`, STRING_TO_ENCODE], {...fullStdio, encoding});\n\tcompareValues(t, stdio[fdNumber], encoding);\n\n\tif (execaMethod !== execaSync) {\n\t\tconst subprocess = execaMethod('noop-fd.js', [`${fdNumber}`, STRING_TO_ENCODE], {...fullStdio, encoding});\n\t\tconst result = await getStream(subprocess.stdio[fdNumber]);\n\t\tcompareValues(t, result, 'utf8');\n\t\tawait subprocess;\n\t}\n\n\tif (fdNumber === 3) {\n\t\treturn;\n\t}\n\n\tconst {stdout, stderr} = await pExec(`node noop-fd.js ${fdNumber} ${STRING_TO_ENCODE}`, {encoding, cwd: FIXTURES_DIRECTORY});\n\tcompareValues(t, fdNumber === 1 ? stdout : stderr, encoding);\n};\n\nconst compareValues = (t, value, encoding) => {\n\tif (encoding === 'buffer') {\n\t\tt.true(ArrayBuffer.isView(value));\n\t\tt.true(BUFFER_TO_ENCODE.equals(value));\n\t} else {\n\t\tt.is(value, BUFFER_TO_ENCODE.toString(encoding));\n\t}\n};\n\n// This string gives different outputs with each encoding type\nconst STRING_TO_ENCODE = '\\u1000.';\nconst BUFFER_TO_ENCODE = Buffer.from(STRING_TO_ENCODE);\n\ntest('can pass encoding \"buffer\" to stdout', checkEncoding, 'buffer', 1, execa);\ntest('can pass encoding \"utf8\" to stdout', checkEncoding, 'utf8', 1, execa);\ntest('can pass encoding \"utf16le\" to stdout', checkEncoding, 'utf16le', 1, execa);\ntest('can pass encoding \"latin1\" to stdout', checkEncoding, 'latin1', 1, execa);\ntest('can pass encoding \"ascii\" to stdout', checkEncoding, 'ascii', 1, execa);\ntest('can pass encoding \"hex\" to stdout', checkEncoding, 'hex', 1, execa);\ntest('can pass encoding \"base64\" to stdout', checkEncoding, 'base64', 1, execa);\ntest('can pass encoding \"base64url\" to stdout', checkEncoding, 'base64url', 1, execa);\ntest('can pass encoding \"buffer\" to stderr', checkEncoding, 'buffer', 2, execa);\ntest('can pass encoding \"utf8\" to stderr', checkEncoding, 'utf8', 2, execa);\ntest('can pass encoding \"utf16le\" to stderr', checkEncoding, 'utf16le', 2, execa);\ntest('can pass encoding \"latin1\" to stderr', checkEncoding, 'latin1', 2, execa);\ntest('can pass encoding \"ascii\" to stderr', checkEncoding, 'ascii', 2, execa);\ntest('can pass encoding \"hex\" to stderr', checkEncoding, 'hex', 2, execa);\ntest('can pass encoding \"base64\" to stderr', checkEncoding, 'base64', 2, execa);\ntest('can pass encoding \"base64url\" to stderr', checkEncoding, 'base64url', 2, execa);\ntest('can pass encoding \"buffer\" to stdio[*]', checkEncoding, 'buffer', 3, execa);\ntest('can pass encoding \"utf8\" to stdio[*]', checkEncoding, 'utf8', 3, execa);\ntest('can pass encoding \"utf16le\" to stdio[*]', checkEncoding, 'utf16le', 3, execa);\ntest('can pass encoding \"latin1\" to stdio[*]', checkEncoding, 'latin1', 3, execa);\ntest('can pass encoding \"ascii\" to stdio[*]', checkEncoding, 'ascii', 3, execa);\ntest('can pass encoding \"hex\" to stdio[*]', checkEncoding, 'hex', 3, execa);\ntest('can pass encoding \"base64\" to stdio[*]', checkEncoding, 'base64', 3, execa);\ntest('can pass encoding \"base64url\" to stdio[*]', checkEncoding, 'base64url', 3, execa);\ntest('can pass encoding \"buffer\" to stdout - sync', checkEncoding, 'buffer', 1, execaSync);\ntest('can pass encoding \"utf8\" to stdout - sync', checkEncoding, 'utf8', 1, execaSync);\ntest('can pass encoding \"utf16le\" to stdout - sync', checkEncoding, 'utf16le', 1, execaSync);\ntest('can pass encoding \"latin1\" to stdout - sync', checkEncoding, 'latin1', 1, execaSync);\ntest('can pass encoding \"ascii\" to stdout - sync', checkEncoding, 'ascii', 1, execaSync);\ntest('can pass encoding \"hex\" to stdout - sync', checkEncoding, 'hex', 1, execaSync);\ntest('can pass encoding \"base64\" to stdout - sync', checkEncoding, 'base64', 1, execaSync);\ntest('can pass encoding \"base64url\" to stdout - sync', checkEncoding, 'base64url', 1, execaSync);\ntest('can pass encoding \"buffer\" to stderr - sync', checkEncoding, 'buffer', 2, execaSync);\ntest('can pass encoding \"utf8\" to stderr - sync', checkEncoding, 'utf8', 2, execaSync);\ntest('can pass encoding \"utf16le\" to stderr - sync', checkEncoding, 'utf16le', 2, execaSync);\ntest('can pass encoding \"latin1\" to stderr - sync', checkEncoding, 'latin1', 2, execaSync);\ntest('can pass encoding \"ascii\" to stderr - sync', checkEncoding, 'ascii', 2, execaSync);\ntest('can pass encoding \"hex\" to stderr - sync', checkEncoding, 'hex', 2, execaSync);\ntest('can pass encoding \"base64\" to stderr - sync', checkEncoding, 'base64', 2, execaSync);\ntest('can pass encoding \"base64url\" to stderr - sync', checkEncoding, 'base64url', 2, execaSync);\ntest('can pass encoding \"buffer\" to stdio[*] - sync', checkEncoding, 'buffer', 3, execaSync);\ntest('can pass encoding \"utf8\" to stdio[*] - sync', checkEncoding, 'utf8', 3, execaSync);\ntest('can pass encoding \"utf16le\" to stdio[*] - sync', checkEncoding, 'utf16le', 3, execaSync);\ntest('can pass encoding \"latin1\" to stdio[*] - sync', checkEncoding, 'latin1', 3, execaSync);\ntest('can pass encoding \"ascii\" to stdio[*] - sync', checkEncoding, 'ascii', 3, execaSync);\ntest('can pass encoding \"hex\" to stdio[*] - sync', checkEncoding, 'hex', 3, execaSync);\ntest('can pass encoding \"base64\" to stdio[*] - sync', checkEncoding, 'base64', 3, execaSync);\ntest('can pass encoding \"base64url\" to stdio[*] - sync', checkEncoding, 'base64url', 3, execaSync);\n\n// eslint-disable-next-line max-params\nconst testEncodingInput = async (t, input, expectedStdout, encoding, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin.js', {input, encoding});\n\tt.deepEqual(stdout, expectedStdout);\n};\n\ntest('Can use string input', testEncodingInput, foobarString, foobarString, 'utf8', execa);\ntest('Can use Uint8Array input', testEncodingInput, foobarUint8Array, foobarString, 'utf8', execa);\ntest('Can use string input, encoding \"buffer\"', testEncodingInput, foobarString, foobarUint8Array, 'buffer', execa);\ntest('Can use Uint8Array input, encoding \"buffer\"', testEncodingInput, foobarUint8Array, foobarUint8Array, 'buffer', execa);\ntest('Can use string input, encoding \"hex\"', testEncodingInput, foobarString, foobarHex, 'hex', execa);\ntest('Can use Uint8Array input, encoding \"hex\"', testEncodingInput, foobarUint8Array, foobarHex, 'hex', execa);\ntest('Can use string input, sync', testEncodingInput, foobarString, foobarString, 'utf8', execaSync);\ntest('Can use Uint8Array input, sync', testEncodingInput, foobarUint8Array, foobarString, 'utf8', execaSync);\ntest('Can use string input, encoding \"buffer\", sync', testEncodingInput, foobarString, foobarUint8Array, 'buffer', execaSync);\ntest('Can use Uint8Array input, encoding \"buffer\", sync', testEncodingInput, foobarUint8Array, foobarUint8Array, 'buffer', execaSync);\ntest('Can use string input, encoding \"hex\", sync', testEncodingInput, foobarString, foobarHex, 'hex', execaSync);\ntest('Can use Uint8Array input, encoding \"hex\", sync', testEncodingInput, foobarUint8Array, foobarHex, 'hex', execaSync);\n\nconst testSubprocessEncoding = (t, encoding) => {\n\tconst subprocess = execa('empty.js', {...fullStdio, encoding});\n\tt.is(subprocess.stdout.readableEncoding, null);\n\tt.is(subprocess.stderr.readableEncoding, null);\n\tt.is(subprocess.stdio[3].readableEncoding, null);\n};\n\ntest('Does not modify subprocess.std* encoding, \"utf8\"', testSubprocessEncoding, 'utf8');\ntest('Does not modify subprocess.std* encoding, \"utf16le\"', testSubprocessEncoding, 'utf16le');\ntest('Does not modify subprocess.std* encoding, \"buffer\"', testSubprocessEncoding, 'buffer');\ntest('Does not modify subprocess.std* encoding, \"hex\"', testSubprocessEncoding, 'hex');\ntest('Does not modify subprocess.std* encoding, \"base64\"', testSubprocessEncoding, 'base64');\ntest('Does not modify subprocess.std* encoding, \"base64url\"', testSubprocessEncoding, 'base64url');\ntest('Does not modify subprocess.std* encoding, \"latin1\"', testSubprocessEncoding, 'latin1');\ntest('Does not modify subprocess.std* encoding, \"ascii\"', testSubprocessEncoding, 'ascii');\n"
  },
  {
    "path": "test/transform/encoding-ignored.js",
    "content": "import process from 'node:process';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {outputObjectGenerator, addNoopGenerator} from '../helpers/generator.js';\nimport {foobarObject} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testObjectMode = async (t, addNoopTransform, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: addNoopGenerator(outputObjectGenerator(), addNoopTransform, true),\n\t\tencoding: 'base64',\n\t});\n\tt.deepEqual(stdout, [foobarObject]);\n};\n\ntest('Other encodings work with transforms that return objects', testObjectMode, false, execa);\ntest('Other encodings work with transforms that return objects, noop transform', testObjectMode, true, execa);\ntest('Other encodings work with transforms that return objects, sync', testObjectMode, false, execaSync);\ntest('Other encodings work with transforms that return objects, noop transform, sync', testObjectMode, true, execaSync);\n\n// eslint-disable-next-line max-params\nconst testIgnoredEncoding = async (t, stdoutOption, isUndefined, options, execaMethod) => {\n\tconst {stdout} = await execaMethod('empty.js', {stdout: stdoutOption, ...options});\n\tt.is(stdout === undefined, isUndefined);\n};\n\nconst base64Options = {encoding: 'base64'};\nconst linesOptions = {lines: true};\ntest('Is ignored with other encodings and \"ignore\"', testIgnoredEncoding, 'ignore', true, base64Options, execa);\ntest('Is ignored with other encodings and [\"ignore\"]', testIgnoredEncoding, ['ignore'], true, base64Options, execa);\ntest('Is ignored with other encodings and \"ipc\"', testIgnoredEncoding, 'ipc', true, base64Options, execa);\ntest('Is ignored with other encodings and [\"ipc\"]', testIgnoredEncoding, ['ipc'], true, base64Options, execa);\ntest('Is ignored with other encodings and \"inherit\"', testIgnoredEncoding, 'inherit', true, base64Options, execa);\ntest('Is ignored with other encodings and [\"inherit\"]', testIgnoredEncoding, ['inherit'], true, base64Options, execa);\ntest('Is ignored with other encodings and 1', testIgnoredEncoding, 1, true, base64Options, execa);\ntest('Is ignored with other encodings and [1]', testIgnoredEncoding, [1], true, base64Options, execa);\ntest('Is ignored with other encodings and process.stdout', testIgnoredEncoding, process.stdout, true, base64Options, execa);\ntest('Is ignored with other encodings and [process.stdout]', testIgnoredEncoding, [process.stdout], true, base64Options, execa);\ntest('Is not ignored with other encodings and \"pipe\"', testIgnoredEncoding, 'pipe', false, base64Options, execa);\ntest('Is not ignored with other encodings and [\"pipe\"]', testIgnoredEncoding, ['pipe'], false, base64Options, execa);\ntest('Is not ignored with other encodings and \"overlapped\"', testIgnoredEncoding, 'overlapped', false, base64Options, execa);\ntest('Is not ignored with other encodings and [\"overlapped\"]', testIgnoredEncoding, ['overlapped'], false, base64Options, execa);\ntest('Is not ignored with other encodings and [\"inherit\", \"pipe\"]', testIgnoredEncoding, ['inherit', 'pipe'], false, base64Options, execa);\ntest('Is not ignored with other encodings and undefined', testIgnoredEncoding, undefined, false, base64Options, execa);\ntest('Is not ignored with other encodings and null', testIgnoredEncoding, null, false, base64Options, execa);\ntest('Is ignored with \"lines: true\" and \"ignore\"', testIgnoredEncoding, 'ignore', true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and [\"ignore\"]', testIgnoredEncoding, ['ignore'], true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and \"ipc\"', testIgnoredEncoding, 'ipc', true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and [\"ipc\"]', testIgnoredEncoding, ['ipc'], true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and \"inherit\"', testIgnoredEncoding, 'inherit', true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and [\"inherit\"]', testIgnoredEncoding, ['inherit'], true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and 1', testIgnoredEncoding, 1, true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and [1]', testIgnoredEncoding, [1], true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and process.stdout', testIgnoredEncoding, process.stdout, true, linesOptions, execa);\ntest('Is ignored with \"lines: true\" and [process.stdout]', testIgnoredEncoding, [process.stdout], true, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and \"pipe\"', testIgnoredEncoding, 'pipe', false, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and [\"pipe\"]', testIgnoredEncoding, ['pipe'], false, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and \"overlapped\"', testIgnoredEncoding, 'overlapped', false, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and [\"overlapped\"]', testIgnoredEncoding, ['overlapped'], false, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and [\"inherit\", \"pipe\"]', testIgnoredEncoding, ['inherit', 'pipe'], false, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and undefined', testIgnoredEncoding, undefined, false, linesOptions, execa);\ntest('Is not ignored with \"lines: true\" and null', testIgnoredEncoding, null, false, linesOptions, execa);\ntest('Is ignored with \"lines: true\", other encodings and \"ignore\"', testIgnoredEncoding, 'ignore', true, {...base64Options, ...linesOptions}, execa);\ntest('Is not ignored with \"lines: true\", other encodings and \"pipe\"', testIgnoredEncoding, 'pipe', false, {...base64Options, ...linesOptions}, execa);\ntest('Is ignored with other encodings and \"ignore\", sync', testIgnoredEncoding, 'ignore', true, base64Options, execaSync);\ntest('Is ignored with other encodings and [\"ignore\"], sync', testIgnoredEncoding, ['ignore'], true, base64Options, execaSync);\ntest('Is ignored with other encodings and \"inherit\", sync', testIgnoredEncoding, 'inherit', true, base64Options, execaSync);\ntest('Is ignored with other encodings and [\"inherit\"], sync', testIgnoredEncoding, ['inherit'], true, base64Options, execaSync);\ntest('Is ignored with other encodings and 1, sync', testIgnoredEncoding, 1, true, base64Options, execaSync);\ntest('Is ignored with other encodings and [1], sync', testIgnoredEncoding, [1], true, base64Options, execaSync);\ntest('Is ignored with other encodings and process.stdout, sync', testIgnoredEncoding, process.stdout, true, base64Options, execaSync);\ntest('Is ignored with other encodings and [process.stdout], sync', testIgnoredEncoding, [process.stdout], true, base64Options, execaSync);\ntest('Is not ignored with other encodings and \"pipe\", sync', testIgnoredEncoding, 'pipe', false, base64Options, execaSync);\ntest('Is not ignored with other encodings and [\"pipe\"], sync', testIgnoredEncoding, ['pipe'], false, base64Options, execaSync);\ntest('Is not ignored with other encodings and undefined, sync', testIgnoredEncoding, undefined, false, base64Options, execaSync);\ntest('Is not ignored with other encodings and null, sync', testIgnoredEncoding, null, false, base64Options, execaSync);\ntest('Is ignored with \"lines: true\" and \"ignore\", sync', testIgnoredEncoding, 'ignore', true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and [\"ignore\"], sync', testIgnoredEncoding, ['ignore'], true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and \"inherit\", sync', testIgnoredEncoding, 'inherit', true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and [\"inherit\"], sync', testIgnoredEncoding, ['inherit'], true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and 1, sync', testIgnoredEncoding, 1, true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and [1], sync', testIgnoredEncoding, [1], true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and process.stdout, sync', testIgnoredEncoding, process.stdout, true, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\" and [process.stdout], sync', testIgnoredEncoding, [process.stdout], true, linesOptions, execaSync);\ntest('Is not ignored with \"lines: true\" and \"pipe\", sync', testIgnoredEncoding, 'pipe', false, linesOptions, execaSync);\ntest('Is not ignored with \"lines: true\" and [\"pipe\"], sync', testIgnoredEncoding, ['pipe'], false, linesOptions, execaSync);\ntest('Is not ignored with \"lines: true\" and undefined, sync', testIgnoredEncoding, undefined, false, linesOptions, execaSync);\ntest('Is not ignored with \"lines: true\" and null, sync', testIgnoredEncoding, null, false, linesOptions, execaSync);\ntest('Is ignored with \"lines: true\", other encodings and \"ignore\", sync', testIgnoredEncoding, 'ignore', true, {...base64Options, ...linesOptions}, execaSync);\ntest('Is not ignored with \"lines: true\", other encodings and \"pipe\", sync', testIgnoredEncoding, 'pipe', false, {...base64Options, ...linesOptions}, execaSync);\n"
  },
  {
    "path": "test/transform/encoding-multibyte.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {noopGenerator, getOutputsGenerator, addNoopGenerator} from '../helpers/generator.js';\nimport {\n\tmultibyteChar,\n\tmultibyteString,\n\tmultibyteUint8Array,\n\tbreakingLength,\n\tbrokenSymbol,\n} from '../helpers/encoding.js';\n\nsetFixtureDirectory();\n\nconst foobarArray = ['fo', 'ob', 'ar', '..'];\n\nconst testMultibyteCharacters = async (t, objectMode, addNoopTransform, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: addNoopGenerator(getOutputsGenerator(foobarArray)(objectMode, true), addNoopTransform, objectMode),\n\t\tencoding: 'base64',\n\t});\n\tif (objectMode) {\n\t\tt.deepEqual(stdout, foobarArray);\n\t} else {\n\t\tt.is(stdout, Buffer.from(foobarArray.join('')).toString('base64'));\n\t}\n};\n\ntest('Handle multibyte characters', testMultibyteCharacters, false, false, execa);\ntest('Handle multibyte characters, noop transform', testMultibyteCharacters, false, true, execa);\ntest('Handle multibyte characters, with objectMode', testMultibyteCharacters, true, false, execa);\ntest('Handle multibyte characters, with objectMode, noop transform', testMultibyteCharacters, true, true, execa);\ntest('Handle multibyte characters, sync', testMultibyteCharacters, false, false, execaSync);\ntest('Handle multibyte characters, noop transform, sync', testMultibyteCharacters, false, true, execaSync);\ntest('Handle multibyte characters, with objectMode, sync', testMultibyteCharacters, true, false, execaSync);\ntest('Handle multibyte characters, with objectMode, noop transform, sync', testMultibyteCharacters, true, true, execaSync);\n\nconst testMultibyte = async (t, objectMode, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin.js', {\n\t\tstdin: [\n\t\t\t[multibyteUint8Array.slice(0, breakingLength), multibyteUint8Array.slice(breakingLength)],\n\t\t\tnoopGenerator(objectMode, true),\n\t\t],\n\t});\n\tt.is(stdout, multibyteString);\n};\n\ntest('Generator handles multibyte characters with Uint8Array', testMultibyte, false, execa);\ntest('Generator handles multibyte characters with Uint8Array, objectMode', testMultibyte, true, execa);\ntest('Generator handles multibyte characters with Uint8Array, sync', testMultibyte, false, execaSync);\ntest('Generator handles multibyte characters with Uint8Array, objectMode, sync', testMultibyte, true, execaSync);\n\nconst testMultibytePartial = async (t, objectMode, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin.js', {\n\t\tstdin: [\n\t\t\t[multibyteUint8Array.slice(0, breakingLength)],\n\t\t\tnoopGenerator(objectMode, true),\n\t\t],\n\t});\n\tt.is(stdout, `${multibyteChar}${brokenSymbol}`);\n};\n\ntest('Generator handles partial multibyte characters with Uint8Array', testMultibytePartial, false, execa);\ntest('Generator handles partial multibyte characters with Uint8Array, objectMode', testMultibytePartial, true, execa);\ntest('Generator handles partial multibyte characters with Uint8Array, sync', testMultibytePartial, false, execaSync);\ntest('Generator handles partial multibyte characters with Uint8Array, objectMode, sync', testMultibytePartial, true, execaSync);\n\nconst testMultibytePartialOutput = async (t, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: getOutputsGenerator([\n\t\t\tmultibyteUint8Array.slice(0, breakingLength),\n\t\t\tmultibyteUint8Array.slice(breakingLength),\n\t\t])(false, true),\n\t});\n\tt.is(stdout, multibyteString);\n};\n\ntest('Generator handles output multibyte characters with Uint8Array', testMultibytePartialOutput, execa);\ntest('Generator handles output multibyte characters with Uint8Array, sync', testMultibytePartialOutput, execaSync);\n"
  },
  {
    "path": "test/transform/encoding-transform.js",
    "content": "import {Buffer} from 'node:buffer';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {\n\tfoobarString,\n\tfoobarUint8Array,\n\tfoobarBuffer,\n\tfoobarObject,\n} from '../helpers/input.js';\nimport {noopGenerator, getOutputGenerator} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\nconst getTypeofGenerator = lines => (objectMode, binary) => ({\n\t* transform(line) {\n\t\tlines.push(Object.prototype.toString.call(line));\n\t\tyield '';\n\t},\n\tobjectMode,\n\tbinary,\n});\n\nconst assertTypeofChunk = (t, lines, expectedType) => {\n\tt.deepEqual(lines, [`[object ${expectedType}]`]);\n};\n\n// eslint-disable-next-line max-params\nconst testGeneratorFirstEncoding = async (t, input, encoding, expectedType, objectMode, binary) => {\n\tconst lines = [];\n\tconst subprocess = execa('stdin.js', {stdin: getTypeofGenerator(lines)(objectMode, binary), encoding});\n\tsubprocess.stdin.end(input);\n\tawait subprocess;\n\tassertTypeofChunk(t, lines, expectedType);\n};\n\ntest('First generator argument is string with default encoding, with string writes', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', false, undefined);\ntest('First generator argument is string with default encoding, with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'utf8', 'String', false, undefined);\ntest('First generator argument is string with default encoding, with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'utf8', 'String', false, undefined);\ntest('First generator argument is string with default encoding, with string writes, \"binary: false\"', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', false, false);\ntest('First generator argument is Uint8Array with default encoding, with string writes, \"binary: true\"', testGeneratorFirstEncoding, foobarString, 'utf8', 'Uint8Array', false, true);\ntest('First generator argument is string with encoding \"utf16le\", with string writes', testGeneratorFirstEncoding, foobarString, 'utf16le', 'String', false, undefined);\ntest('First generator argument is string with encoding \"utf16le\", with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'utf16le', 'String', false, undefined);\ntest('First generator argument is string with encoding \"utf16le\", with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'utf16le', 'String', false, undefined);\ntest('First generator argument is string with encoding \"utf16le\", with string writes, \"binary: false\"', testGeneratorFirstEncoding, foobarString, 'utf16le', 'String', false, false);\ntest('First generator argument is Uint8Array with encoding \"utf16le\", with string writes, \"binary: true\"', testGeneratorFirstEncoding, foobarString, 'utf16le', 'Uint8Array', false, true);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with string writes', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'buffer', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'buffer', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with string writes, \"binary: false\"', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false, false);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with string writes, \"binary: true\"', testGeneratorFirstEncoding, foobarString, 'buffer', 'Uint8Array', false, true);\ntest('First generator argument is Uint8Array with encoding \"hex\", with string writes', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"hex\", with Buffer writes', testGeneratorFirstEncoding, foobarBuffer, 'hex', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"hex\", with Uint8Array writes', testGeneratorFirstEncoding, foobarUint8Array, 'hex', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"hex\", with string writes, \"binary: false\"', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, false);\ntest('First generator argument is Uint8Array with encoding \"hex\", with string writes, \"binary: true\"', testGeneratorFirstEncoding, foobarString, 'hex', 'Uint8Array', false, true);\ntest('First generator argument can be string with objectMode', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', true, undefined);\ntest('First generator argument can be string with objectMode, \"binary: false\"', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', true, false);\ntest('First generator argument can be string with objectMode, \"binary: true\"', testGeneratorFirstEncoding, foobarString, 'utf8', 'String', true, true);\ntest('First generator argument can be objects with objectMode', testGeneratorFirstEncoding, foobarObject, 'utf8', 'Object', true, undefined);\ntest('First generator argument can be objects with objectMode, \"binary: false\"', testGeneratorFirstEncoding, foobarObject, 'utf8', 'Object', true, false);\ntest('First generator argument can be objects with objectMode, \"binary: true\"', testGeneratorFirstEncoding, foobarObject, 'utf8', 'Object', true, true);\n\n// eslint-disable-next-line max-params\nconst testGeneratorFirstEncodingSync = (t, input, encoding, expectedType, objectMode, binary) => {\n\tconst lines = [];\n\texecaSync('stdin.js', {stdin: [[input], getTypeofGenerator(lines)(objectMode, binary)], encoding});\n\tassertTypeofChunk(t, lines, expectedType);\n};\n\ntest('First generator argument is string with default encoding, with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', false, undefined);\ntest('First generator argument is string with default encoding, with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'utf8', 'String', false, undefined);\ntest('First generator argument is string with default encoding, with string writes, \"binary: false\", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', false, false);\ntest('First generator argument is Uint8Array with default encoding, with string writes, \"binary: true\", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'Uint8Array', false, true);\ntest('First generator argument is string with encoding \"utf16le\", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'utf16le', 'String', false, undefined);\ntest('First generator argument is string with encoding \"utf16le\", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'utf16le', 'String', false, undefined);\ntest('First generator argument is string with encoding \"utf16le\", with string writes, \"binary: false\", sync', testGeneratorFirstEncodingSync, foobarString, 'utf16le', 'String', false, false);\ntest('First generator argument is Uint8Array with encoding \"utf16le\", with string writes, \"binary: true\", sync', testGeneratorFirstEncodingSync, foobarString, 'utf16le', 'Uint8Array', false, true);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'buffer', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with string writes, \"binary: false\", sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, false);\ntest('First generator argument is Uint8Array with encoding \"buffer\", with string writes, \"binary: true\", sync', testGeneratorFirstEncodingSync, foobarString, 'buffer', 'Uint8Array', false, true);\ntest('First generator argument is Uint8Array with encoding \"hex\", with string writes, sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"hex\", with Uint8Array writes, sync', testGeneratorFirstEncodingSync, foobarUint8Array, 'hex', 'Uint8Array', false, undefined);\ntest('First generator argument is Uint8Array with encoding \"hex\", with string writes, \"binary: false\", sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, false);\ntest('First generator argument is Uint8Array with encoding \"hex\", with string writes, \"binary: true\", sync', testGeneratorFirstEncodingSync, foobarString, 'hex', 'Uint8Array', false, true);\ntest('First generator argument can be string with objectMode, sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', true, undefined);\ntest('First generator argument can be string with objectMode, \"binary: false\", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', true, false);\ntest('First generator argument can be string with objectMode, \"binary: true\", sync', testGeneratorFirstEncodingSync, foobarString, 'utf8', 'String', true, true);\ntest('First generator argument can be objects with objectMode, sync', testGeneratorFirstEncodingSync, foobarObject, 'utf8', 'Object', true, undefined);\ntest('First generator argument can be objects with objectMode, \"binary: false\", sync', testGeneratorFirstEncodingSync, foobarObject, 'utf8', 'Object', true, false);\ntest('First generator argument can be objects with objectMode, \"binary: true\", sync', testGeneratorFirstEncodingSync, foobarObject, 'utf8', 'Object', true, true);\n\nconst testEncodingIgnored = async (t, encoding) => {\n\tconst input = Buffer.from(foobarString).toString(encoding);\n\tconst subprocess = execa('stdin.js', {stdin: noopGenerator(true)});\n\tsubprocess.stdin.end(input, encoding);\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, input);\n};\n\ntest('Write call encoding \"utf8\" is ignored with objectMode', testEncodingIgnored, 'utf8');\ntest('Write call encoding \"utf16le\" is ignored with objectMode', testEncodingIgnored, 'utf16le');\ntest('Write call encoding \"hex\" is ignored with objectMode', testEncodingIgnored, 'hex');\ntest('Write call encoding \"base64\" is ignored with objectMode', testEncodingIgnored, 'base64');\n\n// eslint-disable-next-line max-params\nconst testGeneratorNextEncoding = async (t, input, encoding, firstObjectMode, secondObjectMode, expectedType, execaMethod) => {\n\tconst lines = [];\n\tawait execaMethod('noop.js', ['other'], {\n\t\tstdout: [\n\t\t\tgetOutputGenerator(input)(firstObjectMode),\n\t\t\tgetTypeofGenerator(lines)(secondObjectMode),\n\t\t],\n\t\tencoding,\n\t});\n\tassertTypeofChunk(t, lines, expectedType);\n};\n\ntest('Next generator argument is string with default encoding, with string writes', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String', execa);\ntest('Next generator argument is string with default encoding, with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String', execa);\ntest('Next generator argument is string with default encoding, with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String', execa);\ntest('Next generator argument is string with default encoding, with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String', execa);\ntest('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array', execa);\ntest('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array', execa);\ntest('Next generator argument is string with encoding \"utf16le\", with string writes', testGeneratorNextEncoding, foobarString, 'utf16le', false, false, 'String', execa);\ntest('Next generator argument is string with encoding \"utf16le\",, with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'utf16le', true, false, 'String', execa);\ntest('Next generator argument is string with encoding \"utf16le\",, with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'utf16le', true, true, 'String', execa);\ntest('Next generator argument is string with encoding \"utf16le\",, with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'utf16le', false, false, 'String', execa);\ntest('Next generator argument is Uint8Array with encoding \"utf16le\",, with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'utf16le', true, false, 'Uint8Array', execa);\ntest('Next generator argument is string with encoding \"utf16le\",, with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'utf16le', true, true, 'Uint8Array', execa);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with string writes', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array', execa);\ntest('Next generator argument is string with encoding \"buffer\", with string writes, objectMode first', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String', execa);\ntest('Next generator argument is string with encoding \"buffer\", with string writes, objectMode both', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String', execa);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array', execa);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes, objectMode first', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array', execa);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes, objectMode both', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array', execa);\ntest('Next generator argument is Uint8Array with encoding \"hex\", with string writes', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array', execa);\ntest('Next generator argument is Uint8Array with encoding \"hex\", with Uint8Array writes', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array', execa);\ntest('Next generator argument is object with default encoding, with object writes, objectMode first', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object', execa);\ntest('Next generator argument is object with default encoding, with object writes, objectMode both', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object', execa);\ntest('Next generator argument is string with default encoding, with string writes, sync', testGeneratorNextEncoding, foobarString, 'utf8', false, false, 'String', execaSync);\ntest('Next generator argument is string with default encoding, with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'utf8', true, false, 'String', execaSync);\ntest('Next generator argument is string with default encoding, with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'utf8', true, true, 'String', execaSync);\ntest('Next generator argument is string with default encoding, with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', false, false, 'String', execaSync);\ntest('Next generator argument is Uint8Array with default encoding, with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, false, 'Uint8Array', execaSync);\ntest('Next generator argument is string with default encoding, with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf8', true, true, 'Uint8Array', execaSync);\ntest('Next generator argument is string with encoding \"utf16le\", with string writes, sync', testGeneratorNextEncoding, foobarString, 'utf16le', false, false, 'String', execaSync);\ntest('Next generator argument is string with encoding \"utf16le\",, with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'utf16le', true, false, 'String', execaSync);\ntest('Next generator argument is string with encoding \"utf16le\",, with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'utf16le', true, true, 'String', execaSync);\ntest('Next generator argument is string with encoding \"utf16le\",, with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf16le', false, false, 'String', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"utf16le\",, with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf16le', true, false, 'Uint8Array', execaSync);\ntest('Next generator argument is string with encoding \"utf16le\",, with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'utf16le', true, true, 'Uint8Array', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with string writes, sync', testGeneratorNextEncoding, foobarString, 'buffer', false, false, 'Uint8Array', execaSync);\ntest('Next generator argument is string with encoding \"buffer\", with string writes, objectMode first, sync', testGeneratorNextEncoding, foobarString, 'buffer', true, false, 'String', execaSync);\ntest('Next generator argument is string with encoding \"buffer\", with string writes, objectMode both, sync', testGeneratorNextEncoding, foobarString, 'buffer', true, true, 'String', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', false, false, 'Uint8Array', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes, objectMode first, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, false, 'Uint8Array', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"buffer\", with Uint8Array writes, objectMode both, sync', testGeneratorNextEncoding, foobarUint8Array, 'buffer', true, true, 'Uint8Array', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"hex\", with string writes, sync', testGeneratorNextEncoding, foobarString, 'hex', false, false, 'Uint8Array', execaSync);\ntest('Next generator argument is Uint8Array with encoding \"hex\", with Uint8Array writes, sync', testGeneratorNextEncoding, foobarUint8Array, 'hex', false, false, 'Uint8Array', execaSync);\ntest('Next generator argument is object with default encoding, with object writes, objectMode first, sync', testGeneratorNextEncoding, foobarObject, 'utf8', true, false, 'Object', execaSync);\ntest('Next generator argument is object with default encoding, with object writes, objectMode both, sync', testGeneratorNextEncoding, foobarObject, 'utf8', true, true, 'Object', execaSync);\n\nconst testFirstOutputGeneratorArgument = async (t, fdNumber, execaMethod) => {\n\tconst lines = [];\n\tawait execaMethod('noop-fd.js', [`${fdNumber}`], getStdio(fdNumber, getTypeofGenerator(lines)(true)));\n\tassertTypeofChunk(t, lines, 'String');\n};\n\ntest('The first generator with result.stdout does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 1, execa);\ntest('The first generator with result.stderr does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 2, execa);\ntest('The first generator with result.stdio[*] does not receive an object argument even in objectMode', testFirstOutputGeneratorArgument, 3, execa);\ntest('The first generator with result.stdout does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 1, execaSync);\ntest('The first generator with result.stderr does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 2, execaSync);\ntest('The first generator with result.stdio[*] does not receive an object argument even in objectMode, sync', testFirstOutputGeneratorArgument, 3, execaSync);\n"
  },
  {
    "path": "test/transform/generator-all.js",
    "content": "import {Buffer} from 'node:buffer';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarObject} from '../helpers/input.js';\nimport {\n\toutputObjectGenerator,\n\tuppercaseGenerator,\n\tuppercaseBufferGenerator,\n} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\nconst textEncoder = new TextEncoder();\n\nconst getAllStdioOption = (stdioOption, encoding, objectMode) => {\n\tif (stdioOption) {\n\t\treturn 'pipe';\n\t}\n\n\tif (objectMode) {\n\t\treturn outputObjectGenerator();\n\t}\n\n\treturn encoding === 'utf8' ? uppercaseGenerator() : uppercaseBufferGenerator();\n};\n\nconst getStdoutStderrOutput = ({output, stdioOption, encoding, objectMode, lines}) => {\n\tif (objectMode && !stdioOption) {\n\t\treturn encoding === 'utf8' ? [foobarObject, foobarObject] : [foobarObject];\n\t}\n\n\tconst stdioOutput = stdioOption ? output : output.toUpperCase();\n\n\tif (encoding === 'hex') {\n\t\treturn Buffer.from(stdioOutput).toString('hex');\n\t}\n\n\tif (encoding === 'buffer') {\n\t\treturn textEncoder.encode(stdioOutput);\n\t}\n\n\treturn lines ? stdioOutput.trim().split('\\n').map(string => `${string}\\n`) : stdioOutput;\n};\n\nconst getAllOutput = ({stdoutOutput, stderrOutput, encoding, objectMode, lines}) => {\n\tif (objectMode || (lines && encoding === 'utf8')) {\n\t\treturn [stdoutOutput, stderrOutput].flat();\n\t}\n\n\treturn encoding === 'buffer'\n\t\t? new Uint8Array([...stdoutOutput, ...stderrOutput])\n\t\t: `${stdoutOutput}${stderrOutput}`;\n};\n\n// eslint-disable-next-line max-params\nconst testGeneratorAll = async (t, reject, encoding, objectMode, stdoutOption, stderrOption, lines, execaMethod) => {\n\tconst fixtureName = reject ? 'all.js' : 'all-fail.js';\n\tconst {stdout, stderr, all} = await execaMethod(fixtureName, {\n\t\tall: true,\n\t\treject,\n\t\tstdout: getAllStdioOption(stdoutOption, encoding, objectMode),\n\t\tstderr: getAllStdioOption(stderrOption, encoding, objectMode),\n\t\tencoding,\n\t\tlines,\n\t\tstripFinalNewline: false,\n\t});\n\n\tconst stdoutOutput = getStdoutStderrOutput({\n\t\toutput: 'std\\nout\\n',\n\t\tstdioOption: stdoutOption,\n\t\tencoding,\n\t\tobjectMode,\n\t\tlines,\n\t});\n\tt.deepEqual(stdout, stdoutOutput);\n\tconst stderrOutput = getStdoutStderrOutput({\n\t\toutput: 'std\\nerr\\n',\n\t\tstdioOption: stderrOption,\n\t\tencoding,\n\t\tobjectMode,\n\t\tlines,\n\t});\n\tt.deepEqual(stderr, stderrOutput);\n\tconst allOutput = getAllOutput({\n\t\tstdoutOutput,\n\t\tstderrOutput,\n\t\tencoding,\n\t\tobjectMode,\n\t\tlines,\n\t});\n\tif (Array.isArray(all) && Array.isArray(allOutput)) {\n\t\tt.deepEqual([...all].sort(), [...allOutput].sort());\n\t} else {\n\t\tt.deepEqual(all, allOutput);\n\t}\n};\n\ntest('Can use generators with result.all = transform + transform', testGeneratorAll, true, 'utf8', false, false, false, false, execa);\ntest('Can use generators with error.all = transform + transform', testGeneratorAll, false, 'utf8', false, false, false, false, execa);\ntest('Can use generators with result.all = transform + transform, encoding \"buffer\"', testGeneratorAll, true, 'buffer', false, false, false, false, execa);\ntest('Can use generators with error.all = transform + transform, encoding \"buffer\"', testGeneratorAll, false, 'buffer', false, false, false, false, execa);\ntest('Can use generators with result.all = transform + transform, encoding \"hex\"', testGeneratorAll, true, 'hex', false, false, false, false, execa);\ntest('Can use generators with error.all = transform + transform, encoding \"hex\"', testGeneratorAll, false, 'hex', false, false, false, false, execa);\ntest('Can use generators with result.all = transform + pipe', testGeneratorAll, true, 'utf8', false, false, true, false, execa);\ntest('Can use generators with error.all = transform + pipe', testGeneratorAll, false, 'utf8', false, false, true, false, execa);\ntest('Can use generators with result.all = transform + pipe, encoding \"buffer\"', testGeneratorAll, true, 'buffer', false, false, true, false, execa);\ntest('Can use generators with error.all = transform + pipe, encoding \"buffer\"', testGeneratorAll, false, 'buffer', false, false, true, false, execa);\ntest('Can use generators with result.all = transform + pipe, encoding \"hex\"', testGeneratorAll, true, 'hex', false, false, true, false, execa);\ntest('Can use generators with error.all = transform + pipe, encoding \"hex\"', testGeneratorAll, false, 'hex', false, false, true, false, execa);\ntest('Can use generators with result.all = pipe + transform', testGeneratorAll, true, 'utf8', false, true, false, false, execa);\ntest('Can use generators with error.all = pipe + transform', testGeneratorAll, false, 'utf8', false, true, false, false, execa);\ntest('Can use generators with result.all = pipe + transform, encoding \"buffer\"', testGeneratorAll, true, 'buffer', false, true, false, false, execa);\ntest('Can use generators with error.all = pipe + transform, encoding \"buffer\"', testGeneratorAll, false, 'buffer', false, true, false, false, execa);\ntest('Can use generators with result.all = pipe + transform, encoding \"hex\"', testGeneratorAll, true, 'hex', false, true, false, false, execa);\ntest('Can use generators with error.all = pipe + transform, encoding \"hex\"', testGeneratorAll, false, 'hex', false, true, false, false, execa);\ntest('Can use generators with result.all = transform + transform, objectMode', testGeneratorAll, true, 'utf8', true, false, false, false, execa);\ntest('Can use generators with error.all = transform + transform, objectMode', testGeneratorAll, false, 'utf8', true, false, false, false, execa);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"buffer\"', testGeneratorAll, true, 'buffer', true, false, false, false, execa);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"buffer\"', testGeneratorAll, false, 'buffer', true, false, false, false, execa);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"hex\"', testGeneratorAll, true, 'hex', true, false, false, false, execa);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"hex\"', testGeneratorAll, false, 'hex', true, false, false, false, execa);\ntest('Can use generators with result.all = transform + pipe, objectMode', testGeneratorAll, true, 'utf8', true, false, true, false, execa);\ntest('Can use generators with error.all = transform + pipe, objectMode', testGeneratorAll, false, 'utf8', true, false, true, false, execa);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"buffer\"', testGeneratorAll, true, 'buffer', true, false, true, false, execa);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"buffer\"', testGeneratorAll, false, 'buffer', true, false, true, false, execa);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"hex\"', testGeneratorAll, true, 'hex', true, false, true, false, execa);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"hex\"', testGeneratorAll, false, 'hex', true, false, true, false, execa);\ntest('Can use generators with result.all = pipe + transform, objectMode', testGeneratorAll, true, 'utf8', true, true, false, false, execa);\ntest('Can use generators with error.all = pipe + transform, objectMode', testGeneratorAll, false, 'utf8', true, true, false, false, execa);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"buffer\"', testGeneratorAll, true, 'buffer', true, true, false, false, execa);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"buffer\"', testGeneratorAll, false, 'buffer', true, true, false, false, execa);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"hex\"', testGeneratorAll, true, 'hex', true, true, false, false, execa);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"hex\"', testGeneratorAll, false, 'hex', true, true, false, false, execa);\ntest('Can use generators with result.all = transform + transform, sync', testGeneratorAll, true, 'utf8', false, false, false, false, execaSync);\ntest('Can use generators with error.all = transform + transform, sync', testGeneratorAll, false, 'utf8', false, false, false, false, execaSync);\ntest('Can use generators with result.all = transform + transform, encoding \"buffer\", sync', testGeneratorAll, true, 'buffer', false, false, false, false, execaSync);\ntest('Can use generators with error.all = transform + transform, encoding \"buffer\", sync', testGeneratorAll, false, 'buffer', false, false, false, false, execaSync);\ntest('Can use generators with result.all = transform + transform, encoding \"hex\", sync', testGeneratorAll, true, 'hex', false, false, false, false, execaSync);\ntest('Can use generators with error.all = transform + transform, encoding \"hex\", sync', testGeneratorAll, false, 'hex', false, false, false, false, execaSync);\ntest('Can use generators with result.all = transform + pipe, sync', testGeneratorAll, true, 'utf8', false, false, true, false, execaSync);\ntest('Can use generators with error.all = transform + pipe, sync', testGeneratorAll, false, 'utf8', false, false, true, false, execaSync);\ntest('Can use generators with result.all = transform + pipe, encoding \"buffer\", sync', testGeneratorAll, true, 'buffer', false, false, true, false, execaSync);\ntest('Can use generators with error.all = transform + pipe, encoding \"buffer\", sync', testGeneratorAll, false, 'buffer', false, false, true, false, execaSync);\ntest('Can use generators with result.all = transform + pipe, encoding \"hex\", sync', testGeneratorAll, true, 'hex', false, false, true, false, execaSync);\ntest('Can use generators with error.all = transform + pipe, encoding \"hex\", sync', testGeneratorAll, false, 'hex', false, false, true, false, execaSync);\ntest('Can use generators with result.all = pipe + transform, sync', testGeneratorAll, true, 'utf8', false, true, false, false, execaSync);\ntest('Can use generators with error.all = pipe + transform, sync', testGeneratorAll, false, 'utf8', false, true, false, false, execaSync);\ntest('Can use generators with result.all = pipe + transform, encoding \"buffer\", sync', testGeneratorAll, true, 'buffer', false, true, false, false, execaSync);\ntest('Can use generators with error.all = pipe + transform, encoding \"buffer\", sync', testGeneratorAll, false, 'buffer', false, true, false, false, execaSync);\ntest('Can use generators with result.all = pipe + transform, encoding \"hex\", sync', testGeneratorAll, true, 'hex', false, true, false, false, execaSync);\ntest('Can use generators with error.all = pipe + transform, encoding \"hex\", sync', testGeneratorAll, false, 'hex', false, true, false, false, execaSync);\ntest('Can use generators with result.all = transform + transform, objectMode, sync', testGeneratorAll, true, 'utf8', true, false, false, false, execaSync);\ntest('Can use generators with error.all = transform + transform, objectMode, sync', testGeneratorAll, false, 'utf8', true, false, false, false, execaSync);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"buffer\", sync', testGeneratorAll, true, 'buffer', true, false, false, false, execaSync);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"buffer\", sync', testGeneratorAll, false, 'buffer', true, false, false, false, execaSync);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"hex\", sync', testGeneratorAll, true, 'hex', true, false, false, false, execaSync);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"hex\", sync', testGeneratorAll, false, 'hex', true, false, false, false, execaSync);\ntest('Can use generators with result.all = transform + pipe, objectMode, sync', testGeneratorAll, true, 'utf8', true, false, true, false, execaSync);\ntest('Can use generators with error.all = transform + pipe, objectMode, sync', testGeneratorAll, false, 'utf8', true, false, true, false, execaSync);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"buffer\", sync', testGeneratorAll, true, 'buffer', true, false, true, false, execaSync);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"buffer\", sync', testGeneratorAll, false, 'buffer', true, false, true, false, execaSync);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"hex\", sync', testGeneratorAll, true, 'hex', true, false, true, false, execaSync);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"hex\", sync', testGeneratorAll, false, 'hex', true, false, true, false, execaSync);\ntest('Can use generators with result.all = pipe + transform, objectMode, sync', testGeneratorAll, true, 'utf8', true, true, false, false, execaSync);\ntest('Can use generators with error.all = pipe + transform, objectMode, sync', testGeneratorAll, false, 'utf8', true, true, false, false, execaSync);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"buffer\", sync', testGeneratorAll, true, 'buffer', true, true, false, false, execaSync);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"buffer\", sync', testGeneratorAll, false, 'buffer', true, true, false, false, execaSync);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"hex\", sync', testGeneratorAll, true, 'hex', true, true, false, false, execaSync);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"hex\", sync', testGeneratorAll, false, 'hex', true, true, false, false, execaSync);\ntest('Can use generators with result.all = transform + transform, lines', testGeneratorAll, true, 'utf8', false, false, false, true, execa);\ntest('Can use generators with error.all = transform + transform, lines', testGeneratorAll, false, 'utf8', false, false, false, true, execa);\ntest('Can use generators with result.all = transform + transform, encoding \"buffer\", lines', testGeneratorAll, true, 'buffer', false, false, false, true, execa);\ntest('Can use generators with error.all = transform + transform, encoding \"buffer\", lines', testGeneratorAll, false, 'buffer', false, false, false, true, execa);\ntest('Can use generators with result.all = transform + transform, encoding \"hex\", lines', testGeneratorAll, true, 'hex', false, false, false, true, execa);\ntest('Can use generators with error.all = transform + transform, encoding \"hex\", lines', testGeneratorAll, false, 'hex', false, false, false, true, execa);\ntest('Can use generators with result.all = transform + pipe, lines', testGeneratorAll, true, 'utf8', false, false, true, true, execa);\ntest('Can use generators with error.all = transform + pipe, lines', testGeneratorAll, false, 'utf8', false, false, true, true, execa);\ntest('Can use generators with result.all = transform + pipe, encoding \"buffer\", lines', testGeneratorAll, true, 'buffer', false, false, true, true, execa);\ntest('Can use generators with error.all = transform + pipe, encoding \"buffer\", lines', testGeneratorAll, false, 'buffer', false, false, true, true, execa);\ntest('Can use generators with result.all = transform + pipe, encoding \"hex\", lines', testGeneratorAll, true, 'hex', false, false, true, true, execa);\ntest('Can use generators with error.all = transform + pipe, encoding \"hex\", lines', testGeneratorAll, false, 'hex', false, false, true, true, execa);\ntest('Can use generators with result.all = pipe + transform, lines', testGeneratorAll, true, 'utf8', false, true, false, true, execa);\ntest('Can use generators with error.all = pipe + transform, lines', testGeneratorAll, false, 'utf8', false, true, false, true, execa);\ntest('Can use generators with result.all = pipe + transform, encoding \"buffer\", lines', testGeneratorAll, true, 'buffer', false, true, false, true, execa);\ntest('Can use generators with error.all = pipe + transform, encoding \"buffer\", lines', testGeneratorAll, false, 'buffer', false, true, false, true, execa);\ntest('Can use generators with result.all = pipe + transform, encoding \"hex\", lines', testGeneratorAll, true, 'hex', false, true, false, true, execa);\ntest('Can use generators with error.all = pipe + transform, encoding \"hex\", lines', testGeneratorAll, false, 'hex', false, true, false, true, execa);\ntest('Can use generators with result.all = transform + transform, objectMode, lines', testGeneratorAll, true, 'utf8', true, false, false, true, execa);\ntest('Can use generators with error.all = transform + transform, objectMode, lines', testGeneratorAll, false, 'utf8', true, false, false, true, execa);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"buffer\", lines', testGeneratorAll, true, 'buffer', true, false, false, true, execa);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"buffer\", lines', testGeneratorAll, false, 'buffer', true, false, false, true, execa);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"hex\", lines', testGeneratorAll, true, 'hex', true, false, false, true, execa);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"hex\", lines', testGeneratorAll, false, 'hex', true, false, false, true, execa);\ntest('Can use generators with result.all = transform + pipe, objectMode, lines', testGeneratorAll, true, 'utf8', true, false, true, true, execa);\ntest('Can use generators with error.all = transform + pipe, objectMode, lines', testGeneratorAll, false, 'utf8', true, false, true, true, execa);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"buffer\", lines', testGeneratorAll, true, 'buffer', true, false, true, true, execa);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"buffer\", lines', testGeneratorAll, false, 'buffer', true, false, true, true, execa);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"hex\", lines', testGeneratorAll, true, 'hex', true, false, true, true, execa);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"hex\", lines', testGeneratorAll, false, 'hex', true, false, true, true, execa);\ntest('Can use generators with result.all = pipe + transform, objectMode, lines', testGeneratorAll, true, 'utf8', true, true, false, true, execa);\ntest('Can use generators with error.all = pipe + transform, objectMode, lines', testGeneratorAll, false, 'utf8', true, true, false, true, execa);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"buffer\", lines', testGeneratorAll, true, 'buffer', true, true, false, true, execa);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"buffer\", lines', testGeneratorAll, false, 'buffer', true, true, false, true, execa);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"hex\", lines', testGeneratorAll, true, 'hex', true, true, false, true, execa);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"hex\", lines', testGeneratorAll, false, 'hex', true, true, false, true, execa);\ntest('Can use generators with result.all = transform + transform, sync, lines', testGeneratorAll, true, 'utf8', false, false, false, true, execaSync);\ntest('Can use generators with error.all = transform + transform, sync, lines', testGeneratorAll, false, 'utf8', false, false, false, true, execaSync);\ntest('Can use generators with result.all = transform + transform, encoding \"buffer\", sync, lines', testGeneratorAll, true, 'buffer', false, false, false, true, execaSync);\ntest('Can use generators with error.all = transform + transform, encoding \"buffer\", sync, lines', testGeneratorAll, false, 'buffer', false, false, false, true, execaSync);\ntest('Can use generators with result.all = transform + transform, encoding \"hex\", sync, lines', testGeneratorAll, true, 'hex', false, false, false, true, execaSync);\ntest('Can use generators with error.all = transform + transform, encoding \"hex\", sync, lines', testGeneratorAll, false, 'hex', false, false, false, true, execaSync);\ntest('Can use generators with result.all = transform + pipe, sync, lines', testGeneratorAll, true, 'utf8', false, false, true, true, execaSync);\ntest('Can use generators with error.all = transform + pipe, sync, lines', testGeneratorAll, false, 'utf8', false, false, true, true, execaSync);\ntest('Can use generators with result.all = transform + pipe, encoding \"buffer\", sync, lines', testGeneratorAll, true, 'buffer', false, false, true, true, execaSync);\ntest('Can use generators with error.all = transform + pipe, encoding \"buffer\", sync, lines', testGeneratorAll, false, 'buffer', false, false, true, true, execaSync);\ntest('Can use generators with result.all = transform + pipe, encoding \"hex\", sync, lines', testGeneratorAll, true, 'hex', false, false, true, true, execaSync);\ntest('Can use generators with error.all = transform + pipe, encoding \"hex\", sync, lines', testGeneratorAll, false, 'hex', false, false, true, true, execaSync);\ntest('Can use generators with result.all = pipe + transform, sync, lines', testGeneratorAll, true, 'utf8', false, true, false, true, execaSync);\ntest('Can use generators with error.all = pipe + transform, sync, lines', testGeneratorAll, false, 'utf8', false, true, false, true, execaSync);\ntest('Can use generators with result.all = pipe + transform, encoding \"buffer\", sync, lines', testGeneratorAll, true, 'buffer', false, true, false, true, execaSync);\ntest('Can use generators with error.all = pipe + transform, encoding \"buffer\", sync, lines', testGeneratorAll, false, 'buffer', false, true, false, true, execaSync);\ntest('Can use generators with result.all = pipe + transform, encoding \"hex\", sync, lines', testGeneratorAll, true, 'hex', false, true, false, true, execaSync);\ntest('Can use generators with error.all = pipe + transform, encoding \"hex\", sync, lines', testGeneratorAll, false, 'hex', false, true, false, true, execaSync);\ntest('Can use generators with result.all = transform + transform, objectMode, sync, lines', testGeneratorAll, true, 'utf8', true, false, false, true, execaSync);\ntest('Can use generators with error.all = transform + transform, objectMode, sync, lines', testGeneratorAll, false, 'utf8', true, false, false, true, execaSync);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"buffer\", sync, lines', testGeneratorAll, true, 'buffer', true, false, false, true, execaSync);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"buffer\", sync, lines', testGeneratorAll, false, 'buffer', true, false, false, true, execaSync);\ntest('Can use generators with result.all = transform + transform, objectMode, encoding \"hex\", sync, lines', testGeneratorAll, true, 'hex', true, false, false, true, execaSync);\ntest('Can use generators with error.all = transform + transform, objectMode, encoding \"hex\", sync, lines', testGeneratorAll, false, 'hex', true, false, false, true, execaSync);\ntest('Can use generators with result.all = transform + pipe, objectMode, sync, lines', testGeneratorAll, true, 'utf8', true, false, true, true, execaSync);\ntest('Can use generators with error.all = transform + pipe, objectMode, sync, lines', testGeneratorAll, false, 'utf8', true, false, true, true, execaSync);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"buffer\", sync, lines', testGeneratorAll, true, 'buffer', true, false, true, true, execaSync);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"buffer\", sync, lines', testGeneratorAll, false, 'buffer', true, false, true, true, execaSync);\ntest('Can use generators with result.all = transform + pipe, objectMode, encoding \"hex\", sync, lines', testGeneratorAll, true, 'hex', true, false, true, true, execaSync);\ntest('Can use generators with error.all = transform + pipe, objectMode, encoding \"hex\", sync, lines', testGeneratorAll, false, 'hex', true, false, true, true, execaSync);\ntest('Can use generators with result.all = pipe + transform, objectMode, sync, lines', testGeneratorAll, true, 'utf8', true, true, false, true, execaSync);\ntest('Can use generators with error.all = pipe + transform, objectMode, sync, lines', testGeneratorAll, false, 'utf8', true, true, false, true, execaSync);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"buffer\", sync, lines', testGeneratorAll, true, 'buffer', true, true, false, true, execaSync);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"buffer\", sync, lines', testGeneratorAll, false, 'buffer', true, true, false, true, execaSync);\ntest('Can use generators with result.all = pipe + transform, objectMode, encoding \"hex\", sync, lines', testGeneratorAll, true, 'hex', true, true, false, true, execaSync);\ntest('Can use generators with error.all = pipe + transform, objectMode, encoding \"hex\", sync, lines', testGeneratorAll, false, 'hex', true, true, false, true, execaSync);\n"
  },
  {
    "path": "test/transform/generator-error.js",
    "content": "import {once} from 'node:events';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {noopGenerator, infiniteGenerator, convertTransformToFinal} from '../helpers/generator.js';\nimport {generatorsMap} from '../helpers/map.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getEarlyErrorSubprocess, expectedEarlyError} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst assertProcessError = async (t, type, execaMethod, getSubprocess) => {\n\tconst cause = new Error(foobarString);\n\tconst transform = generatorsMap[type].throwing(cause)();\n\tconst error = execaMethod === execa\n\t\t? await t.throwsAsync(getSubprocess(transform))\n\t\t: t.throws(() => {\n\t\t\tgetSubprocess(transform);\n\t\t});\n\tt.is(error.cause, cause);\n};\n\nconst testThrowingGenerator = async (t, type, final, execaMethod) => {\n\tawait assertProcessError(t, type, execaMethod, transform => execaMethod('noop.js', {\n\t\tstdout: convertTransformToFinal(transform, final),\n\t}));\n};\n\ntest('Generators \"transform\" errors make subprocess fail', testThrowingGenerator, 'generator', false, execa);\ntest('Generators \"final\" errors make subprocess fail', testThrowingGenerator, 'generator', true, execa);\ntest('Generators \"transform\" errors make subprocess fail, sync', testThrowingGenerator, 'generator', false, execaSync);\ntest('Generators \"final\" errors make subprocess fail, sync', testThrowingGenerator, 'generator', true, execaSync);\ntest('Duplexes \"transform\" errors make subprocess fail', testThrowingGenerator, 'duplex', false, execa);\ntest('WebTransform \"transform\" errors make subprocess fail', testThrowingGenerator, 'webTransform', false, execa);\n\nconst testSingleErrorOutput = async (t, type, execaMethod) => {\n\tawait assertProcessError(t, type, execaMethod, transform => execaMethod('noop.js', {\n\t\tstdout: [\n\t\t\tgeneratorsMap[type].noop(false),\n\t\t\ttransform,\n\t\t\tgeneratorsMap[type].noop(false),\n\t\t],\n\t}));\n};\n\ntest('Generators errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'generator', execa);\ntest('Generators errors make subprocess fail even when other output generators do not throw, sync', testSingleErrorOutput, 'generator', execaSync);\ntest('Duplexes errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'duplex', execa);\ntest('WebTransform errors make subprocess fail even when other output generators do not throw', testSingleErrorOutput, 'webTransform', execa);\n\nconst testSingleErrorInput = async (t, type, execaMethod) => {\n\tawait assertProcessError(t, type, execaMethod, transform => execaMethod('stdin.js', {\n\t\tstdin: [\n\t\t\t['foobar\\n'],\n\t\t\tgeneratorsMap[type].noop(false),\n\t\t\ttransform,\n\t\t\tgeneratorsMap[type].noop(false),\n\t\t],\n\t}));\n};\n\ntest('Generators errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'generator', execa);\ntest('Generators errors make subprocess fail even when other input generators do not throw, sync', testSingleErrorInput, 'generator', execaSync);\ntest('Duplexes errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'duplex', execa);\ntest('WebTransform errors make subprocess fail even when other input generators do not throw', testSingleErrorInput, 'webTransform', execa);\n\nconst testGeneratorCancel = async (t, error) => {\n\tconst subprocess = execa('noop.js', {stdout: infiniteGenerator()});\n\tawait once(subprocess.stdout, 'data');\n\tsubprocess.stdout.destroy(error);\n\tawait (error === undefined ? t.notThrowsAsync(subprocess) : t.throwsAsync(subprocess));\n};\n\ntest('Running generators are canceled on subprocess abort', testGeneratorCancel, undefined);\ntest('Running generators are canceled on subprocess error', testGeneratorCancel, new Error('test'));\n\nconst testGeneratorDestroy = async (t, transform) => {\n\tconst subprocess = execa('forever.js', {stdout: transform});\n\tconst cause = new Error('test');\n\tsubprocess.stdout.destroy(cause);\n\tsubprocess.kill();\n\tt.like(await t.throwsAsync(subprocess), {cause});\n};\n\ntest('Generators are destroyed on subprocess error, sync', testGeneratorDestroy, noopGenerator(false));\ntest('Generators are destroyed on subprocess error, async', testGeneratorDestroy, infiniteGenerator());\n\ntest('Generators are destroyed on early subprocess exit', async t => {\n\tconst error = await t.throwsAsync(getEarlyErrorSubprocess({stdout: infiniteGenerator()}));\n\tt.like(error, expectedEarlyError);\n});\n"
  },
  {
    "path": "test/transform/generator-final.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {getOutputAsyncGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\n\nsetFixtureDirectory();\n\nconst testGeneratorFinal = async (t, fixtureName, execaMethod) => {\n\tconst {stdout} = await execaMethod(fixtureName, {stdout: convertTransformToFinal(getOutputGenerator(foobarString)(), true)});\n\tt.is(stdout, foobarString);\n};\n\ntest('Generators \"final\" can be used', testGeneratorFinal, 'noop.js', execa);\ntest('Generators \"final\" is used even on empty streams', testGeneratorFinal, 'empty.js', execa);\ntest('Generators \"final\" can be used, sync', testGeneratorFinal, 'noop.js', execaSync);\ntest('Generators \"final\" is used even on empty streams, sync', testGeneratorFinal, 'empty.js', execaSync);\n\nconst testFinalAlone = async (t, final, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', '.'], {stdout: {final: final(foobarString)().transform}});\n\tt.is(stdout, `.\\n${foobarString}`);\n};\n\ntest('Generators \"final\" can be used without \"transform\"', testFinalAlone, getOutputGenerator, execa);\ntest('Generators \"final\" can be used without \"transform\", sync', testFinalAlone, getOutputGenerator, execaSync);\ntest('Generators \"final\" can be used without \"transform\", async', testFinalAlone, getOutputAsyncGenerator, execa);\n\nconst testFinalNoOutput = async (t, final, execaMethod) => {\n\tconst {stdout} = await execaMethod('empty.js', {stdout: {final: final(foobarString)().transform}});\n\tt.is(stdout, foobarString);\n};\n\ntest('Generators \"final\" can be used without \"transform\" nor output', testFinalNoOutput, getOutputGenerator, execa);\ntest('Generators \"final\" can be used without \"transform\" nor output, sync', testFinalNoOutput, getOutputGenerator, execaSync);\ntest('Generators \"final\" can be used without \"transform\" nor output, async', testFinalNoOutput, getOutputAsyncGenerator, execa);\n"
  },
  {
    "path": "test/transform/generator-input.js",
    "content": "import {Buffer} from 'node:buffer';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {\n\tfoobarString,\n\tfoobarUppercase,\n\tfoobarHex,\n\tfoobarUint8Array,\n\tfoobarBuffer,\n\tfoobarObject,\n\tfoobarObjectString,\n} from '../helpers/input.js';\nimport {generatorsMap} from '../helpers/map.js';\n\nsetFixtureDirectory();\n\nconst getInputObjectMode = (objectMode, addNoopTransform, type) => objectMode\n\t? {\n\t\tinput: [foobarObject],\n\t\tgenerators: generatorsMap[type].addNoop(generatorsMap[type].serialize(objectMode), addNoopTransform, objectMode),\n\t\toutput: foobarObjectString,\n\t}\n\t: {\n\t\tinput: foobarUint8Array,\n\t\tgenerators: generatorsMap[type].addNoop(generatorsMap[type].uppercase(objectMode), addNoopTransform, objectMode),\n\t\toutput: foobarUppercase,\n\t};\n\n// eslint-disable-next-line max-params\nconst testGeneratorInput = async (t, fdNumber, objectMode, addNoopTransform, type, execaMethod) => {\n\tconst {input, generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);\n\tconst {stdout} = await execaMethod('stdin-fd.js', [`${fdNumber}`], getStdio(fdNumber, [input, ...generators]));\n\tt.is(stdout, output);\n};\n\ntest('Can use generators with result.stdin', testGeneratorInput, 0, false, false, 'generator', execa);\ntest('Can use generators with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'generator', execa);\ntest('Can use generators with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'generator', execa);\ntest('Can use generators with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'generator', execa);\ntest('Can use generators with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'generator', execa);\ntest('Can use generators with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'generator', execa);\ntest('Can use generators with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'generator', execa);\ntest('Can use generators with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'generator', execa);\ntest('Can use generators with result.stdin, sync', testGeneratorInput, 0, false, false, 'generator', execaSync);\ntest('Can use generators with result.stdin, objectMode, sync', testGeneratorInput, 0, true, false, 'generator', execaSync);\ntest('Can use generators with result.stdin, noop transform, sync', testGeneratorInput, 0, false, true, 'generator', execaSync);\ntest('Can use generators with result.stdin, objectMode, noop transform, sync', testGeneratorInput, 0, true, true, 'generator', execaSync);\ntest('Can use duplexes with result.stdin', testGeneratorInput, 0, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'duplex', execa);\ntest('Can use webTransforms with result.stdin', testGeneratorInput, 0, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as input', testGeneratorInput, 3, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdin, objectMode', testGeneratorInput, 0, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as input, objectMode', testGeneratorInput, 3, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdin, noop transform', testGeneratorInput, 0, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as input, noop transform', testGeneratorInput, 3, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdin, objectMode, noop transform', testGeneratorInput, 0, true, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as input, objectMode, noop transform', testGeneratorInput, 3, true, true, 'webTransform', execa);\n\n// eslint-disable-next-line max-params\nconst testGeneratorInputPipe = async (t, useShortcutProperty, objectMode, addNoopTransform, type, input) => {\n\tconst {generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);\n\tconst subprocess = execa('stdin-fd.js', ['0'], getStdio(0, generators));\n\tconst stream = useShortcutProperty ? subprocess.stdin : subprocess.stdio[0];\n\tstream.end(...input);\n\tconst {stdout} = await subprocess;\n\tconst expectedOutput = input[1] === 'utf16le' ? Buffer.from(output, input[1]).toString() : output;\n\tt.is(stdout, expectedOutput);\n};\n\ntest('Can use generators with subprocess.stdio[0] and default encoding', testGeneratorInputPipe, false, false, false, 'generator', [foobarString, 'utf8']);\ntest('Can use generators with subprocess.stdin and default encoding', testGeneratorInputPipe, true, false, false, 'generator', [foobarString, 'utf8']);\ntest('Can use generators with subprocess.stdio[0] and encoding \"utf16le\"', testGeneratorInputPipe, false, false, false, 'generator', [foobarString, 'utf16le']);\ntest('Can use generators with subprocess.stdin and encoding \"utf16le\"', testGeneratorInputPipe, true, false, false, 'generator', [foobarString, 'utf16le']);\ntest('Can use generators with subprocess.stdio[0] and encoding \"buffer\"', testGeneratorInputPipe, false, false, false, 'generator', [foobarBuffer, 'buffer']);\ntest('Can use generators with subprocess.stdin and encoding \"buffer\"', testGeneratorInputPipe, true, false, false, 'generator', [foobarBuffer, 'buffer']);\ntest('Can use generators with subprocess.stdio[0] and encoding \"hex\"', testGeneratorInputPipe, false, false, false, 'generator', [foobarHex, 'hex']);\ntest('Can use generators with subprocess.stdin and encoding \"hex\"', testGeneratorInputPipe, true, false, false, 'generator', [foobarHex, 'hex']);\ntest('Can use generators with subprocess.stdio[0], objectMode', testGeneratorInputPipe, false, true, false, 'generator', [foobarObject]);\ntest('Can use generators with subprocess.stdin, objectMode', testGeneratorInputPipe, true, true, false, 'generator', [foobarObject]);\ntest('Can use generators with subprocess.stdio[0] and default encoding, noop transform', testGeneratorInputPipe, false, false, true, 'generator', [foobarString, 'utf8']);\ntest('Can use generators with subprocess.stdin and default encoding, noop transform', testGeneratorInputPipe, true, false, true, 'generator', [foobarString, 'utf8']);\ntest('Can use generators with subprocess.stdio[0] and encoding \"utf16le\", noop transform', testGeneratorInputPipe, false, false, true, 'generator', [foobarString, 'utf16le']);\ntest('Can use generators with subprocess.stdin and encoding \"utf16le\", noop transform', testGeneratorInputPipe, true, false, true, 'generator', [foobarString, 'utf16le']);\ntest('Can use generators with subprocess.stdio[0] and encoding \"buffer\", noop transform', testGeneratorInputPipe, false, false, true, 'generator', [foobarBuffer, 'buffer']);\ntest('Can use generators with subprocess.stdin and encoding \"buffer\", noop transform', testGeneratorInputPipe, true, false, true, 'generator', [foobarBuffer, 'buffer']);\ntest('Can use generators with subprocess.stdio[0] and encoding \"hex\", noop transform', testGeneratorInputPipe, false, false, true, 'generator', [foobarHex, 'hex']);\ntest('Can use generators with subprocess.stdin and encoding \"hex\", noop transform', testGeneratorInputPipe, true, false, true, 'generator', [foobarHex, 'hex']);\ntest('Can use generators with subprocess.stdio[0], objectMode, noop transform', testGeneratorInputPipe, false, true, true, 'generator', [foobarObject]);\ntest('Can use generators with subprocess.stdin, objectMode, noop transform', testGeneratorInputPipe, true, true, true, 'generator', [foobarObject]);\ntest('Can use duplexes with subprocess.stdio[0] and default encoding', testGeneratorInputPipe, false, false, false, 'duplex', [foobarString, 'utf8']);\ntest('Can use duplexes with subprocess.stdin and default encoding', testGeneratorInputPipe, true, false, false, 'duplex', [foobarString, 'utf8']);\ntest('Can use duplexes with subprocess.stdio[0] and encoding \"utf16le\"', testGeneratorInputPipe, false, false, false, 'duplex', [foobarString, 'utf16le']);\ntest('Can use duplexes with subprocess.stdin and encoding \"utf16le\"', testGeneratorInputPipe, true, false, false, 'duplex', [foobarString, 'utf16le']);\ntest('Can use duplexes with subprocess.stdio[0] and encoding \"buffer\"', testGeneratorInputPipe, false, false, false, 'duplex', [foobarBuffer, 'buffer']);\ntest('Can use duplexes with subprocess.stdin and encoding \"buffer\"', testGeneratorInputPipe, true, false, false, 'duplex', [foobarBuffer, 'buffer']);\ntest('Can use duplexes with subprocess.stdio[0] and encoding \"hex\"', testGeneratorInputPipe, false, false, false, 'duplex', [foobarHex, 'hex']);\ntest('Can use duplexes with subprocess.stdin and encoding \"hex\"', testGeneratorInputPipe, true, false, false, 'duplex', [foobarHex, 'hex']);\ntest('Can use duplexes with subprocess.stdio[0], objectMode', testGeneratorInputPipe, false, true, false, 'duplex', [foobarObject]);\ntest('Can use duplexes with subprocess.stdin, objectMode', testGeneratorInputPipe, true, true, false, 'duplex', [foobarObject]);\ntest('Can use duplexes with subprocess.stdio[0] and default encoding, noop transform', testGeneratorInputPipe, false, false, true, 'duplex', [foobarString, 'utf8']);\ntest('Can use duplexes with subprocess.stdin and default encoding, noop transform', testGeneratorInputPipe, true, false, true, 'duplex', [foobarString, 'utf8']);\ntest('Can use duplexes with subprocess.stdio[0] and encoding \"utf16le\", noop transform', testGeneratorInputPipe, false, false, true, 'duplex', [foobarString, 'utf16le']);\ntest('Can use duplexes with subprocess.stdin and encoding \"utf16le\", noop transform', testGeneratorInputPipe, true, false, true, 'duplex', [foobarString, 'utf16le']);\ntest('Can use duplexes with subprocess.stdio[0] and encoding \"buffer\", noop transform', testGeneratorInputPipe, false, false, true, 'duplex', [foobarBuffer, 'buffer']);\ntest('Can use duplexes with subprocess.stdin and encoding \"buffer\", noop transform', testGeneratorInputPipe, true, false, true, 'duplex', [foobarBuffer, 'buffer']);\ntest('Can use duplexes with subprocess.stdio[0] and encoding \"hex\", noop transform', testGeneratorInputPipe, false, false, true, 'duplex', [foobarHex, 'hex']);\ntest('Can use duplexes with subprocess.stdin and encoding \"hex\", noop transform', testGeneratorInputPipe, true, false, true, 'duplex', [foobarHex, 'hex']);\ntest('Can use duplexes with subprocess.stdio[0], objectMode, noop transform', testGeneratorInputPipe, false, true, true, 'duplex', [foobarObject]);\ntest('Can use duplexes with subprocess.stdin, objectMode, noop transform', testGeneratorInputPipe, true, true, true, 'duplex', [foobarObject]);\ntest('Can use webTransforms with subprocess.stdio[0] and default encoding', testGeneratorInputPipe, false, false, false, 'webTransform', [foobarString, 'utf8']);\ntest('Can use webTransforms with subprocess.stdin and default encoding', testGeneratorInputPipe, true, false, false, 'webTransform', [foobarString, 'utf8']);\ntest('Can use webTransforms with subprocess.stdio[0] and encoding \"utf16le\"', testGeneratorInputPipe, false, false, false, 'webTransform', [foobarString, 'utf16le']);\ntest('Can use webTransforms with subprocess.stdin and encoding \"utf16le\"', testGeneratorInputPipe, true, false, false, 'webTransform', [foobarString, 'utf16le']);\ntest('Can use webTransforms with subprocess.stdio[0] and encoding \"buffer\"', testGeneratorInputPipe, false, false, false, 'webTransform', [foobarBuffer, 'buffer']);\ntest('Can use webTransforms with subprocess.stdin and encoding \"buffer\"', testGeneratorInputPipe, true, false, false, 'webTransform', [foobarBuffer, 'buffer']);\ntest('Can use webTransforms with subprocess.stdio[0] and encoding \"hex\"', testGeneratorInputPipe, false, false, false, 'webTransform', [foobarHex, 'hex']);\ntest('Can use webTransforms with subprocess.stdin and encoding \"hex\"', testGeneratorInputPipe, true, false, false, 'webTransform', [foobarHex, 'hex']);\ntest('Can use webTransforms with subprocess.stdio[0], objectMode', testGeneratorInputPipe, false, true, false, 'webTransform', [foobarObject]);\ntest('Can use webTransforms with subprocess.stdin, objectMode', testGeneratorInputPipe, true, true, false, 'webTransform', [foobarObject]);\ntest('Can use webTransforms with subprocess.stdio[0] and default encoding, noop transform', testGeneratorInputPipe, false, false, true, 'webTransform', [foobarString, 'utf8']);\ntest('Can use webTransforms with subprocess.stdin and default encoding, noop transform', testGeneratorInputPipe, true, false, true, 'webTransform', [foobarString, 'utf8']);\ntest('Can use webTransforms with subprocess.stdio[0] and encoding \"utf16le\", noop transform', testGeneratorInputPipe, false, false, true, 'webTransform', [foobarString, 'utf16le']);\ntest('Can use webTransforms with subprocess.stdin and encoding \"utf16le\", noop transform', testGeneratorInputPipe, true, false, true, 'webTransform', [foobarString, 'utf16le']);\ntest('Can use webTransforms with subprocess.stdio[0] and encoding \"buffer\", noop transform', testGeneratorInputPipe, false, false, true, 'webTransform', [foobarBuffer, 'buffer']);\ntest('Can use webTransforms with subprocess.stdin and encoding \"buffer\", noop transform', testGeneratorInputPipe, true, false, true, 'webTransform', [foobarBuffer, 'buffer']);\ntest('Can use webTransforms with subprocess.stdio[0] and encoding \"hex\", noop transform', testGeneratorInputPipe, false, false, true, 'webTransform', [foobarHex, 'hex']);\ntest('Can use webTransforms with subprocess.stdin and encoding \"hex\", noop transform', testGeneratorInputPipe, true, false, true, 'webTransform', [foobarHex, 'hex']);\ntest('Can use webTransforms with subprocess.stdio[0], objectMode, noop transform', testGeneratorInputPipe, false, true, true, 'webTransform', [foobarObject]);\ntest('Can use webTransforms with subprocess.stdin, objectMode, noop transform', testGeneratorInputPipe, true, true, true, 'webTransform', [foobarObject]);\n\nconst testGeneratorStdioInputPipe = async (t, objectMode, addNoopTransform, type) => {\n\tconst {input, generators, output} = getInputObjectMode(objectMode, addNoopTransform, type);\n\tconst subprocess = execa('stdin-fd.js', ['3'], getStdio(3, [[], ...generators]));\n\tsubprocess.stdio[3].write(Array.isArray(input) ? input[0] : input);\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, output);\n};\n\ntest('Can use generators with subprocess.stdio[*] as input', testGeneratorStdioInputPipe, false, false, 'generator');\ntest('Can use generators with subprocess.stdio[*] as input, objectMode', testGeneratorStdioInputPipe, true, false, 'generator');\ntest('Can use generators with subprocess.stdio[*] as input, noop transform', testGeneratorStdioInputPipe, false, true, 'generator');\ntest('Can use generators with subprocess.stdio[*] as input, objectMode, noop transform', testGeneratorStdioInputPipe, true, true, 'generator');\ntest('Can use duplexes with subprocess.stdio[*] as input', testGeneratorStdioInputPipe, false, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as input, objectMode', testGeneratorStdioInputPipe, true, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as input, noop transform', testGeneratorStdioInputPipe, false, true, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as input, objectMode, noop transform', testGeneratorStdioInputPipe, true, true, 'duplex');\ntest('Can use webTransforms with subprocess.stdio[*] as input', testGeneratorStdioInputPipe, false, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as input, objectMode', testGeneratorStdioInputPipe, true, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as input, noop transform', testGeneratorStdioInputPipe, false, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as input, objectMode, noop transform', testGeneratorStdioInputPipe, true, true, 'webTransform');\n"
  },
  {
    "path": "test/transform/generator-main.js",
    "content": "import {Buffer} from 'node:buffer';\nimport {scheduler} from 'node:timers/promises';\nimport test from 'ava';\nimport {getStreamAsArray} from 'get-stream';\nimport {execa, execaSync} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {\n\tnoopGenerator,\n\toutputObjectGenerator,\n\tconvertTransformToFinal,\n\tprefix,\n\tsuffix,\n} from '../helpers/generator.js';\nimport {generatorsMap} from '../helpers/map.js';\nimport {defaultHighWaterMark} from '../helpers/stream.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {maxBuffer, assertErrorMessage} from '../helpers/max-buffer.js';\n\nsetFixtureDirectory();\n\nconst repeatCount = defaultHighWaterMark * 3;\n\nconst writerGenerator = function * () {\n\tfor (let index = 0; index < repeatCount; index += 1) {\n\t\tyield '\\n';\n\t}\n};\n\nconst getLengthGenerator = function * (t, chunk) {\n\tt.is(chunk.length, 1);\n\tyield chunk;\n};\n\n// eslint-disable-next-line max-params\nconst testHighWaterMark = async (t, passThrough, binary, objectMode, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: [\n\t\t\t...(objectMode ? [outputObjectGenerator()] : []),\n\t\t\twriterGenerator,\n\t\t\t...(passThrough ? [noopGenerator(false, binary)] : []),\n\t\t\t{transform: getLengthGenerator.bind(undefined, t), preserveNewlines: true, objectMode: true},\n\t\t],\n\t});\n\tt.is(stdout.length, repeatCount);\n\tt.true(stdout.every(chunk => chunk === '\\n'));\n};\n\ntest('Synchronous yields are not buffered, no passThrough', testHighWaterMark, false, false, false, execa);\ntest('Synchronous yields are not buffered, line-wise passThrough', testHighWaterMark, true, false, false, execa);\ntest('Synchronous yields are not buffered, binary passThrough', testHighWaterMark, true, true, false, execa);\ntest('Synchronous yields are not buffered, objectMode as input but not output', testHighWaterMark, false, false, true, execa);\ntest('Synchronous yields are not buffered, no passThrough, sync', testHighWaterMark, false, false, false, execaSync);\ntest('Synchronous yields are not buffered, line-wise passThrough, sync', testHighWaterMark, true, false, false, execaSync);\ntest('Synchronous yields are not buffered, binary passThrough, sync', testHighWaterMark, true, true, false, execaSync);\ntest('Synchronous yields are not buffered, objectMode as input but not output, sync', testHighWaterMark, false, false, true, execaSync);\n\n// eslint-disable-next-line max-params\nconst testNoYield = async (t, type, objectMode, final, output, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {stdout: convertTransformToFinal(generatorsMap[type].noYield(objectMode), final)});\n\tt.deepEqual(stdout, output);\n};\n\ntest('Generator can filter \"transform\" by not calling yield', testNoYield, 'generator', false, false, '', execa);\ntest('Generator can filter \"transform\" by not calling yield, objectMode', testNoYield, 'generator', true, false, [], execa);\ntest('Generator can filter \"final\" by not calling yield', testNoYield, 'generator', false, true, '', execa);\ntest('Generator can filter \"final\" by not calling yield, objectMode', testNoYield, 'generator', true, true, [], execa);\ntest('Generator can filter \"transform\" by not calling yield, sync', testNoYield, 'generator', false, false, '', execaSync);\ntest('Generator can filter \"transform\" by not calling yield, objectMode, sync', testNoYield, 'generator', true, false, [], execaSync);\ntest('Generator can filter \"final\" by not calling yield, sync', testNoYield, 'generator', false, true, '', execaSync);\ntest('Generator can filter \"final\" by not calling yield, objectMode, sync', testNoYield, 'generator', true, true, [], execaSync);\ntest('Duplex can filter by not calling push', testNoYield, 'duplex', false, false, '', execa);\ntest('Duplex can filter by not calling push, objectMode', testNoYield, 'duplex', true, false, [], execa);\ntest('WebTransform can filter by not calling push', testNoYield, 'webTransform', false, false, '', execa);\ntest('WebTransform can filter by not calling push, objectMode', testNoYield, 'webTransform', true, false, [], execa);\n\nconst testMultipleYields = async (t, type, final, binary) => {\n\tconst {stdout} = await execa('noop-fd.js', ['1', foobarString], {stdout: convertTransformToFinal(generatorsMap[type].multipleYield(), final)});\n\tconst newline = binary ? '' : '\\n';\n\tt.is(stdout, `${prefix}${newline}${foobarString}${newline}${suffix}`);\n};\n\ntest('Generator can yield \"transform\" multiple times at different moments', testMultipleYields, 'generator', false, false);\ntest('Generator can yield \"final\" multiple times at different moments', testMultipleYields, 'generator', true, false);\ntest('Duplex can push multiple times at different moments', testMultipleYields, 'duplex', false, true);\ntest('WebTransform can push multiple times at different moments', testMultipleYields, 'webTransform', false, true);\n\nconst partsPerChunk = 4;\nconst chunksPerCall = 10;\nconst callCount = 5;\nconst fullString = '\\n'.repeat(defaultHighWaterMark / partsPerChunk);\n\nconst yieldFullStrings = function * () {\n\tyield * Array.from({length: partsPerChunk * chunksPerCall}).fill(fullString);\n};\n\nconst manyYieldGenerator = async function * () {\n\tfor (let index = 0; index < callCount; index += 1) {\n\t\tyield * yieldFullStrings();\n\t\t// eslint-disable-next-line no-await-in-loop\n\t\tawait scheduler.yield();\n\t}\n};\n\nconst testManyYields = async (t, final) => {\n\tconst subprocess = execa('noop.js', {stdout: convertTransformToFinal(manyYieldGenerator, final), stripFinalNewline: false});\n\tconst [chunks, {stdout}] = await Promise.all([getStreamAsArray(subprocess.stdout), subprocess]);\n\tconst expectedChunk = Buffer.from(fullString);\n\tt.deepEqual(chunks, Array.from({length: callCount * partsPerChunk * chunksPerCall}).fill(expectedChunk));\n\tt.is(chunks.join(''), stdout);\n};\n\ntest('Generator \"transform\" yields are sent right away', testManyYields, false);\ntest('Generator \"final\" yields are sent right away', testManyYields, true);\n\nconst testMaxBuffer = async (t, type) => {\n\tconst bigString = '.'.repeat(maxBuffer);\n\tconst {stdout} = await execa('noop.js', {\n\t\tmaxBuffer,\n\t\tstdout: generatorsMap[type].getOutput(bigString)(false, true),\n\t});\n\tt.is(stdout, bigString);\n\n\tconst {isMaxBuffer, shortMessage} = await t.throwsAsync(execa('noop.js', {\n\t\tmaxBuffer,\n\t\tstdout: generatorsMap[type].getOutput(`${bigString}.`)(false, true),\n\t}));\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage);\n};\n\ntest('Generators take \"maxBuffer\" into account', testMaxBuffer, 'generator');\ntest('Duplexes take \"maxBuffer\" into account', testMaxBuffer, 'duplex');\ntest('WebTransforms take \"maxBuffer\" into account', testMaxBuffer, 'webTransform');\n\ntest('Generators does not take \"maxBuffer\" into account, sync', t => {\n\tconst bigString = '.'.repeat(maxBuffer);\n\tconst {isMaxBuffer, stdout} = execaSync('noop.js', {\n\t\tmaxBuffer,\n\t\tstdout: generatorsMap.generator.getOutput(`${bigString}.`)(false, true),\n\t});\n\tt.false(isMaxBuffer);\n\tt.is(stdout.length, maxBuffer + 1);\n});\n\nconst testMaxBufferObject = async (t, type) => {\n\tconst bigArray = Array.from({length: maxBuffer}).fill('..');\n\tconst {stdout} = await execa('noop.js', {\n\t\tmaxBuffer,\n\t\tstdout: generatorsMap[type].getOutputs(bigArray)(true, true),\n\t});\n\tt.is(stdout.length, maxBuffer);\n\n\tconst {isMaxBuffer, shortMessage} = await t.throwsAsync(execa('noop.js', {\n\t\tmaxBuffer,\n\t\tstdout: generatorsMap[type].getOutputs([...bigArray, ''])(true, true),\n\t}));\n\tt.true(isMaxBuffer);\n\tassertErrorMessage(t, shortMessage, {unit: 'objects'});\n};\n\ntest('Generators take \"maxBuffer\" into account, objectMode', testMaxBufferObject, 'generator');\ntest('Duplexes take \"maxBuffer\" into account, objectMode', testMaxBufferObject, 'duplex');\ntest('WebTransforms take \"maxBuffer\" into account, objectMode', testMaxBufferObject, 'webTransform');\n\ntest('Generators does not take \"maxBuffer\" into account, objectMode, sync', t => {\n\tconst bigArray = Array.from({length: maxBuffer}).fill('..');\n\tconst {isMaxBuffer, stdout} = execaSync('noop.js', {\n\t\tmaxBuffer,\n\t\tstdout: generatorsMap.generator.getOutputs([...bigArray, ''])(true, true),\n\t});\n\tt.false(isMaxBuffer);\n\tt.is(stdout.length, maxBuffer + 1);\n});\n\nconst testAsyncGenerators = async (t, type, final) => {\n\tconst {stdout} = await execa('noop.js', {\n\t\tstdout: convertTransformToFinal(generatorsMap[type].timeout(1e2)(), final),\n\t});\n\tt.is(stdout, foobarString);\n};\n\ntest('Generators \"transform\" is awaited on success', testAsyncGenerators, 'generator', false);\ntest('Generators \"final\" is awaited on success', testAsyncGenerators, 'generator', true);\ntest('Duplex is awaited on success', testAsyncGenerators, 'duplex', false);\ntest('WebTransform is awaited on success', testAsyncGenerators, 'webTransform', false);\n"
  },
  {
    "path": "test/transform/generator-mixed.js",
    "content": "import {readFile, writeFile, rm} from 'node:fs/promises';\nimport {PassThrough} from 'node:stream';\nimport test from 'ava';\nimport getStream from 'get-stream';\nimport tempfile from 'tempfile';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUppercase, foobarUint8Array} from '../helpers/input.js';\nimport {uppercaseGenerator} from '../helpers/generator.js';\nimport {uppercaseBufferDuplex} from '../helpers/duplex.js';\nimport {uppercaseBufferWebTransform} from '../helpers/web-transform.js';\nimport {generatorsMap} from '../helpers/map.js';\n\nsetFixtureDirectory();\n\nconst testInputOption = async (t, type, execaMethod) => {\n\tconst {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: generatorsMap[type].uppercase(), input: foobarUint8Array});\n\tt.is(stdout, foobarUppercase);\n};\n\ntest('Can use generators with input option', testInputOption, 'generator', execa);\ntest('Can use generators with input option, sync', testInputOption, 'generator', execaSync);\ntest('Can use duplexes with input option', testInputOption, 'duplex', execa);\ntest('Can use webTransforms with input option', testInputOption, 'webTransform', execa);\n\n// eslint-disable-next-line max-params\nconst testInputFile = async (t, stdinOption, useInputFile, reversed, execaMethod) => {\n\tconst filePath = tempfile();\n\tawait writeFile(filePath, foobarString);\n\tconst options = useInputFile\n\t\t? {inputFile: filePath, stdin: stdinOption}\n\t\t: {stdin: [{file: filePath}, stdinOption]};\n\toptions.stdin = reversed ? options.stdin.reverse() : options.stdin;\n\tconst {stdout} = await execaMethod('stdin-fd.js', ['0'], options);\n\tt.is(stdout, foobarUppercase);\n\tawait rm(filePath);\n};\n\ntest('Can use generators with a file as input', testInputFile, uppercaseGenerator(), false, false, execa);\ntest('Can use generators with a file as input, reversed', testInputFile, uppercaseGenerator(), false, true, execa);\ntest('Can use generators with inputFile option', testInputFile, uppercaseGenerator(), true, false, execa);\ntest('Can use generators with a file as input, sync', testInputFile, uppercaseGenerator(), false, false, execaSync);\ntest('Can use generators with a file as input, reversed, sync', testInputFile, uppercaseGenerator(), false, true, execaSync);\ntest('Can use generators with inputFile option, sync', testInputFile, uppercaseGenerator(), true, false, execaSync);\ntest('Can use duplexes with a file as input', testInputFile, uppercaseBufferDuplex(), false, false, execa);\ntest('Can use duplexes with a file as input, reversed', testInputFile, uppercaseBufferDuplex(), false, true, execa);\ntest('Can use duplexes with inputFile option', testInputFile, uppercaseBufferDuplex(), true, false, execa);\ntest('Can use webTransforms with a file as input', testInputFile, uppercaseBufferWebTransform(), false, false, execa);\ntest('Can use webTransforms with a file as input, reversed', testInputFile, uppercaseBufferWebTransform(), false, true, execa);\ntest('Can use webTransforms with inputFile option', testInputFile, uppercaseBufferWebTransform(), true, false, execa);\n\nconst testOutputFile = async (t, reversed, type, execaMethod) => {\n\tconst filePath = tempfile();\n\tconst stdoutOption = [generatorsMap[type].uppercaseBuffer(false, true), {file: filePath}];\n\tconst reversedStdoutOption = reversed ? stdoutOption.reverse() : stdoutOption;\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1'], {stdout: reversedStdoutOption});\n\tt.is(stdout, foobarUppercase);\n\tt.is(await readFile(filePath, 'utf8'), foobarUppercase);\n\tawait rm(filePath);\n};\n\ntest('Can use generators with a file as output', testOutputFile, false, 'generator', execa);\ntest('Can use generators with a file as output, reversed', testOutputFile, true, 'generator', execa);\ntest('Can use generators with a file as output, sync', testOutputFile, false, 'generator', execaSync);\ntest('Can use generators with a file as output, reversed, sync', testOutputFile, true, 'generator', execaSync);\ntest('Can use duplexes with a file as output', testOutputFile, false, 'duplex', execa);\ntest('Can use duplexes with a file as output, reversed', testOutputFile, true, 'duplex', execa);\ntest('Can use webTransforms with a file as output', testOutputFile, false, 'webTransform', execa);\ntest('Can use webTransforms with a file as output, reversed', testOutputFile, true, 'webTransform', execa);\n\nconst testWritableDestination = async (t, type) => {\n\tconst passThrough = new PassThrough();\n\tconst [{stdout}, streamOutput] = await Promise.all([\n\t\texeca('noop-fd.js', ['1', foobarString], {stdout: [generatorsMap[type].uppercaseBuffer(false, true), passThrough]}),\n\t\tgetStream(passThrough),\n\t]);\n\tt.is(stdout, foobarUppercase);\n\tt.is(streamOutput, foobarUppercase);\n};\n\ntest('Can use generators to a Writable stream', testWritableDestination, 'generator');\ntest('Can use duplexes to a Writable stream', testWritableDestination, 'duplex');\ntest('Can use webTransforms to a Writable stream', testWritableDestination, 'webTransform');\n\nconst testReadableSource = async (t, type) => {\n\tconst passThrough = new PassThrough();\n\tconst subprocess = execa('stdin-fd.js', ['0'], {stdin: [passThrough, generatorsMap[type].uppercase()]});\n\tpassThrough.end(foobarString);\n\tconst {stdout} = await subprocess;\n\tt.is(stdout, foobarUppercase);\n};\n\ntest('Can use generators from a Readable stream', testReadableSource, 'generator');\ntest('Can use duplexes from a Readable stream', testReadableSource, 'duplex');\ntest('Can use webTransforms from a Readable stream', testReadableSource, 'webTransform');\n\nconst testInherit = async (t, type) => {\n\tconst {stdout} = await execa('nested-inherit.js', [type]);\n\tt.is(stdout, foobarUppercase);\n};\n\ntest('Can use generators with \"inherit\"', testInherit, 'generator');\ntest('Can use duplexes with \"inherit\"', testInherit, 'duplex');\ntest('Can use webTransforms with \"inherit\"', testInherit, 'webTransform');\n"
  },
  {
    "path": "test/transform/generator-output.js",
    "content": "import test from 'ava';\nimport getStream, {getStreamAsArray} from 'get-stream';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {foobarString, foobarUppercase, foobarObject} from '../helpers/input.js';\nimport {generatorsMap} from '../helpers/map.js';\n\nsetFixtureDirectory();\n\nconst getOutputObjectMode = (objectMode, addNoopTransform, type, binary) => objectMode\n\t? {\n\t\tgenerators: generatorsMap[type].addNoop(generatorsMap[type].outputObject(), addNoopTransform, objectMode, binary),\n\t\toutput: [foobarObject],\n\t\tgetStreamMethod: getStreamAsArray,\n\t}\n\t: {\n\t\tgenerators: generatorsMap[type].addNoop(generatorsMap[type].uppercaseBuffer(objectMode, true), addNoopTransform, objectMode, binary),\n\t\toutput: foobarUppercase,\n\t\tgetStreamMethod: getStream,\n\t};\n\n// eslint-disable-next-line max-params\nconst testGeneratorOutput = async (t, fdNumber, reject, useShortcutProperty, objectMode, addNoopTransform, type, execaMethod) => {\n\tconst {generators, output} = getOutputObjectMode(objectMode, addNoopTransform, type);\n\tconst fixtureName = reject ? 'noop-fd.js' : 'noop-fail.js';\n\tconst {stdout, stderr, stdio} = await execaMethod(fixtureName, [`${fdNumber}`, foobarString], {...getStdio(fdNumber, generators), reject});\n\tconst result = useShortcutProperty ? [stdout, stderr][fdNumber - 1] : stdio[fdNumber];\n\tt.deepEqual(result, output);\n};\n\ntest('Can use generators with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'generator', execa);\ntest('Can use generators with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'generator', execa);\ntest('Can use generators with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'generator', execa);\ntest('Can use generators with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'generator', execa);\ntest('Can use generators with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'generator', execa);\ntest('Can use generators with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'generator', execa);\ntest('Can use generators with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'generator', execa);\ntest('Can use generators with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'generator', execa);\ntest('Can use generators with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'generator', execa);\ntest('Can use generators with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'generator', execa);\ntest('Can use generators with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'generator', execa);\ntest('Can use generators with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'generator', execa);\ntest('Can use generators with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'generator', execa);\ntest('Can use generators with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'generator', execa);\ntest('Can use generators with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'generator', execa);\ntest('Can use generators with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'generator', execa);\ntest('Can use generators with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'generator', execa);\ntest('Can use generators with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'generator', execa);\ntest('Can use generators with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'generator', execa);\ntest('Can use generators with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'generator', execa);\ntest('Can use generators with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'generator', execa);\ntest('Can use generators with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'generator', execa);\ntest('Can use generators with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'generator', execa);\ntest('Can use generators with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'generator', execa);\ntest('Can use generators with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'generator', execa);\ntest('Can use generators with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'generator', execa);\ntest('Can use generators with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'generator', execa);\ntest('Can use generators with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'generator', execa);\ntest('Can use generators with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'generator', execa);\ntest('Can use generators with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'generator', execa);\ntest('Can use generators with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'generator', execa);\ntest('Can use generators with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'generator', execa);\ntest('Can use generators with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'generator', execa);\ntest('Can use generators with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'generator', execa);\ntest('Can use generators with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'generator', execa);\ntest('Can use generators with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'generator', execa);\ntest('Can use generators with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'generator', execa);\ntest('Can use generators with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'generator', execa);\ntest('Can use generators with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'generator', execa);\ntest('Can use generators with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'generator', execa);\ntest('Can use generators with result.stdio[1], sync', testGeneratorOutput, 1, true, false, false, false, 'generator', execaSync);\ntest('Can use generators with result.stdout, sync', testGeneratorOutput, 1, true, true, false, false, 'generator', execaSync);\ntest('Can use generators with result.stdio[2], sync', testGeneratorOutput, 2, true, false, false, false, 'generator', execaSync);\ntest('Can use generators with result.stderr, sync', testGeneratorOutput, 2, true, true, false, false, 'generator', execaSync);\ntest('Can use generators with result.stdio[*] as output, sync', testGeneratorOutput, 3, true, false, false, false, 'generator', execaSync);\ntest('Can use generators with error.stdio[1], sync', testGeneratorOutput, 1, false, false, false, false, 'generator', execaSync);\ntest('Can use generators with error.stdout, sync', testGeneratorOutput, 1, false, true, false, false, 'generator', execaSync);\ntest('Can use generators with error.stdio[2], sync', testGeneratorOutput, 2, false, false, false, false, 'generator', execaSync);\ntest('Can use generators with error.stderr, sync', testGeneratorOutput, 2, false, true, false, false, 'generator', execaSync);\ntest('Can use generators with error.stdio[*] as output, sync', testGeneratorOutput, 3, false, false, false, false, 'generator', execaSync);\ntest('Can use generators with result.stdio[1], objectMode, sync', testGeneratorOutput, 1, true, false, true, false, 'generator', execaSync);\ntest('Can use generators with result.stdout, objectMode, sync', testGeneratorOutput, 1, true, true, true, false, 'generator', execaSync);\ntest('Can use generators with result.stdio[2], objectMode, sync', testGeneratorOutput, 2, true, false, true, false, 'generator', execaSync);\ntest('Can use generators with result.stderr, objectMode, sync', testGeneratorOutput, 2, true, true, true, false, 'generator', execaSync);\ntest('Can use generators with result.stdio[*] as output, objectMode, sync', testGeneratorOutput, 3, true, false, true, false, 'generator', execaSync);\ntest('Can use generators with error.stdio[1], objectMode, sync', testGeneratorOutput, 1, false, false, true, false, 'generator', execaSync);\ntest('Can use generators with error.stdout, objectMode, sync', testGeneratorOutput, 1, false, true, true, false, 'generator', execaSync);\ntest('Can use generators with error.stdio[2], objectMode, sync', testGeneratorOutput, 2, false, false, true, false, 'generator', execaSync);\ntest('Can use generators with error.stderr, objectMode, sync', testGeneratorOutput, 2, false, true, true, false, 'generator', execaSync);\ntest('Can use generators with error.stdio[*] as output, objectMode, sync', testGeneratorOutput, 3, false, false, true, false, 'generator', execaSync);\ntest('Can use generators with result.stdio[1], noop transform, sync', testGeneratorOutput, 1, true, false, false, true, 'generator', execaSync);\ntest('Can use generators with result.stdout, noop transform, sync', testGeneratorOutput, 1, true, true, false, true, 'generator', execaSync);\ntest('Can use generators with result.stdio[2], noop transform, sync', testGeneratorOutput, 2, true, false, false, true, 'generator', execaSync);\ntest('Can use generators with result.stderr, noop transform, sync', testGeneratorOutput, 2, true, true, false, true, 'generator', execaSync);\ntest('Can use generators with result.stdio[*] as output, noop transform, sync', testGeneratorOutput, 3, true, false, false, true, 'generator', execaSync);\ntest('Can use generators with error.stdio[1], noop transform, sync', testGeneratorOutput, 1, false, false, false, true, 'generator', execaSync);\ntest('Can use generators with error.stdout, noop transform, sync', testGeneratorOutput, 1, false, true, false, true, 'generator', execaSync);\ntest('Can use generators with error.stdio[2], noop transform, sync', testGeneratorOutput, 2, false, false, false, true, 'generator', execaSync);\ntest('Can use generators with error.stderr, noop transform, sync', testGeneratorOutput, 2, false, true, false, true, 'generator', execaSync);\ntest('Can use generators with error.stdio[*] as output, noop transform, sync', testGeneratorOutput, 3, false, false, false, true, 'generator', execaSync);\ntest('Can use generators with result.stdio[1], objectMode, noop transform, sync', testGeneratorOutput, 1, true, false, true, true, 'generator', execaSync);\ntest('Can use generators with result.stdout, objectMode, noop transform, sync', testGeneratorOutput, 1, true, true, true, true, 'generator', execaSync);\ntest('Can use generators with result.stdio[2], objectMode, noop transform, sync', testGeneratorOutput, 2, true, false, true, true, 'generator', execaSync);\ntest('Can use generators with result.stderr, objectMode, noop transform, sync', testGeneratorOutput, 2, true, true, true, true, 'generator', execaSync);\ntest('Can use generators with result.stdio[*] as output, objectMode, noop transform, sync', testGeneratorOutput, 3, true, false, true, true, 'generator', execaSync);\ntest('Can use generators with error.stdio[1], objectMode, noop transform, sync', testGeneratorOutput, 1, false, false, true, true, 'generator', execaSync);\ntest('Can use generators with error.stdout, objectMode, noop transform, sync', testGeneratorOutput, 1, false, true, true, true, 'generator', execaSync);\ntest('Can use generators with error.stdio[2], objectMode, noop transform, sync', testGeneratorOutput, 2, false, false, true, true, 'generator', execaSync);\ntest('Can use generators with error.stderr, objectMode, noop transform, sync', testGeneratorOutput, 2, false, true, true, true, 'generator', execaSync);\ntest('Can use generators with error.stdio[*] as output, objectMode, noop transform, sync', testGeneratorOutput, 3, false, false, true, true, 'generator', execaSync);\ntest('Can use duplexes with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'duplex', execa);\ntest('Can use duplexes with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'duplex', execa);\ntest('Can use duplexes with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'duplex', execa);\ntest('Can use duplexes with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'duplex', execa);\ntest('Can use duplexes with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'duplex', execa);\ntest('Can use duplexes with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'duplex', execa);\ntest('Can use duplexes with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'duplex', execa);\ntest('Can use duplexes with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'duplex', execa);\ntest('Can use duplexes with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'duplex', execa);\ntest('Can use duplexes with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'duplex', execa);\ntest('Can use duplexes with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'duplex', execa);\ntest('Can use duplexes with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'duplex', execa);\ntest('Can use duplexes with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'duplex', execa);\ntest('Can use duplexes with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'duplex', execa);\ntest('Can use duplexes with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'duplex', execa);\ntest('Can use duplexes with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'duplex', execa);\ntest('Can use duplexes with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'duplex', execa);\ntest('Can use duplexes with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'duplex', execa);\ntest('Can use duplexes with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'duplex', execa);\ntest('Can use duplexes with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'duplex', execa);\ntest('Can use duplexes with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'duplex', execa);\ntest('Can use duplexes with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'duplex', execa);\ntest('Can use duplexes with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'duplex', execa);\ntest('Can use duplexes with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'duplex', execa);\ntest('Can use duplexes with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'duplex', execa);\ntest('Can use webTransforms with result.stdio[1]', testGeneratorOutput, 1, true, false, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdout', testGeneratorOutput, 1, true, true, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[2]', testGeneratorOutput, 2, true, false, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stderr', testGeneratorOutput, 2, true, true, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as output', testGeneratorOutput, 3, true, false, false, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[1]', testGeneratorOutput, 1, false, false, false, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdout', testGeneratorOutput, 1, false, true, false, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[2]', testGeneratorOutput, 2, false, false, false, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stderr', testGeneratorOutput, 2, false, true, false, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[*] as output', testGeneratorOutput, 3, false, false, false, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[1], objectMode', testGeneratorOutput, 1, true, false, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdout, objectMode', testGeneratorOutput, 1, true, true, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[2], objectMode', testGeneratorOutput, 2, true, false, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stderr, objectMode', testGeneratorOutput, 2, true, true, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as output, objectMode', testGeneratorOutput, 3, true, false, true, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[1], objectMode', testGeneratorOutput, 1, false, false, true, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdout, objectMode', testGeneratorOutput, 1, false, true, true, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[2], objectMode', testGeneratorOutput, 2, false, false, true, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stderr, objectMode', testGeneratorOutput, 2, false, true, true, false, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[*] as output, objectMode', testGeneratorOutput, 3, false, false, true, false, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[1], noop transform', testGeneratorOutput, 1, true, false, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdout, noop transform', testGeneratorOutput, 1, true, true, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[2], noop transform', testGeneratorOutput, 2, true, false, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stderr, noop transform', testGeneratorOutput, 2, true, true, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as output, noop transform', testGeneratorOutput, 3, true, false, false, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[1], noop transform', testGeneratorOutput, 1, false, false, false, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdout, noop transform', testGeneratorOutput, 1, false, true, false, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[2], noop transform', testGeneratorOutput, 2, false, false, false, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stderr, noop transform', testGeneratorOutput, 2, false, true, false, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[*] as output, noop transform', testGeneratorOutput, 3, false, false, false, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, true, false, true, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdout, objectMode, noop transform', testGeneratorOutput, 1, true, true, true, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, true, false, true, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stderr, objectMode, noop transform', testGeneratorOutput, 2, true, true, true, true, 'webTransform', execa);\ntest('Can use webTransforms with result.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, true, false, true, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[1], objectMode, noop transform', testGeneratorOutput, 1, false, false, true, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdout, objectMode, noop transform', testGeneratorOutput, 1, false, true, true, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[2], objectMode, noop transform', testGeneratorOutput, 2, false, false, true, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stderr, objectMode, noop transform', testGeneratorOutput, 2, false, true, true, true, 'webTransform', execa);\ntest('Can use webTransforms with error.stdio[*] as output, objectMode, noop transform', testGeneratorOutput, 3, false, false, true, true, 'webTransform', execa);\n\n// eslint-disable-next-line max-params\nconst testGeneratorOutputPipe = async (t, fdNumber, useShortcutProperty, objectMode, addNoopTransform, type) => {\n\tconst {generators, output, getStreamMethod} = getOutputObjectMode(objectMode, addNoopTransform, type, true);\n\tconst subprocess = execa('noop-fd.js', [`${fdNumber}`, foobarString], getStdio(fdNumber, generators));\n\tconst stream = useShortcutProperty ? [subprocess.stdout, subprocess.stderr][fdNumber - 1] : subprocess.stdio[fdNumber];\n\tconst [result] = await Promise.all([getStreamMethod(stream), subprocess]);\n\tt.deepEqual(result, output);\n};\n\ntest('Can use generators with subprocess.stdio[1]', testGeneratorOutputPipe, 1, false, false, false, 'generator');\ntest('Can use generators with subprocess.stdout', testGeneratorOutputPipe, 1, true, false, false, 'generator');\ntest('Can use generators with subprocess.stdio[2]', testGeneratorOutputPipe, 2, false, false, false, 'generator');\ntest('Can use generators with subprocess.stderr', testGeneratorOutputPipe, 2, true, false, false, 'generator');\ntest('Can use generators with subprocess.stdio[*] as output', testGeneratorOutputPipe, 3, false, false, false, 'generator');\ntest('Can use generators with subprocess.stdio[1], objectMode', testGeneratorOutputPipe, 1, false, true, false, 'generator');\ntest('Can use generators with subprocess.stdout, objectMode', testGeneratorOutputPipe, 1, true, true, false, 'generator');\ntest('Can use generators with subprocess.stdio[2], objectMode', testGeneratorOutputPipe, 2, false, true, false, 'generator');\ntest('Can use generators with subprocess.stderr, objectMode', testGeneratorOutputPipe, 2, true, true, false, 'generator');\ntest('Can use generators with subprocess.stdio[*] as output, objectMode', testGeneratorOutputPipe, 3, false, true, false, 'generator');\ntest('Can use generators with subprocess.stdio[1], noop transform', testGeneratorOutputPipe, 1, false, false, true, 'generator');\ntest('Can use generators with subprocess.stdout, noop transform', testGeneratorOutputPipe, 1, true, false, true, 'generator');\ntest('Can use generators with subprocess.stdio[2], noop transform', testGeneratorOutputPipe, 2, false, false, true, 'generator');\ntest('Can use generators with subprocess.stderr, noop transform', testGeneratorOutputPipe, 2, true, false, true, 'generator');\ntest('Can use generators with subprocess.stdio[*] as output, noop transform', testGeneratorOutputPipe, 3, false, false, true, 'generator');\ntest('Can use generators with subprocess.stdio[1], objectMode, noop transform', testGeneratorOutputPipe, 1, false, true, true, 'generator');\ntest('Can use generators with subprocess.stdout, objectMode, noop transform', testGeneratorOutputPipe, 1, true, true, true, 'generator');\ntest('Can use generators with subprocess.stdio[2], objectMode, noop transform', testGeneratorOutputPipe, 2, false, true, true, 'generator');\ntest('Can use generators with subprocess.stderr, objectMode, noop transform', testGeneratorOutputPipe, 2, true, true, true, 'generator');\ntest('Can use generators with subprocess.stdio[*] as output, objectMode, noop transform', testGeneratorOutputPipe, 3, false, true, true, 'generator');\ntest('Can use duplexes with subprocess.stdio[1]', testGeneratorOutputPipe, 1, false, false, false, 'duplex');\ntest('Can use duplexes with subprocess.stdout', testGeneratorOutputPipe, 1, true, false, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[2]', testGeneratorOutputPipe, 2, false, false, false, 'duplex');\ntest('Can use duplexes with subprocess.stderr', testGeneratorOutputPipe, 2, true, false, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as output', testGeneratorOutputPipe, 3, false, false, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[1], objectMode', testGeneratorOutputPipe, 1, false, true, false, 'duplex');\ntest('Can use duplexes with subprocess.stdout, objectMode', testGeneratorOutputPipe, 1, true, true, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[2], objectMode', testGeneratorOutputPipe, 2, false, true, false, 'duplex');\ntest('Can use duplexes with subprocess.stderr, objectMode', testGeneratorOutputPipe, 2, true, true, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as output, objectMode', testGeneratorOutputPipe, 3, false, true, false, 'duplex');\ntest('Can use duplexes with subprocess.stdio[1], noop transform', testGeneratorOutputPipe, 1, false, false, true, 'duplex');\ntest('Can use duplexes with subprocess.stdout, noop transform', testGeneratorOutputPipe, 1, true, false, true, 'duplex');\ntest('Can use duplexes with subprocess.stdio[2], noop transform', testGeneratorOutputPipe, 2, false, false, true, 'duplex');\ntest('Can use duplexes with subprocess.stderr, noop transform', testGeneratorOutputPipe, 2, true, false, true, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as output, noop transform', testGeneratorOutputPipe, 3, false, false, true, 'duplex');\ntest('Can use duplexes with subprocess.stdio[1], objectMode, noop transform', testGeneratorOutputPipe, 1, false, true, true, 'duplex');\ntest('Can use duplexes with subprocess.stdout, objectMode, noop transform', testGeneratorOutputPipe, 1, true, true, true, 'duplex');\ntest('Can use duplexes with subprocess.stdio[2], objectMode, noop transform', testGeneratorOutputPipe, 2, false, true, true, 'duplex');\ntest('Can use duplexes with subprocess.stderr, objectMode, noop transform', testGeneratorOutputPipe, 2, true, true, true, 'duplex');\ntest('Can use duplexes with subprocess.stdio[*] as output, objectMode, noop transform', testGeneratorOutputPipe, 3, false, true, true, 'duplex');\ntest('Can use webTransforms with subprocess.stdio[1]', testGeneratorOutputPipe, 1, false, false, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdout', testGeneratorOutputPipe, 1, true, false, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[2]', testGeneratorOutputPipe, 2, false, false, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stderr', testGeneratorOutputPipe, 2, true, false, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as output', testGeneratorOutputPipe, 3, false, false, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[1], objectMode', testGeneratorOutputPipe, 1, false, true, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdout, objectMode', testGeneratorOutputPipe, 1, true, true, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[2], objectMode', testGeneratorOutputPipe, 2, false, true, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stderr, objectMode', testGeneratorOutputPipe, 2, true, true, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as output, objectMode', testGeneratorOutputPipe, 3, false, true, false, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[1], noop transform', testGeneratorOutputPipe, 1, false, false, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdout, noop transform', testGeneratorOutputPipe, 1, true, false, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[2], noop transform', testGeneratorOutputPipe, 2, false, false, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stderr, noop transform', testGeneratorOutputPipe, 2, true, false, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as output, noop transform', testGeneratorOutputPipe, 3, false, false, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[1], objectMode, noop transform', testGeneratorOutputPipe, 1, false, true, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdout, objectMode, noop transform', testGeneratorOutputPipe, 1, true, true, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[2], objectMode, noop transform', testGeneratorOutputPipe, 2, false, true, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stderr, objectMode, noop transform', testGeneratorOutputPipe, 2, true, true, true, 'webTransform');\ntest('Can use webTransforms with subprocess.stdio[*] as output, objectMode, noop transform', testGeneratorOutputPipe, 3, false, true, true, 'webTransform');\n"
  },
  {
    "path": "test/transform/generator-return.js",
    "content": "import {Buffer} from 'node:buffer';\nimport test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUint8Array, foobarBuffer} from '../helpers/input.js';\nimport {getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testGeneratorReturnType = async (t, input, encoding, reject, objectMode, final, execaMethod) => {\n\tconst fixtureName = reject ? 'noop-fd.js' : 'noop-fail.js';\n\tconst {stdout} = await execaMethod(fixtureName, ['1', foobarString], {\n\t\tstdout: convertTransformToFinal(getOutputGenerator(input)(objectMode, true), final),\n\t\tencoding,\n\t\treject,\n\t});\n\tconst typeofChunk = Array.isArray(stdout) ? stdout[0] : stdout;\n\tconst output = Buffer.from(typeofChunk, encoding === 'buffer' || objectMode ? undefined : encoding).toString();\n\tt.is(output, foobarString);\n};\n\ntest('Generator can return string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, false, execa);\ntest('Generator can return Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false, execa);\ntest('Generator can return Buffer with default encoding', testGeneratorReturnType, foobarBuffer, 'utf8', true, false, false, execa);\ntest('Generator can return string with encoding \"utf16le\"', testGeneratorReturnType, foobarString, 'utf16le', true, false, false, execa);\ntest('Generator can return Uint8Array with encoding \"utf16le\"', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, false, false, execa);\ntest('Generator can return Buffer with encoding \"utf16le\"', testGeneratorReturnType, foobarBuffer, 'utf16le', true, false, false, execa);\ntest('Generator can return string with encoding \"buffer\"', testGeneratorReturnType, foobarString, 'buffer', true, false, false, execa);\ntest('Generator can return Uint8Array with encoding \"buffer\"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false, execa);\ntest('Generator can return Buffer with encoding \"buffer\"', testGeneratorReturnType, foobarBuffer, 'buffer', true, false, false, execa);\ntest('Generator can return string with encoding \"hex\"', testGeneratorReturnType, foobarString, 'hex', true, false, false, execa);\ntest('Generator can return Uint8Array with encoding \"hex\"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false, execa);\ntest('Generator can return Buffer with encoding \"hex\"', testGeneratorReturnType, foobarBuffer, 'hex', true, false, false, execa);\ntest('Generator can return string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, false, execa);\ntest('Generator can return Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false, execa);\ntest('Generator can return string with encoding \"utf16le\", failure', testGeneratorReturnType, foobarString, 'utf16le', false, false, false, execa);\ntest('Generator can return Uint8Array with encoding \"utf16le\", failure', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, false, false, execa);\ntest('Generator can return string with encoding \"buffer\", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, false, execa);\ntest('Generator can return Uint8Array with encoding \"buffer\", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false, execa);\ntest('Generator can return string with encoding \"hex\", failure', testGeneratorReturnType, foobarString, 'hex', false, false, false, execa);\ntest('Generator can return Uint8Array with encoding \"hex\", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false, execa);\ntest('Generator can return string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, false, execa);\ntest('Generator can return Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false, execa);\ntest('Generator can return string with encoding \"utf16le\", objectMode', testGeneratorReturnType, foobarString, 'utf16le', true, true, false, execa);\ntest('Generator can return Uint8Array with encoding \"utf16le\", objectMode', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, true, false, execa);\ntest('Generator can return string with encoding \"buffer\", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, false, execa);\ntest('Generator can return Uint8Array with encoding \"buffer\", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false, execa);\ntest('Generator can return string with encoding \"hex\", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, false, execa);\ntest('Generator can return Uint8Array with encoding \"hex\", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false, execa);\ntest('Generator can return string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, false, execa);\ntest('Generator can return Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false, execa);\ntest('Generator can return string with encoding \"utf16le\", objectMode, failure', testGeneratorReturnType, foobarString, 'utf16le', false, true, false, execa);\ntest('Generator can return Uint8Array with encoding \"utf16le\", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, true, false, execa);\ntest('Generator can return string with encoding \"buffer\", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, false, execa);\ntest('Generator can return Uint8Array with encoding \"buffer\", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false, execa);\ntest('Generator can return string with encoding \"hex\", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, false, execa);\ntest('Generator can return Uint8Array with encoding \"hex\", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false, execa);\ntest('Generator can return final string with default encoding', testGeneratorReturnType, foobarString, 'utf8', true, false, true, execa);\ntest('Generator can return final Uint8Array with default encoding', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true, execa);\ntest('Generator can return final string with encoding \"utf16le\"', testGeneratorReturnType, foobarString, 'utf16le', true, false, true, execa);\ntest('Generator can return final Uint8Array with encoding \"utf16le\"', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, false, true, execa);\ntest('Generator can return final string with encoding \"buffer\"', testGeneratorReturnType, foobarString, 'buffer', true, false, true, execa);\ntest('Generator can return final Uint8Array with encoding \"buffer\"', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true, execa);\ntest('Generator can return final string with encoding \"hex\"', testGeneratorReturnType, foobarString, 'hex', true, false, true, execa);\ntest('Generator can return final Uint8Array with encoding \"hex\"', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true, execa);\ntest('Generator can return final string with default encoding, failure', testGeneratorReturnType, foobarString, 'utf8', false, false, true, execa);\ntest('Generator can return final Uint8Array with default encoding, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true, execa);\ntest('Generator can return final string with encoding \"utf16le\", failure', testGeneratorReturnType, foobarString, 'utf16le', false, false, true, execa);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", failure', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, false, true, execa);\ntest('Generator can return final string with encoding \"buffer\", failure', testGeneratorReturnType, foobarString, 'buffer', false, false, true, execa);\ntest('Generator can return final Uint8Array with encoding \"buffer\", failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true, execa);\ntest('Generator can return final string with encoding \"hex\", failure', testGeneratorReturnType, foobarString, 'hex', false, false, true, execa);\ntest('Generator can return final Uint8Array with encoding \"hex\", failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true, execa);\ntest('Generator can return final string with default encoding, objectMode', testGeneratorReturnType, foobarString, 'utf8', true, true, true, execa);\ntest('Generator can return final Uint8Array with default encoding, objectMode', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true, execa);\ntest('Generator can return final string with encoding \"utf16le\", objectMode', testGeneratorReturnType, foobarString, 'utf16le', true, true, true, execa);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", objectMode', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, true, true, execa);\ntest('Generator can return final string with encoding \"buffer\", objectMode', testGeneratorReturnType, foobarString, 'buffer', true, true, true, execa);\ntest('Generator can return final Uint8Array with encoding \"buffer\", objectMode', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true, execa);\ntest('Generator can return final string with encoding \"hex\", objectMode', testGeneratorReturnType, foobarString, 'hex', true, true, true, execa);\ntest('Generator can return final Uint8Array with encoding \"hex\", objectMode', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true, execa);\ntest('Generator can return final string with default encoding, objectMode, failure', testGeneratorReturnType, foobarString, 'utf8', false, true, true, execa);\ntest('Generator can return final Uint8Array with default encoding, objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true, execa);\ntest('Generator can return final string with encoding \"utf16le\", objectMode, failure', testGeneratorReturnType, foobarString, 'utf16le', false, true, true, execa);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, true, true, execa);\ntest('Generator can return final string with encoding \"buffer\", objectMode, failure', testGeneratorReturnType, foobarString, 'buffer', false, true, true, execa);\ntest('Generator can return final Uint8Array with encoding \"buffer\", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true, execa);\ntest('Generator can return final string with encoding \"hex\", objectMode, failure', testGeneratorReturnType, foobarString, 'hex', false, true, true, execa);\ntest('Generator can return final Uint8Array with encoding \"hex\", objectMode, failure', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true, execa);\ntest('Generator can return string with default encoding, sync', testGeneratorReturnType, foobarString, 'utf8', true, false, false, execaSync);\ntest('Generator can return Uint8Array with default encoding, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, false, execaSync);\ntest('Generator can return Buffer with default encoding, sync', testGeneratorReturnType, foobarBuffer, 'utf8', true, false, false, execaSync);\ntest('Generator can return string with encoding \"utf16le\", sync', testGeneratorReturnType, foobarString, 'utf16le', true, false, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"utf16le\", sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, false, false, execaSync);\ntest('Generator can return Buffer with encoding \"utf16le\", sync', testGeneratorReturnType, foobarBuffer, 'utf16le', true, false, false, execaSync);\ntest('Generator can return string with encoding \"buffer\", sync', testGeneratorReturnType, foobarString, 'buffer', true, false, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"buffer\", sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, false, execaSync);\ntest('Generator can return Buffer with encoding \"buffer\", sync', testGeneratorReturnType, foobarBuffer, 'buffer', true, false, false, execaSync);\ntest('Generator can return string with encoding \"hex\", sync', testGeneratorReturnType, foobarString, 'hex', true, false, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"hex\", sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, false, execaSync);\ntest('Generator can return Buffer with encoding \"hex\", sync', testGeneratorReturnType, foobarBuffer, 'hex', true, false, false, execaSync);\ntest('Generator can return string with default encoding, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, false, false, execaSync);\ntest('Generator can return Uint8Array with default encoding, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, false, execaSync);\ntest('Generator can return string with encoding \"utf16le\", failure, sync', testGeneratorReturnType, foobarString, 'utf16le', false, false, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"utf16le\", failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, false, false, execaSync);\ntest('Generator can return string with encoding \"buffer\", failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, false, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"buffer\", failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, false, execaSync);\ntest('Generator can return string with encoding \"hex\", failure, sync', testGeneratorReturnType, foobarString, 'hex', false, false, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"hex\", failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, false, execaSync);\ntest('Generator can return string with default encoding, objectMode, sync', testGeneratorReturnType, foobarString, 'utf8', true, true, false, execaSync);\ntest('Generator can return Uint8Array with default encoding, objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, false, execaSync);\ntest('Generator can return string with encoding \"utf16le\", objectMode, sync', testGeneratorReturnType, foobarString, 'utf16le', true, true, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"utf16le\", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, true, false, execaSync);\ntest('Generator can return string with encoding \"buffer\", objectMode, sync', testGeneratorReturnType, foobarString, 'buffer', true, true, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"buffer\", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, false, execaSync);\ntest('Generator can return string with encoding \"hex\", objectMode, sync', testGeneratorReturnType, foobarString, 'hex', true, true, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"hex\", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, false, execaSync);\ntest('Generator can return string with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, true, false, execaSync);\ntest('Generator can return Uint8Array with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, false, execaSync);\ntest('Generator can return string with encoding \"utf16le\", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf16le', false, true, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"utf16le\", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, true, false, execaSync);\ntest('Generator can return string with encoding \"buffer\", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, true, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"buffer\", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, false, execaSync);\ntest('Generator can return string with encoding \"hex\", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'hex', false, true, false, execaSync);\ntest('Generator can return Uint8Array with encoding \"hex\", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, false, execaSync);\ntest('Generator can return final string with default encoding, sync', testGeneratorReturnType, foobarString, 'utf8', true, false, true, execaSync);\ntest('Generator can return final Uint8Array with default encoding, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, false, true, execaSync);\ntest('Generator can return final string with encoding \"utf16le\", sync', testGeneratorReturnType, foobarString, 'utf16le', true, false, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, false, true, execaSync);\ntest('Generator can return final string with encoding \"buffer\", sync', testGeneratorReturnType, foobarString, 'buffer', true, false, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"buffer\", sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, false, true, execaSync);\ntest('Generator can return final string with encoding \"hex\", sync', testGeneratorReturnType, foobarString, 'hex', true, false, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"hex\", sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, false, true, execaSync);\ntest('Generator can return final string with default encoding, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, false, true, execaSync);\ntest('Generator can return final Uint8Array with default encoding, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, false, true, execaSync);\ntest('Generator can return final string with encoding \"utf16le\", failure, sync', testGeneratorReturnType, foobarString, 'utf16le', false, false, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, false, true, execaSync);\ntest('Generator can return final string with encoding \"buffer\", failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, false, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"buffer\", failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, false, true, execaSync);\ntest('Generator can return final string with encoding \"hex\", failure, sync', testGeneratorReturnType, foobarString, 'hex', false, false, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"hex\", failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, false, true, execaSync);\ntest('Generator can return final string with default encoding, objectMode, sync', testGeneratorReturnType, foobarString, 'utf8', true, true, true, execaSync);\ntest('Generator can return final Uint8Array with default encoding, objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', true, true, true, execaSync);\ntest('Generator can return final string with encoding \"utf16le\", objectMode, sync', testGeneratorReturnType, foobarString, 'utf16le', true, true, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', true, true, true, execaSync);\ntest('Generator can return final string with encoding \"buffer\", objectMode, sync', testGeneratorReturnType, foobarString, 'buffer', true, true, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"buffer\", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', true, true, true, execaSync);\ntest('Generator can return final string with encoding \"hex\", objectMode, sync', testGeneratorReturnType, foobarString, 'hex', true, true, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"hex\", objectMode, sync', testGeneratorReturnType, foobarUint8Array, 'hex', true, true, true, execaSync);\ntest('Generator can return final string with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf8', false, true, true, execaSync);\ntest('Generator can return final Uint8Array with default encoding, objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf8', false, true, true, execaSync);\ntest('Generator can return final string with encoding \"utf16le\", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'utf16le', false, true, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"utf16le\", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'utf16le', false, true, true, execaSync);\ntest('Generator can return final string with encoding \"buffer\", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'buffer', false, true, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"buffer\", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'buffer', false, true, true, execaSync);\ntest('Generator can return final string with encoding \"hex\", objectMode, failure, sync', testGeneratorReturnType, foobarString, 'hex', false, true, true, execaSync);\ntest('Generator can return final Uint8Array with encoding \"hex\", objectMode, failure, sync', testGeneratorReturnType, foobarUint8Array, 'hex', false, true, true, execaSync);\n"
  },
  {
    "path": "test/transform/normalize-transform.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUppercase, foobarUint8Array} from '../helpers/input.js';\nimport {casedSuffix} from '../helpers/generator.js';\nimport {generatorsMap} from '../helpers/map.js';\n\nsetFixtureDirectory();\n\nconst testAppendInput = async (t, reversed, type, execaMethod) => {\n\tconst stdin = [foobarUint8Array, generatorsMap[type].uppercase(), generatorsMap[type].append()];\n\tconst reversedStdin = reversed ? stdin.reverse() : stdin;\n\tconst {stdout} = await execaMethod('stdin-fd.js', ['0'], {stdin: reversedStdin});\n\tconst reversedSuffix = reversed ? casedSuffix.toUpperCase() : casedSuffix;\n\tt.is(stdout, `${foobarUppercase}${reversedSuffix}`);\n};\n\ntest('Can use multiple generators as input', testAppendInput, false, 'generator', execa);\ntest('Can use multiple generators as input, reversed', testAppendInput, true, 'generator', execa);\ntest('Can use multiple generators as input, sync', testAppendInput, false, 'generator', execaSync);\ntest('Can use multiple generators as input, reversed, sync', testAppendInput, true, 'generator', execaSync);\ntest('Can use multiple duplexes as input', testAppendInput, false, 'duplex', execa);\ntest('Can use multiple duplexes as input, reversed', testAppendInput, true, 'duplex', execa);\ntest('Can use multiple webTransforms as input', testAppendInput, false, 'webTransform', execa);\ntest('Can use multiple webTransforms as input, reversed', testAppendInput, true, 'webTransform', execa);\n\nconst testAppendOutput = async (t, reversed, type, execaMethod) => {\n\tconst stdoutOption = [generatorsMap[type].uppercase(), generatorsMap[type].append()];\n\tconst reversedStdoutOption = reversed ? stdoutOption.reverse() : stdoutOption;\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: reversedStdoutOption});\n\tconst reversedSuffix = reversed ? casedSuffix.toUpperCase() : casedSuffix;\n\tt.is(stdout, `${foobarUppercase}${reversedSuffix}`);\n};\n\ntest('Can use multiple generators as output', testAppendOutput, false, 'generator', execa);\ntest('Can use multiple generators as output, reversed', testAppendOutput, true, 'generator', execa);\ntest('Can use multiple generators as output, sync', testAppendOutput, false, 'generator', execaSync);\ntest('Can use multiple generators as output, reversed, sync', testAppendOutput, true, 'generator', execaSync);\ntest('Can use multiple duplexes as output', testAppendOutput, false, 'duplex', execa);\ntest('Can use multiple duplexes as output, reversed', testAppendOutput, true, 'duplex', execa);\ntest('Can use multiple webTransforms as output', testAppendOutput, false, 'webTransform', execa);\ntest('Can use multiple webTransforms as output, reversed', testAppendOutput, true, 'webTransform', execa);\n\nconst testGeneratorSyntax = async (t, type, usePlainObject, execaMethod) => {\n\tconst transform = generatorsMap[type].uppercase();\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {stdout: usePlainObject ? transform : transform.transform});\n\tt.is(stdout, foobarUppercase);\n};\n\ntest('Can pass generators with an options plain object', testGeneratorSyntax, 'generator', false, execa);\ntest('Can pass generators without an options plain object', testGeneratorSyntax, 'generator', true, execa);\ntest('Can pass generators with an options plain object, sync', testGeneratorSyntax, 'generator', false, execaSync);\ntest('Can pass generators without an options plain object, sync', testGeneratorSyntax, 'generator', true, execaSync);\ntest('Can pass webTransforms with an options plain object', testGeneratorSyntax, 'webTransform', true, execa);\ntest('Can pass webTransforms without an options plain object', testGeneratorSyntax, 'webTransform', false, execa);\n"
  },
  {
    "path": "test/transform/split-binary.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getOutputsGenerator, resultGenerator} from '../helpers/generator.js';\nimport {\n\tsimpleFull,\n\tsimpleChunks,\n\tsimpleFullUint8Array,\n\tsimpleFullUtf16Inverted,\n\tsimpleFullUtf16Uint8Array,\n\tsimpleChunksUint8Array,\n\tsimpleFullEnd,\n\tsimpleFullEndUtf16Inverted,\n\tsimpleFullHex,\n\tsimpleLines,\n\tnoNewlinesChunks,\n} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testBinaryOption = async (t, binary, input, expectedLines, expectedOutput, objectMode, preserveNewlines, encoding, execaMethod) => {\n\tconst lines = [];\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: [\n\t\t\tgetOutputsGenerator(input)(false, true),\n\t\t\tresultGenerator(lines)(objectMode, binary, preserveNewlines),\n\t\t],\n\t\tstripFinalNewline: false,\n\t\tencoding,\n\t});\n\tt.deepEqual(lines, expectedLines);\n\tt.deepEqual(stdout, expectedOutput);\n};\n\ntest('Does not split lines when \"binary\" is true', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true, 'utf8', execa);\ntest('Splits lines when \"binary\" is false', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execa);\ntest('Splits lines when \"binary\" is undefined', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execa);\ntest('Does not split lines when \"binary\" is true, encoding \"utf16le\"', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUtf16Inverted, false, true, 'utf16le', execa);\ntest('Splits lines when \"binary\" is false, encoding \"utf16le\"', testBinaryOption, false, [simpleFullUtf16Uint8Array], simpleLines, simpleFullUtf16Inverted, false, true, 'utf16le', execa);\ntest('Splits lines when \"binary\" is undefined, encoding \"utf16le\"', testBinaryOption, undefined, [simpleFullUtf16Uint8Array], simpleLines, simpleFullUtf16Inverted, false, true, 'utf16le', execa);\ntest('Does not split lines when \"binary\" is true, encoding \"buffer\"', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);\ntest('Does not split lines when \"binary\" is undefined, encoding \"buffer\"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);\ntest('Does not split lines when \"binary\" is false, encoding \"buffer\"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execa);\ntest('Does not split lines when \"binary\" is true, encoding \"hex\"', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);\ntest('Does not split lines when \"binary\" is undefined, encoding \"hex\"', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);\ntest('Does not split lines when \"binary\" is false, encoding \"hex\"', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execa);\ntest('Does not split lines when \"binary\" is true, objectMode', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true, 'utf8', execa);\ntest('Splits lines when \"binary\" is false, objectMode', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execa);\ntest('Splits lines when \"binary\" is undefined, objectMode', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execa);\ntest('Does not split lines when \"binary\" is true, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false, 'utf8', execa);\ntest('Splits lines when \"binary\" is false, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execa);\ntest('Splits lines when \"binary\" is undefined, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execa);\ntest('Does not split lines when \"binary\" is true, preserveNewlines, encoding \"utf16le\"', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUtf16Inverted, false, false, 'utf16le', execa);\ntest('Splits lines when \"binary\" is false, preserveNewlines, encoding \"utf16le\"', testBinaryOption, false, [simpleFullUtf16Uint8Array], noNewlinesChunks, simpleFullEndUtf16Inverted, false, false, 'utf16le', execa);\ntest('Splits lines when \"binary\" is undefined, preserveNewlines, encoding \"utf16le\"', testBinaryOption, undefined, [simpleFullUtf16Uint8Array], noNewlinesChunks, simpleFullEndUtf16Inverted, false, false, 'utf16le', execa);\ntest('Does not split lines when \"binary\" is true, encoding \"buffer\", preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);\ntest('Does not split lines when \"binary\" is undefined, encoding \"buffer\", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);\ntest('Does not split lines when \"binary\" is false, encoding \"buffer\", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execa);\ntest('Does not split lines when \"binary\" is true, objectMode, preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false, 'utf8', execa);\ntest('Does not split lines when \"binary\" is true, encoding \"hex\", preserveNewlines', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);\ntest('Does not split lines when \"binary\" is undefined, encoding \"hex\", preserveNewlines', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);\ntest('Does not split lines when \"binary\" is false, encoding \"hex\", preserveNewlines', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execa);\ntest('Splits lines when \"binary\" is false, objectMode, preserveNewlines', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execa);\ntest('Splits lines when \"binary\" is undefined, objectMode, preserveNewlines', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execa);\ntest('Does not split lines when \"binary\" is true, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, true, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is false, sync', testBinaryOption, false, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is undefined, sync', testBinaryOption, undefined, simpleChunks, simpleLines, simpleFull, false, true, 'utf8', execaSync);\ntest('Does not split lines when \"binary\" is true, encoding \"utf16le\", sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUtf16Inverted, false, true, 'utf16le', execaSync);\ntest('Splits lines when \"binary\" is false, encoding \"utf16le\", sync', testBinaryOption, false, [simpleFullUtf16Uint8Array], simpleLines, simpleFullUtf16Inverted, false, true, 'utf16le', execaSync);\ntest('Splits lines when \"binary\" is undefined, encoding \"utf16le\", sync', testBinaryOption, undefined, [simpleFullUtf16Uint8Array], simpleLines, simpleFullUtf16Inverted, false, true, 'utf16le', execaSync);\ntest('Does not split lines when \"binary\" is true, encoding \"buffer\", sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);\ntest('Does not split lines when \"binary\" is undefined, encoding \"buffer\", sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);\ntest('Does not split lines when \"binary\" is false, encoding \"buffer\", sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, true, 'buffer', execaSync);\ntest('Does not split lines when \"binary\" is true, encoding \"hex\", sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);\ntest('Does not split lines when \"binary\" is undefined, encoding \"hex\", sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);\ntest('Does not split lines when \"binary\" is false, encoding \"hex\", sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, true, 'hex', execaSync);\ntest('Does not split lines when \"binary\" is true, objectMode, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, true, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is false, objectMode, sync', testBinaryOption, false, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is undefined, objectMode, sync', testBinaryOption, undefined, simpleChunks, simpleLines, simpleLines, true, true, 'utf8', execaSync);\ntest('Does not split lines when \"binary\" is true, preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFull, false, false, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is false, preserveNewlines, sync', testBinaryOption, false, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is undefined, preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, 'utf8', execaSync);\ntest('Does not split lines when \"binary\" is true, preserveNewlines, encoding \"utf16le\", sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUtf16Inverted, false, false, 'utf16le', execaSync);\ntest('Splits lines when \"binary\" is false, preserveNewlines, encoding \"utf16le\", sync', testBinaryOption, false, [simpleFullUtf16Uint8Array], noNewlinesChunks, simpleFullEndUtf16Inverted, false, false, 'utf16le', execaSync);\ntest('Splits lines when \"binary\" is undefined, preserveNewlines, encoding \"utf16le\", sync', testBinaryOption, undefined, [simpleFullUtf16Uint8Array], noNewlinesChunks, simpleFullEndUtf16Inverted, false, false, 'utf16le', execaSync);\ntest('Does not split lines when \"binary\" is true, encoding \"buffer\", preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);\ntest('Does not split lines when \"binary\" is undefined, encoding \"buffer\", preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);\ntest('Does not split lines when \"binary\" is false, encoding \"buffer\", preserveNewlines, sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullUint8Array, false, false, 'buffer', execaSync);\ntest('Does not split lines when \"binary\" is true, objectMode, preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleChunksUint8Array, true, false, 'utf8', execaSync);\ntest('Does not split lines when \"binary\" is true, encoding \"hex\", preserveNewlines, sync', testBinaryOption, true, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);\ntest('Does not split lines when \"binary\" is undefined, encoding \"hex\", preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);\ntest('Does not split lines when \"binary\" is false, encoding \"hex\", preserveNewlines, sync', testBinaryOption, false, simpleChunks, simpleChunksUint8Array, simpleFullHex, false, false, 'hex', execaSync);\ntest('Splits lines when \"binary\" is false, objectMode, preserveNewlines, sync', testBinaryOption, false, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execaSync);\ntest('Splits lines when \"binary\" is undefined, objectMode, preserveNewlines, sync', testBinaryOption, undefined, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, 'utf8', execaSync);\n"
  },
  {
    "path": "test/transform/split-lines.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {getOutputsGenerator, resultGenerator} from '../helpers/generator.js';\nimport {\n\tsingleFull,\n\tsingleFullEnd,\n\tsimpleFull,\n\tsimpleChunks,\n\tsimpleFullEnd,\n\tsimpleFullEndChunks,\n\tsimpleLines,\n\tsimpleFullEndLines,\n\tnoNewlinesFull,\n\tnoNewlinesChunks,\n} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\nconst windowsFull = 'aaa\\r\\nbbb\\r\\nccc';\nconst windowsFullEnd = `${windowsFull}\\r\\n`;\nconst windowsChunks = [windowsFull];\nconst windowsLines = ['aaa\\r\\n', 'bbb\\r\\n', 'ccc'];\nconst noNewlinesFullEnd = `${noNewlinesFull}\\n`;\nconst noNewlinesLines = ['aaabbbccc'];\nconst singleChunks = [singleFull];\nconst noLines = [];\nconst emptyFull = '';\nconst emptyChunks = [emptyFull];\nconst manyEmptyChunks = [emptyFull, emptyFull, emptyFull];\nconst newlineFull = '\\n';\nconst newlineChunks = [newlineFull];\nconst newlinesFull = '\\n\\n\\n';\nconst newlinesChunks = [newlinesFull];\nconst newlinesLines = ['\\n', '\\n', '\\n'];\nconst windowsNewlinesFull = '\\r\\n\\r\\n\\r\\n';\nconst windowsNewlinesChunks = [windowsNewlinesFull];\nconst windowsNewlinesLines = ['\\r\\n', '\\r\\n', '\\r\\n'];\nconst runOverChunks = ['aaa\\nb', 'b', 'b\\nccc'];\nconst bigFull = '.'.repeat(1e5);\nconst bigFullEnd = `${bigFull}\\n`;\nconst bigChunks = [bigFull];\nconst manyChunks = Array.from({length: 1e3}).fill('.');\nconst manyFull = manyChunks.join('');\nconst manyFullEnd = `${manyFull}\\n`;\nconst manyLines = [manyFull];\n\n// eslint-disable-next-line max-params\nconst testLines = async (t, fdNumber, input, expectedLines, expectedOutput, objectMode, preserveNewlines, execaMethod) => {\n\tconst lines = [];\n\tconst {stdio} = await execaMethod('noop-fd.js', [`${fdNumber}`], {\n\t\t...getStdio(fdNumber, [\n\t\t\tgetOutputsGenerator(input)(false, true),\n\t\t\tresultGenerator(lines)(objectMode, false, preserveNewlines),\n\t\t]),\n\t\tstripFinalNewline: false,\n\t});\n\tt.deepEqual(lines, expectedLines);\n\tt.deepEqual(stdio[fdNumber], expectedOutput);\n};\n\ntest('Split stdout - n newlines, 1 chunk', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true, execa);\ntest('Split stderr - n newlines, 1 chunk', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true, execa);\ntest('Split stdio[*] - n newlines, 1 chunk', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true, execa);\ntest('Split stdout - preserveNewlines, n chunks', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true, execa);\ntest('Split stdout - 0 newlines, 1 chunk', testLines, 1, singleChunks, singleChunks, singleFull, false, true, execa);\ntest('Split stdout - empty, 1 chunk', testLines, 1, emptyChunks, noLines, emptyFull, false, true, execa);\ntest('Split stdout - Windows newlines', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true, execa);\ntest('Split stdout - chunk ends with newline', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true, execa);\ntest('Split stdout - single newline', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true, execa);\ntest('Split stdout - only newlines', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true, execa);\ntest('Split stdout - only Windows newlines', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true, execa);\ntest('Split stdout - line split over multiple chunks', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true, execa);\ntest('Split stdout - 0 newlines, big line', testLines, 1, bigChunks, bigChunks, bigFull, false, true, execa);\ntest('Split stdout - 0 newlines, many chunks', testLines, 1, manyChunks, manyLines, manyFull, false, true, execa);\ntest('Split stdout - n newlines, 1 chunk, objectMode', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true, execa);\ntest('Split stderr - n newlines, 1 chunk, objectMode', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true, execa);\ntest('Split stdio[*] - n newlines, 1 chunk, objectMode', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true, execa);\ntest('Split stdout - preserveNewlines, n chunks, objectMode', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true, execa);\ntest('Split stdout - empty, 1 chunk, objectMode', testLines, 1, emptyChunks, noLines, noLines, true, true, execa);\ntest('Split stdout - 0 newlines, 1 chunk, objectMode', testLines, 1, singleChunks, singleChunks, singleChunks, true, true, execa);\ntest('Split stdout - Windows newlines, objectMode', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true, execa);\ntest('Split stdout - chunk ends with newline, objectMode', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true, execa);\ntest('Split stdout - single newline, objectMode', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true, execa);\ntest('Split stdout - only newlines, objectMode', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true, execa);\ntest('Split stdout - only Windows newlines, objectMode', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true, execa);\ntest('Split stdout - line split over multiple chunks, objectMode', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true, execa);\ntest('Split stdout - 0 newlines, big line, objectMode', testLines, 1, bigChunks, bigChunks, bigChunks, true, true, execa);\ntest('Split stdout - 0 newlines, many chunks, objectMode', testLines, 1, manyChunks, manyLines, manyLines, true, true, execa);\ntest('Split stdout - n newlines, 1 chunk, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);\ntest('Split stderr - n newlines, 1 chunk, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);\ntest('Split stdio[*] - n newlines, 1 chunk, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);\ntest('Split stdout - preserveNewlines, n chunks, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false, execa);\ntest('Split stdout - empty, 1 chunk, preserveNewlines', testLines, 1, emptyChunks, noLines, emptyFull, false, false, execa);\ntest('Split stdout - 0 newlines, 1 chunk, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false, execa);\ntest('Split stdout - Windows newlines, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false, execa);\ntest('Split stdout - chunk ends with newline, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);\ntest('Split stdout - single newline, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false, execa);\ntest('Split stdout - only newlines, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false, execa);\ntest('Split stdout - only Windows newlines, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false, execa);\ntest('Split stdout - line split over multiple chunks, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false, execa);\ntest('Split stdout - 0 newlines, big line, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false, execa);\ntest('Split stdout - 0 newlines, many chunks, preserveNewlines', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false, execa);\ntest('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);\ntest('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);\ntest('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);\ntest('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false, execa);\ntest('Split stdout - empty, 1 chunk, objectMode, preserveNewlines', testLines, 1, emptyChunks, noLines, noLines, true, false, execa);\ntest('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines', testLines, 1, singleChunks, singleChunks, singleChunks, true, false, execa);\ntest('Split stdout - Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);\ntest('Split stdout - chunk ends with newline, objectMode, preserveNewlines', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);\ntest('Split stdout - single newline, objectMode, preserveNewlines', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false, execa);\ntest('Split stdout - only newlines, objectMode, preserveNewlines', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execa);\ntest('Split stdout - only Windows newlines, objectMode, preserveNewlines', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execa);\ntest('Split stdout - line split over multiple chunks, objectMode, preserveNewlines', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false, execa);\ntest('Split stdout - 0 newlines, big line, objectMode, preserveNewlines', testLines, 1, bigChunks, bigChunks, bigChunks, true, false, execa);\ntest('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines', testLines, 1, manyChunks, manyLines, manyLines, true, false, execa);\ntest('Split stdout - n newlines, 1 chunk, sync', testLines, 1, simpleChunks, simpleLines, simpleFull, false, true, execaSync);\ntest('Split stderr - n newlines, 1 chunk, sync', testLines, 2, simpleChunks, simpleLines, simpleFull, false, true, execaSync);\ntest('Split stdio[*] - n newlines, 1 chunk, sync', testLines, 3, simpleChunks, simpleLines, simpleFull, false, true, execaSync);\ntest('Split stdout - preserveNewlines, n chunks, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFull, false, true, execaSync);\ntest('Split stdout - 0 newlines, 1 chunk, sync', testLines, 1, singleChunks, singleChunks, singleFull, false, true, execaSync);\ntest('Split stdout - empty, 1 chunk, sync', testLines, 1, emptyChunks, noLines, emptyFull, false, true, execaSync);\ntest('Split stdout - Windows newlines, sync', testLines, 1, windowsChunks, windowsLines, windowsFull, false, true, execaSync);\ntest('Split stdout - chunk ends with newline, sync', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEnd, false, true, execaSync);\ntest('Split stdout - single newline, sync', testLines, 1, newlineChunks, newlineChunks, newlineFull, false, true, execaSync);\ntest('Split stdout - only newlines, sync', testLines, 1, newlinesChunks, newlinesLines, newlinesFull, false, true, execaSync);\ntest('Split stdout - only Windows newlines, sync', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesFull, false, true, execaSync);\ntest('Split stdout - line split over multiple chunks, sync', testLines, 1, runOverChunks, simpleLines, simpleFull, false, true, execaSync);\ntest('Split stdout - 0 newlines, big line, sync', testLines, 1, bigChunks, bigChunks, bigFull, false, true, execaSync);\ntest('Split stdout - 0 newlines, many chunks, sync', testLines, 1, manyChunks, manyLines, manyFull, false, true, execaSync);\ntest('Split stdout - n newlines, 1 chunk, objectMode, sync', testLines, 1, simpleChunks, simpleLines, simpleLines, true, true, execaSync);\ntest('Split stderr - n newlines, 1 chunk, objectMode, sync', testLines, 2, simpleChunks, simpleLines, simpleLines, true, true, execaSync);\ntest('Split stdio[*] - n newlines, 1 chunk, objectMode, sync', testLines, 3, simpleChunks, simpleLines, simpleLines, true, true, execaSync);\ntest('Split stdout - preserveNewlines, n chunks, objectMode, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, true, execaSync);\ntest('Split stdout - empty, 1 chunk, objectMode, sync', testLines, 1, emptyChunks, noLines, noLines, true, true, execaSync);\ntest('Split stdout - 0 newlines, 1 chunk, objectMode, sync', testLines, 1, singleChunks, singleChunks, singleChunks, true, true, execaSync);\ntest('Split stdout - Windows newlines, objectMode, sync', testLines, 1, windowsChunks, windowsLines, windowsLines, true, true, execaSync);\ntest('Split stdout - chunk ends with newline, objectMode, sync', testLines, 1, simpleFullEndChunks, simpleFullEndLines, simpleFullEndLines, true, true, execaSync);\ntest('Split stdout - single newline, objectMode, sync', testLines, 1, newlineChunks, newlineChunks, newlineChunks, true, true, execaSync);\ntest('Split stdout - only newlines, objectMode, sync', testLines, 1, newlinesChunks, newlinesLines, newlinesLines, true, true, execaSync);\ntest('Split stdout - only Windows newlines, objectMode, sync', testLines, 1, windowsNewlinesChunks, windowsNewlinesLines, windowsNewlinesLines, true, true, execaSync);\ntest('Split stdout - line split over multiple chunks, objectMode, sync', testLines, 1, runOverChunks, simpleLines, simpleLines, true, true, execaSync);\ntest('Split stdout - 0 newlines, big line, objectMode, sync', testLines, 1, bigChunks, bigChunks, bigChunks, true, true, execaSync);\ntest('Split stdout - 0 newlines, many chunks, objectMode, sync', testLines, 1, manyChunks, manyLines, manyLines, true, true, execaSync);\ntest('Split stdout - n newlines, 1 chunk, preserveNewlines, sync', testLines, 1, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);\ntest('Split stderr - n newlines, 1 chunk, preserveNewlines, sync', testLines, 2, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);\ntest('Split stdio[*] - n newlines, 1 chunk, preserveNewlines, sync', testLines, 3, simpleChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);\ntest('Split stdout - preserveNewlines, n chunks, preserveNewlines, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesFullEnd, false, false, execaSync);\ntest('Split stdout - empty, 1 chunk, preserveNewlines, sync', testLines, 1, emptyChunks, noLines, emptyFull, false, false, execaSync);\ntest('Split stdout - 0 newlines, 1 chunk, preserveNewlines, sync', testLines, 1, singleChunks, singleChunks, singleFullEnd, false, false, execaSync);\ntest('Split stdout - Windows newlines, preserveNewlines, sync', testLines, 1, windowsChunks, noNewlinesChunks, windowsFullEnd, false, false, execaSync);\ntest('Split stdout - chunk ends with newline, preserveNewlines, sync', testLines, 1, simpleFullEndChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);\ntest('Split stdout - single newline, preserveNewlines, sync', testLines, 1, newlineChunks, emptyChunks, newlineFull, false, false, execaSync);\ntest('Split stdout - only newlines, preserveNewlines, sync', testLines, 1, newlinesChunks, manyEmptyChunks, newlinesFull, false, false, execaSync);\ntest('Split stdout - only Windows newlines, preserveNewlines, sync', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, windowsNewlinesFull, false, false, execaSync);\ntest('Split stdout - line split over multiple chunks, preserveNewlines, sync', testLines, 1, runOverChunks, noNewlinesChunks, simpleFullEnd, false, false, execaSync);\ntest('Split stdout - 0 newlines, big line, preserveNewlines, sync', testLines, 1, bigChunks, bigChunks, bigFullEnd, false, false, execaSync);\ntest('Split stdout - 0 newlines, many chunks, preserveNewlines, sync', testLines, 1, manyChunks, manyLines, manyFullEnd, false, false, execaSync);\ntest('Split stdout - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);\ntest('Split stderr - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 2, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);\ntest('Split stdio[*] - n newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 3, simpleChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);\ntest('Split stdout - preserveNewlines, n chunks, objectMode, preserveNewlines, sync', testLines, 1, noNewlinesChunks, noNewlinesLines, noNewlinesLines, true, false, execaSync);\ntest('Split stdout - empty, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, emptyChunks, noLines, noLines, true, false, execaSync);\ntest('Split stdout - 0 newlines, 1 chunk, objectMode, preserveNewlines, sync', testLines, 1, singleChunks, singleChunks, singleChunks, true, false, execaSync);\ntest('Split stdout - Windows newlines, objectMode, preserveNewlines, sync', testLines, 1, windowsChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);\ntest('Split stdout - chunk ends with newline, objectMode, preserveNewlines, sync', testLines, 1, simpleFullEndChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);\ntest('Split stdout - single newline, objectMode, preserveNewlines, sync', testLines, 1, newlineChunks, emptyChunks, emptyChunks, true, false, execaSync);\ntest('Split stdout - only newlines, objectMode, preserveNewlines, sync', testLines, 1, newlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execaSync);\ntest('Split stdout - only Windows newlines, objectMode, preserveNewlines, sync', testLines, 1, windowsNewlinesChunks, manyEmptyChunks, manyEmptyChunks, true, false, execaSync);\ntest('Split stdout - line split over multiple chunks, objectMode, preserveNewlines, sync', testLines, 1, runOverChunks, noNewlinesChunks, noNewlinesChunks, true, false, execaSync);\ntest('Split stdout - 0 newlines, big line, objectMode, preserveNewlines, sync', testLines, 1, bigChunks, bigChunks, bigChunks, true, false, execaSync);\ntest('Split stdout - 0 newlines, many chunks, objectMode, preserveNewlines, sync', testLines, 1, manyChunks, manyLines, manyLines, true, false, execaSync);\n"
  },
  {
    "path": "test/transform/split-newline.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getOutputsGenerator, noopGenerator, noopAsyncGenerator} from '../helpers/generator.js';\nimport {singleFull, singleFullEnd} from '../helpers/lines.js';\n\nsetFixtureDirectory();\n\nconst singleFullEndWindows = `${singleFull}\\r\\n`;\nconst mixedNewlines = '.\\n.\\r\\n.\\n.\\r\\n.\\n';\n\nconst testStripNewline = async (t, input, expectedOutput, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: getOutputsGenerator([input])(),\n\t\tstripFinalNewline: false,\n\t});\n\tt.is(stdout, expectedOutput);\n};\n\ntest('Strips newline when user do not mistakenly yield one at the end', testStripNewline, singleFull, singleFullEnd, execa);\ntest('Strips newline when user mistakenly yielded one at the end', testStripNewline, singleFullEnd, singleFullEnd, execa);\ntest('Strips newline when user mistakenly yielded one at the end, Windows newline', testStripNewline, singleFullEndWindows, singleFullEndWindows, execa);\ntest('Strips newline when user do not mistakenly yield one at the end, sync', testStripNewline, singleFull, singleFullEnd, execaSync);\ntest('Strips newline when user mistakenly yielded one at the end, sync', testStripNewline, singleFullEnd, singleFullEnd, execaSync);\ntest('Strips newline when user mistakenly yielded one at the end, Windows newline, sync', testStripNewline, singleFullEndWindows, singleFullEndWindows, execaSync);\n\nconst testMixNewlines = async (t, generator, execaMethod) => {\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', mixedNewlines], {\n\t\tstdout: generator(),\n\t\tstripFinalNewline: false,\n\t});\n\tt.is(stdout, mixedNewlines);\n};\n\ntest('Can mix Unix and Windows newlines', testMixNewlines, noopGenerator, execa);\ntest('Can mix Unix and Windows newlines, sync', testMixNewlines, noopGenerator, execaSync);\ntest('Can mix Unix and Windows newlines, async', testMixNewlines, noopAsyncGenerator, execa);\n"
  },
  {
    "path": "test/transform/split-transform.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getOutputsGenerator, resultGenerator} from '../helpers/generator.js';\nimport {\n\tfoobarString,\n\tfoobarUint8Array,\n\tfoobarObject,\n\tfoobarObjectString,\n} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst resultUint8ArrayGenerator = function * (lines, chunk) {\n\tlines.push(chunk);\n\tyield new TextEncoder().encode(chunk);\n};\n\n// eslint-disable-next-line max-params\nconst testStringToUint8Array = async (t, expectedOutput, objectMode, preserveNewlines, execaMethod) => {\n\tconst lines = [];\n\tconst {stdout} = await execaMethod('noop-fd.js', ['1', foobarString], {\n\t\tstdout: {\n\t\t\ttransform: resultUint8ArrayGenerator.bind(undefined, lines),\n\t\t\tobjectMode,\n\t\t\tpreserveNewlines,\n\t\t},\n\t\tlines: true,\n\t});\n\tt.deepEqual(lines, [foobarString]);\n\tt.deepEqual(stdout, expectedOutput);\n};\n\ntest('Line splitting when converting from string to Uint8Array', testStringToUint8Array, [foobarString], false, true, execa);\ntest('Line splitting when converting from string to Uint8Array, objectMode', testStringToUint8Array, [foobarUint8Array], true, true, execa);\ntest('Line splitting when converting from string to Uint8Array, preserveNewlines', testStringToUint8Array, [foobarString], false, false, execa);\ntest('Line splitting when converting from string to Uint8Array, objectMode, preserveNewlines', testStringToUint8Array, [foobarUint8Array], true, false, execa);\ntest('Line splitting when converting from string to Uint8Array, sync', testStringToUint8Array, [foobarString], false, true, execaSync);\ntest('Line splitting when converting from string to Uint8Array, objectMode, sync', testStringToUint8Array, [foobarUint8Array], true, true, execaSync);\ntest('Line splitting when converting from string to Uint8Array, preserveNewlines, sync', testStringToUint8Array, [foobarString], false, false, execaSync);\ntest('Line splitting when converting from string to Uint8Array, objectMode, preserveNewlines, sync', testStringToUint8Array, [foobarUint8Array], true, false, execaSync);\n\nconst serializeResultGenerator = function * (lines, chunk) {\n\tlines.push(chunk);\n\tyield JSON.stringify(chunk);\n};\n\nconst testUnsetObjectMode = async (t, expectedOutput, preserveNewlines, execaMethod) => {\n\tconst lines = [];\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: [\n\t\t\tgetOutputsGenerator([foobarObject])(true),\n\t\t\t{transform: serializeResultGenerator.bind(undefined, lines), preserveNewlines, objectMode: false},\n\t\t],\n\t\tstripFinalNewline: false,\n\t});\n\tt.deepEqual(lines, [foobarObject]);\n\tt.is(stdout, expectedOutput);\n};\n\ntest('Can switch from objectMode to non-objectMode', testUnsetObjectMode, `${foobarObjectString}\\n`, false, execa);\ntest('Can switch from objectMode to non-objectMode, preserveNewlines', testUnsetObjectMode, foobarObjectString, true, execa);\ntest('Can switch from objectMode to non-objectMode, sync', testUnsetObjectMode, `${foobarObjectString}\\n`, false, execaSync);\ntest('Can switch from objectMode to non-objectMode, preserveNewlines, sync', testUnsetObjectMode, foobarObjectString, true, execaSync);\n\n// eslint-disable-next-line max-params\nconst testYieldArray = async (t, input, expectedLines, expectedOutput, execaMethod) => {\n\tconst lines = [];\n\tconst {stdout} = await execaMethod('noop.js', {\n\t\tstdout: [\n\t\t\tgetOutputsGenerator(input)(),\n\t\t\tresultGenerator(lines)(),\n\t\t],\n\t\tstripFinalNewline: false,\n\t});\n\tt.deepEqual(lines, expectedLines);\n\tt.deepEqual(stdout, expectedOutput);\n};\n\ntest('Can use \"yield* array\" to produce multiple lines', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\\n${foobarString}\\n`, execa);\ntest('Can use \"yield* array\" to produce empty lines', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\\n\\n`, execa);\ntest('Can use \"yield* array\" to produce multiple lines, sync', testYieldArray, [foobarString, foobarString], [foobarString, foobarString], `${foobarString}\\n${foobarString}\\n`, execaSync);\ntest('Can use \"yield* array\" to produce empty lines, sync', testYieldArray, [foobarString, ''], [foobarString, ''], `${foobarString}\\n\\n`, execaSync);\n"
  },
  {
    "path": "test/transform/validate.js",
    "content": "import test from 'ava';\nimport {execa, execaSync} from '../../index.js';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {getStdio} from '../helpers/stdio.js';\nimport {foobarUint8Array, foobarObject} from '../helpers/input.js';\nimport {serializeGenerator, getOutputGenerator, convertTransformToFinal} from '../helpers/generator.js';\n\nsetFixtureDirectory();\n\nconst getMessage = input => input === null || input === undefined\n\t? 'not be called at all'\n\t: 'a string or an Uint8Array';\n\nconst lastInputGenerator = input => objectMode => [foobarUint8Array, getOutputGenerator(input)(objectMode)];\nconst inputGenerator = input => objectMode => [...lastInputGenerator(input)(objectMode), serializeGenerator(true)];\n\n// eslint-disable-next-line max-params\nconst testGeneratorReturn = async (t, fdNumber, generator, input, objectMode, isInput) => {\n\tconst fixtureName = isInput ? 'stdin-fd.js' : 'noop-fd.js';\n\tconst {message} = await t.throwsAsync(execa(fixtureName, [`${fdNumber}`], getStdio(fdNumber, generator(input)(objectMode))));\n\tt.true(message.includes(getMessage(input)));\n};\n\ntest('Generators with result.stdin cannot return an object if not in objectMode', testGeneratorReturn, 0, inputGenerator, foobarObject, false, true);\ntest('Generators with result.stdio[*] as input cannot return an object if not in objectMode', testGeneratorReturn, 3, inputGenerator, foobarObject, false, true);\ntest('The last generator with result.stdin cannot return an object even in objectMode', testGeneratorReturn, 0, lastInputGenerator, foobarObject, true, true);\ntest('The last generator with result.stdio[*] as input cannot return an object even in objectMode', testGeneratorReturn, 3, lastInputGenerator, foobarObject, true, true);\ntest('Generators with result.stdout cannot return an object if not in objectMode', testGeneratorReturn, 1, getOutputGenerator, foobarObject, false, false);\ntest('Generators with result.stderr cannot return an object if not in objectMode', testGeneratorReturn, 2, getOutputGenerator, foobarObject, false, false);\ntest('Generators with result.stdio[*] as output cannot return an object if not in objectMode', testGeneratorReturn, 3, getOutputGenerator, foobarObject, false, false);\ntest('Generators with result.stdin cannot return null if not in objectMode', testGeneratorReturn, 0, inputGenerator, null, false, true);\ntest('Generators with result.stdin cannot return null if in objectMode', testGeneratorReturn, 0, inputGenerator, null, true, true);\ntest('Generators with result.stdout cannot return null if not in objectMode', testGeneratorReturn, 1, getOutputGenerator, null, false, false);\ntest('Generators with result.stdout cannot return null if in objectMode', testGeneratorReturn, 1, getOutputGenerator, null, true, false);\ntest('Generators with result.stdin cannot return undefined if not in objectMode', testGeneratorReturn, 0, inputGenerator, undefined, false, true);\ntest('Generators with result.stdin cannot return undefined if in objectMode', testGeneratorReturn, 0, inputGenerator, undefined, true, true);\ntest('Generators with result.stdout cannot return undefined if not in objectMode', testGeneratorReturn, 1, getOutputGenerator, undefined, false, false);\ntest('Generators with result.stdout cannot return undefined if in objectMode', testGeneratorReturn, 1, getOutputGenerator, undefined, true, false);\n\n// eslint-disable-next-line max-params\nconst testGeneratorReturnSync = (t, fdNumber, generator, input, objectMode, isInput) => {\n\tconst fixtureName = isInput ? 'stdin-fd.js' : 'noop-fd.js';\n\tconst {message} = t.throws(() => {\n\t\texecaSync(fixtureName, [`${fdNumber}`], getStdio(fdNumber, generator(input)(objectMode)));\n\t});\n\tt.true(message.includes(getMessage(input)));\n};\n\ntest('Generators with result.stdin cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, foobarObject, false, true);\ntest('The last generator with result.stdin cannot return an object even in objectMode, sync', testGeneratorReturnSync, 0, lastInputGenerator, foobarObject, true, true);\ntest('Generators with result.stdout cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, foobarObject, false, false);\ntest('Generators with result.stderr cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 2, getOutputGenerator, foobarObject, false, false);\ntest('Generators with result.stdio[*] as output cannot return an object if not in objectMode, sync', testGeneratorReturnSync, 3, getOutputGenerator, foobarObject, false, false);\ntest('Generators with result.stdin cannot return null if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, null, false, true);\ntest('Generators with result.stdin cannot return null if in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, null, true, true);\ntest('Generators with result.stdout cannot return null if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, null, false, false);\ntest('Generators with result.stdout cannot return null if in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, null, true, false);\ntest('Generators with result.stdin cannot return undefined if not in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, undefined, false, true);\ntest('Generators with result.stdin cannot return undefined if in objectMode, sync', testGeneratorReturnSync, 0, inputGenerator, undefined, true, true);\ntest('Generators with result.stdout cannot return undefined if not in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, undefined, false, false);\ntest('Generators with result.stdout cannot return undefined if in objectMode, sync', testGeneratorReturnSync, 1, getOutputGenerator, undefined, true, false);\n\ntest('Generators \"final\" return value is validated', async t => {\n\tawait t.throwsAsync(\n\t\texeca('noop.js', {stdout: convertTransformToFinal(getOutputGenerator(null)(true), true)}),\n\t\t{message: /not be called at all/},\n\t);\n});\n\ntest('Generators \"final\" return value is validated, sync', t => {\n\tt.throws(() => {\n\t\texecaSync('noop.js', {stdout: convertTransformToFinal(getOutputGenerator(null)(true), true)});\n\t}, {message: /not be called at all/});\n});\n"
  },
  {
    "path": "test/verbose/complete.js",
    "content": "import {stripVTControlCharacters} from 'node:util';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\trunErrorSubprocess,\n\trunWarningSubprocess,\n\trunEarlyErrorSubprocess,\n\tgetCompletionLine,\n\tgetCompletionLines,\n\ttestTimestamp,\n\tgetVerboseOption,\n\tstdoutNoneOption,\n\tstdoutShortOption,\n\tstdoutFullOption,\n\tstderrNoneOption,\n\tstderrShortOption,\n\tstderrFullOption,\n\tfd3NoneOption,\n\tfd3ShortOption,\n\tfd3FullOption,\n\tipcNoneOption,\n\tipcShortOption,\n\tipcFullOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintCompletion = async (t, verbose, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, isSync});\n\tt.is(getCompletionLine(stderr), `${testTimestamp} [0] √ (done in 0ms)`);\n};\n\ntest('Prints completion, verbose \"short\"', testPrintCompletion, 'short', false);\ntest('Prints completion, verbose \"full\"', testPrintCompletion, 'full', false);\ntest('Prints completion, verbose \"short\", fd-specific stdout', testPrintCompletion, stdoutShortOption, false);\ntest('Prints completion, verbose \"full\", fd-specific stdout', testPrintCompletion, stdoutFullOption, false);\ntest('Prints completion, verbose \"short\", fd-specific stderr', testPrintCompletion, stderrShortOption, false);\ntest('Prints completion, verbose \"full\", fd-specific stderr', testPrintCompletion, stderrFullOption, false);\ntest('Prints completion, verbose \"short\", fd-specific fd3', testPrintCompletion, fd3ShortOption, false);\ntest('Prints completion, verbose \"full\", fd-specific fd3', testPrintCompletion, fd3FullOption, false);\ntest('Prints completion, verbose \"short\", fd-specific ipc', testPrintCompletion, ipcShortOption, false);\ntest('Prints completion, verbose \"full\", fd-specific ipc', testPrintCompletion, ipcFullOption, false);\ntest('Prints completion, verbose \"short\", sync', testPrintCompletion, 'short', true);\ntest('Prints completion, verbose \"full\", sync', testPrintCompletion, 'full', true);\ntest('Prints completion, verbose \"short\", fd-specific stdout, sync', testPrintCompletion, stdoutShortOption, true);\ntest('Prints completion, verbose \"full\", fd-specific stdout, sync', testPrintCompletion, stdoutFullOption, true);\ntest('Prints completion, verbose \"short\", fd-specific stderr, sync', testPrintCompletion, stderrShortOption, true);\ntest('Prints completion, verbose \"full\", fd-specific stderr, sync', testPrintCompletion, stderrFullOption, true);\ntest('Prints completion, verbose \"short\", fd-specific fd3, sync', testPrintCompletion, fd3ShortOption, true);\ntest('Prints completion, verbose \"full\", fd-specific fd3, sync', testPrintCompletion, fd3FullOption, true);\ntest('Prints completion, verbose \"short\", fd-specific ipc, sync', testPrintCompletion, ipcShortOption, true);\ntest('Prints completion, verbose \"full\", fd-specific ipc, sync', testPrintCompletion, ipcFullOption, true);\n\nconst testNoPrintCompletion = async (t, verbose, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, isSync});\n\tt.is(stderr, '');\n};\n\ntest('Does not print completion, verbose \"none\"', testNoPrintCompletion, 'none', false);\ntest('Does not print completion, verbose default\"', testNoPrintCompletion, undefined, false);\ntest('Does not print completion, verbose \"none\", fd-specific stdout', testNoPrintCompletion, stdoutNoneOption, false);\ntest('Does not print completion, verbose \"none\", fd-specific stderr', testNoPrintCompletion, stderrNoneOption, false);\ntest('Does not print completion, verbose \"none\", fd-specific fd3', testNoPrintCompletion, fd3NoneOption, false);\ntest('Does not print completion, verbose \"none\", fd-specific ipc', testNoPrintCompletion, ipcNoneOption, false);\ntest('Does not print completion, verbose default\", fd-specific', testNoPrintCompletion, {}, false);\ntest('Does not print completion, verbose \"none\", sync', testNoPrintCompletion, 'none', true);\ntest('Does not print completion, verbose default\", sync', testNoPrintCompletion, undefined, true);\ntest('Does not print completion, verbose \"none\", fd-specific stdout, sync', testNoPrintCompletion, stdoutNoneOption, true);\ntest('Does not print completion, verbose \"none\", fd-specific stderr, sync', testNoPrintCompletion, stderrNoneOption, true);\ntest('Does not print completion, verbose \"none\", fd-specific fd3, sync', testNoPrintCompletion, fd3NoneOption, true);\ntest('Does not print completion, verbose \"none\", fd-specific ipc, sync', testNoPrintCompletion, ipcNoneOption, true);\ntest('Does not print completion, verbose default\", fd-specific, sync', testNoPrintCompletion, {}, true);\n\nconst testPrintCompletionError = async (t, isSync) => {\n\tconst stderr = await runErrorSubprocess(t, 'short', isSync);\n\tt.is(getCompletionLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);\n};\n\ntest('Prints completion after errors', testPrintCompletionError, false);\ntest('Prints completion after errors, sync', testPrintCompletionError, true);\n\nconst testPrintCompletionWarning = async (t, isSync) => {\n\tconst stderr = await runWarningSubprocess(t, isSync);\n\tt.is(getCompletionLine(stderr), `${testTimestamp} [0] ‼ (done in 0ms)`);\n};\n\ntest('Prints completion after errors, \"reject\" false', testPrintCompletionWarning, false);\ntest('Prints completion after errors, \"reject\" false, sync', testPrintCompletionWarning, true);\n\nconst testPrintCompletionEarly = async (t, isSync) => {\n\tconst stderr = await runEarlyErrorSubprocess(t, isSync);\n\tt.is(getCompletionLine(stderr), undefined);\n};\n\ntest('Prints completion after early validation errors', testPrintCompletionEarly, false);\ntest('Prints completion after early validation errors, sync', testPrintCompletionEarly, true);\n\ntest.serial('Prints duration', async t => {\n\tconst {stderr} = await nestedSubprocess('delay.js', ['1000'], {verbose: 'short'});\n\tt.regex(stripVTControlCharacters(stderr).split('\\n').at(-1), /\\(done in [\\d.]+s\\)/);\n});\n\nconst testPipeDuration = async (t, parentFixture, sourceVerbose, destinationVerbose) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\tparentFixture,\n\t\tsourceOptions: getVerboseOption(sourceVerbose),\n\t\tdestinationFile: 'stdin.js',\n\t\tdestinationOptions: getVerboseOption(destinationVerbose),\n\t});\n\n\tconst lines = getCompletionLines(stderr);\n\tt.is(lines.includes(`${testTimestamp} [0] √ (done in 0ms)`), sourceVerbose || destinationVerbose);\n\tt.is(lines.includes(`${testTimestamp} [1] √ (done in 0ms)`), sourceVerbose && destinationVerbose);\n};\n\ntest('Prints both durations piped with .pipe(\"file\")', testPipeDuration, 'nested-pipe-file.js', true, true);\ntest('Prints both durations piped with .pipe`command`', testPipeDuration, 'nested-pipe-script.js', true, true);\ntest('Prints both durations piped with .pipe(subprocess)', testPipeDuration, 'nested-pipe-subprocesses.js', true, true);\ntest('Prints first duration piped with .pipe(\"file\")', testPipeDuration, 'nested-pipe-file.js', true, false);\ntest('Prints first duration piped with .pipe`command`', testPipeDuration, 'nested-pipe-script.js', true, false);\ntest('Prints first duration piped with .pipe(subprocess)', testPipeDuration, 'nested-pipe-subprocesses.js', true, false);\ntest('Prints second duration piped with .pipe(\"file\")', testPipeDuration, 'nested-pipe-file.js', false, true);\ntest('Prints second duration piped with .pipe`command`', testPipeDuration, 'nested-pipe-script.js', false, true);\ntest('Prints second duration piped with .pipe(subprocess)', testPipeDuration, 'nested-pipe-subprocesses.js', false, true);\ntest('Prints neither durations piped with .pipe(\"file\")', testPipeDuration, 'nested-pipe-file.js', false, false);\ntest('Prints neither durations piped with .pipe`command`', testPipeDuration, 'nested-pipe-script.js', false, false);\ntest('Prints neither durations piped with .pipe(subprocess)', testPipeDuration, 'nested-pipe-subprocesses.js', false, false);\n"
  },
  {
    "path": "test/verbose/custom-command.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {\n\tQUOTE,\n\tgetNormalizedLine,\n\ttestTimestamp,\n\trunVerboseSubprocess,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintCommandCustom = async (t, fdNumber, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\tisSync,\n\t\ttype: 'command',\n\t\tfdNumber,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('Prints command, verbose custom', testPrintCommandCustom, undefined, false);\ntest('Prints command, verbose custom, fd-specific stdout', testPrintCommandCustom, 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stderr', testPrintCommandCustom, 'stderr', false);\ntest('Prints command, verbose custom, fd-specific fd3', testPrintCommandCustom, 'fd3', false);\ntest('Prints command, verbose custom, fd-specific ipc', testPrintCommandCustom, 'ipc', false);\ntest('Prints command, verbose custom, sync', testPrintCommandCustom, undefined, true);\ntest('Prints command, verbose custom, fd-specific stdout, sync', testPrintCommandCustom, 'stdout', true);\ntest('Prints command, verbose custom, fd-specific stderr, sync', testPrintCommandCustom, 'stderr', true);\ntest('Prints command, verbose custom, fd-specific fd3, sync', testPrintCommandCustom, 'fd3', true);\ntest('Prints command, verbose custom, fd-specific ipc, sync', testPrintCommandCustom, 'ipc', true);\n\nconst testPrintCommandOrder = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-multiple.js',\n\t\ttype: 'command',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints command, verbose custom, fd-specific stdout+stderr', testPrintCommandOrder, 'stdout', 'stderr', true);\ntest('Prints command, verbose custom, fd-specific stderr+stdout', testPrintCommandOrder, 'stderr', 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stdout+fd3', testPrintCommandOrder, 'stdout', 'fd3', true);\ntest('Prints command, verbose custom, fd-specific fd3+stdout', testPrintCommandOrder, 'fd3', 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stdout+ipc', testPrintCommandOrder, 'stdout', 'ipc', true);\ntest('Prints command, verbose custom, fd-specific ipc+stdout', testPrintCommandOrder, 'ipc', 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stderr+fd3', testPrintCommandOrder, 'stderr', 'fd3', true);\ntest('Prints command, verbose custom, fd-specific fd3+stderr', testPrintCommandOrder, 'fd3', 'stderr', false);\ntest('Prints command, verbose custom, fd-specific stderr+ipc', testPrintCommandOrder, 'stderr', 'ipc', true);\ntest('Prints command, verbose custom, fd-specific ipc+stderr', testPrintCommandOrder, 'ipc', 'stderr', false);\ntest('Prints command, verbose custom, fd-specific fd3+ipc', testPrintCommandOrder, 'fd3', 'ipc', true);\ntest('Prints command, verbose custom, fd-specific ipc+fd3', testPrintCommandOrder, 'ipc', 'fd3', false);\n\nconst testPrintCommandFunction = async (t, fdNumber, secondFdNumber) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-function.js',\n\t\ttype: 'command',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('Prints command, verbose custom, fd-specific stdout+stderr, single function', testPrintCommandFunction, 'stdout', 'stderr');\ntest('Prints command, verbose custom, fd-specific stderr+stdout, single function', testPrintCommandFunction, 'stderr', 'stdout');\ntest('Prints command, verbose custom, fd-specific stdout+fd3, single function', testPrintCommandFunction, 'stdout', 'fd3');\ntest('Prints command, verbose custom, fd-specific fd3+stdout, single function', testPrintCommandFunction, 'fd3', 'stdout');\ntest('Prints command, verbose custom, fd-specific stdout+ipc, single function', testPrintCommandFunction, 'stdout', 'ipc');\ntest('Prints command, verbose custom, fd-specific ipc+stdout, single function', testPrintCommandFunction, 'ipc', 'stdout');\ntest('Prints command, verbose custom, fd-specific stderr+fd3, single function', testPrintCommandFunction, 'stderr', 'fd3');\ntest('Prints command, verbose custom, fd-specific fd3+stderr, single function', testPrintCommandFunction, 'fd3', 'stderr');\ntest('Prints command, verbose custom, fd-specific stderr+ipc, single function', testPrintCommandFunction, 'stderr', 'ipc');\ntest('Prints command, verbose custom, fd-specific ipc+stderr, single function', testPrintCommandFunction, 'ipc', 'stderr');\ntest('Prints command, verbose custom, fd-specific fd3+ipc, single function', testPrintCommandFunction, 'fd3', 'ipc');\ntest('Prints command, verbose custom, fd-specific ipc+fd3, single function', testPrintCommandFunction, 'ipc', 'fd3');\n\nconst testVerboseMessage = async (t, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype: 'command',\n\t\teventProperty: 'message',\n\t});\n\tt.is(getNormalizedLine(stderr), `noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('\"verbose\" function receives verboseObject.message', testVerboseMessage, false);\ntest('\"verbose\" function receives verboseObject.message, sync', testVerboseMessage, true);\n"
  },
  {
    "path": "test/verbose/custom-common.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {QUOTE, getCommandLine, testTimestamp} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testCustomReturn = async (t, verboseOutput, expectedOutput) => {\n\tconst {stderr} = await nestedSubprocess(\n\t\t'empty.js',\n\t\t{optionsFixture: 'custom-return.js', optionsInput: {verboseOutput}},\n\t\t{stripFinalNewline: false},\n\t);\n\tt.is(stderr, expectedOutput);\n};\n\ntest('\"verbose\" returning a string prints it', testCustomReturn, `${foobarString}\\n`, `${foobarString}\\n`);\ntest('\"verbose\" returning a string without a newline adds it', testCustomReturn, foobarString, `${foobarString}\\n`);\ntest('\"verbose\" returning a string with multiple newlines keeps them', testCustomReturn, `${foobarString}\\n\\n`, `${foobarString}\\n\\n`);\ntest('\"verbose\" returning an empty string prints an empty line', testCustomReturn, '', '\\n');\ntest('\"verbose\" returning undefined ignores it', testCustomReturn, undefined, '');\ntest('\"verbose\" returning a number ignores it', testCustomReturn, 0, '');\ntest('\"verbose\" returning a bigint ignores it', testCustomReturn, 0n, '');\ntest('\"verbose\" returning a boolean ignores it', testCustomReturn, true, '');\ntest('\"verbose\" returning an object ignores it', testCustomReturn, {}, '');\ntest('\"verbose\" returning an array ignores it', testCustomReturn, [], '');\n\ntest('\"verbose\" receives verboseLine string as first argument', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {optionsFixture: 'custom-uppercase.js'});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ NOOP.js ${foobarString}`);\n});\n\ntest('\"verbose\" can print as JSON', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['. .'], {optionsFixture: 'custom-json.js', type: 'duration', reject: false});\n\tconst {type, message, escapedCommand, commandId, timestamp, piped, result, options} = JSON.parse(stderr);\n\tt.is(type, 'duration');\n\tt.true(message.includes('done in'));\n\tt.is(escapedCommand, `noop.js ${QUOTE}. .${QUOTE}`);\n\tt.is(commandId, '0');\n\tt.true(Number.isInteger(new Date(timestamp).getTime()));\n\tt.false(piped);\n\tt.false(result.failed);\n\tt.is(result.exitCode, 0);\n\tt.is(result.stdout, '. .');\n\tt.is(result.stderr, '');\n\tt.false(options.reject);\n});\n"
  },
  {
    "path": "test/verbose/custom-complete.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {getNormalizedLine, testTimestamp, runVerboseSubprocess} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintCompletionCustom = async (t, fdNumber, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\tisSync,\n\t\ttype: 'duration',\n\t\tfdNumber,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);\n};\n\ntest('Prints completion, verbose custom', testPrintCompletionCustom, undefined, false);\ntest('Prints completion, verbose custom, fd-specific stdout', testPrintCompletionCustom, 'stdout', false);\ntest('Prints completion, verbose custom, fd-specific stderr', testPrintCompletionCustom, 'stderr', false);\ntest('Prints completion, verbose custom, fd-specific fd3', testPrintCompletionCustom, 'fd3', false);\ntest('Prints completion, verbose custom, fd-specific ipc', testPrintCompletionCustom, 'ipc', false);\ntest('Prints completion, verbose custom, sync', testPrintCompletionCustom, undefined, true);\ntest('Prints completion, verbose custom, fd-specific stdout, sync', testPrintCompletionCustom, 'stdout', true);\ntest('Prints completion, verbose custom, fd-specific stderr, sync', testPrintCompletionCustom, 'stderr', true);\ntest('Prints completion, verbose custom, fd-specific fd3, sync', testPrintCompletionCustom, 'fd3', true);\ntest('Prints completion, verbose custom, fd-specific ipc, sync', testPrintCompletionCustom, 'ipc', true);\n\nconst testPrintCompletionOrder = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-multiple.js',\n\t\ttype: 'duration',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints completion, verbose custom, fd-specific stdout+stderr', testPrintCompletionOrder, 'stdout', 'stderr', true);\ntest('Prints completion, verbose custom, fd-specific stderr+stdout', testPrintCompletionOrder, 'stderr', 'stdout', false);\ntest('Prints completion, verbose custom, fd-specific stdout+fd3', testPrintCompletionOrder, 'stdout', 'fd3', true);\ntest('Prints completion, verbose custom, fd-specific fd3+stdout', testPrintCompletionOrder, 'fd3', 'stdout', false);\ntest('Prints completion, verbose custom, fd-specific stdout+ipc', testPrintCompletionOrder, 'stdout', 'ipc', true);\ntest('Prints completion, verbose custom, fd-specific ipc+stdout', testPrintCompletionOrder, 'ipc', 'stdout', false);\ntest('Prints completion, verbose custom, fd-specific stderr+fd3', testPrintCompletionOrder, 'stderr', 'fd3', true);\ntest('Prints completion, verbose custom, fd-specific fd3+stderr', testPrintCompletionOrder, 'fd3', 'stderr', false);\ntest('Prints completion, verbose custom, fd-specific stderr+ipc', testPrintCompletionOrder, 'stderr', 'ipc', true);\ntest('Prints completion, verbose custom, fd-specific ipc+stderr', testPrintCompletionOrder, 'ipc', 'stderr', false);\ntest('Prints completion, verbose custom, fd-specific fd3+ipc', testPrintCompletionOrder, 'fd3', 'ipc', true);\ntest('Prints completion, verbose custom, fd-specific ipc+fd3', testPrintCompletionOrder, 'ipc', 'fd3', false);\n\nconst testPrintCompletionFunction = async (t, fdNumber, secondFdNumber) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-function.js',\n\t\ttype: 'duration',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] × (done in 0ms)`);\n};\n\ntest('Prints completion, verbose custom, fd-specific stdout+stderr, single function', testPrintCompletionFunction, 'stdout', 'stderr');\ntest('Prints completion, verbose custom, fd-specific stderr+stdout, single function', testPrintCompletionFunction, 'stderr', 'stdout');\ntest('Prints completion, verbose custom, fd-specific stdout+fd3, single function', testPrintCompletionFunction, 'stdout', 'fd3');\ntest('Prints completion, verbose custom, fd-specific fd3+stdout, single function', testPrintCompletionFunction, 'fd3', 'stdout');\ntest('Prints completion, verbose custom, fd-specific stdout+ipc, single function', testPrintCompletionFunction, 'stdout', 'ipc');\ntest('Prints completion, verbose custom, fd-specific ipc+stdout, single function', testPrintCompletionFunction, 'ipc', 'stdout');\ntest('Prints completion, verbose custom, fd-specific stderr+fd3, single function', testPrintCompletionFunction, 'stderr', 'fd3');\ntest('Prints completion, verbose custom, fd-specific fd3+stderr, single function', testPrintCompletionFunction, 'fd3', 'stderr');\ntest('Prints completion, verbose custom, fd-specific stderr+ipc, single function', testPrintCompletionFunction, 'stderr', 'ipc');\ntest('Prints completion, verbose custom, fd-specific ipc+stderr, single function', testPrintCompletionFunction, 'ipc', 'stderr');\ntest('Prints completion, verbose custom, fd-specific fd3+ipc, single function', testPrintCompletionFunction, 'fd3', 'ipc');\ntest('Prints completion, verbose custom, fd-specific ipc+fd3, single function', testPrintCompletionFunction, 'ipc', 'fd3');\n\nconst testVerboseMessage = async (t, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype: 'duration',\n\t\teventProperty: 'message',\n\t});\n\tt.is(getNormalizedLine(stderr), '(done in 0ms)');\n};\n\ntest('\"verbose\" function receives verboseObject.message', testVerboseMessage, false);\ntest('\"verbose\" function receives verboseObject.message, sync', testVerboseMessage, true);\n"
  },
  {
    "path": "test/verbose/custom-error.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {\n\tQUOTE,\n\tgetNormalizedLine,\n\ttestTimestamp,\n\trunVerboseSubprocess,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintErrorCustom = async (t, fdNumber, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\tisSync,\n\t\ttype: 'error',\n\t\tfdNumber,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] × Command failed with exit code 2: noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('Prints error, verbose custom', testPrintErrorCustom, undefined, false);\ntest('Prints error, verbose custom, fd-specific stdout', testPrintErrorCustom, 'stdout', false);\ntest('Prints error, verbose custom, fd-specific stderr', testPrintErrorCustom, 'stderr', false);\ntest('Prints error, verbose custom, fd-specific fd3', testPrintErrorCustom, 'fd3', false);\ntest('Prints error, verbose custom, fd-specific ipc', testPrintErrorCustom, 'ipc', false);\ntest('Prints error, verbose custom, sync', testPrintErrorCustom, undefined, true);\ntest('Prints error, verbose custom, fd-specific stdout, sync', testPrintErrorCustom, 'stdout', true);\ntest('Prints error, verbose custom, fd-specific stderr, sync', testPrintErrorCustom, 'stderr', true);\ntest('Prints error, verbose custom, fd-specific fd3, sync', testPrintErrorCustom, 'fd3', true);\ntest('Prints error, verbose custom, fd-specific ipc, sync', testPrintErrorCustom, 'ipc', true);\n\nconst testPrintErrorOrder = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-multiple.js',\n\t\ttype: 'error',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] × Command failed with exit code 2: noop-verbose.js ${QUOTE}. .${QUOTE}`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints error, verbose custom, fd-specific stdout+stderr', testPrintErrorOrder, 'stdout', 'stderr', true);\ntest('Prints error, verbose custom, fd-specific stderr+stdout', testPrintErrorOrder, 'stderr', 'stdout', false);\ntest('Prints error, verbose custom, fd-specific stdout+fd3', testPrintErrorOrder, 'stdout', 'fd3', true);\ntest('Prints error, verbose custom, fd-specific fd3+stdout', testPrintErrorOrder, 'fd3', 'stdout', false);\ntest('Prints error, verbose custom, fd-specific stdout+ipc', testPrintErrorOrder, 'stdout', 'ipc', true);\ntest('Prints error, verbose custom, fd-specific ipc+stdout', testPrintErrorOrder, 'ipc', 'stdout', false);\ntest('Prints error, verbose custom, fd-specific stderr+fd3', testPrintErrorOrder, 'stderr', 'fd3', true);\ntest('Prints error, verbose custom, fd-specific fd3+stderr', testPrintErrorOrder, 'fd3', 'stderr', false);\ntest('Prints error, verbose custom, fd-specific stderr+ipc', testPrintErrorOrder, 'stderr', 'ipc', true);\ntest('Prints error, verbose custom, fd-specific ipc+stderr', testPrintErrorOrder, 'ipc', 'stderr', false);\ntest('Prints error, verbose custom, fd-specific fd3+ipc', testPrintErrorOrder, 'fd3', 'ipc', true);\ntest('Prints error, verbose custom, fd-specific ipc+fd3', testPrintErrorOrder, 'ipc', 'fd3', false);\n\nconst testPrintErrorFunction = async (t, fdNumber, secondFdNumber) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-function.js',\n\t\ttype: 'error',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] × Command failed with exit code 2: noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('Prints error, verbose custom, fd-specific stdout+stderr, single function', testPrintErrorFunction, 'stdout', 'stderr');\ntest('Prints error, verbose custom, fd-specific stderr+stdout, single function', testPrintErrorFunction, 'stderr', 'stdout');\ntest('Prints error, verbose custom, fd-specific stdout+fd3, single function', testPrintErrorFunction, 'stdout', 'fd3');\ntest('Prints error, verbose custom, fd-specific fd3+stdout, single function', testPrintErrorFunction, 'fd3', 'stdout');\ntest('Prints error, verbose custom, fd-specific stdout+ipc, single function', testPrintErrorFunction, 'stdout', 'ipc');\ntest('Prints error, verbose custom, fd-specific ipc+stdout, single function', testPrintErrorFunction, 'ipc', 'stdout');\ntest('Prints error, verbose custom, fd-specific stderr+fd3, single function', testPrintErrorFunction, 'stderr', 'fd3');\ntest('Prints error, verbose custom, fd-specific fd3+stderr, single function', testPrintErrorFunction, 'fd3', 'stderr');\ntest('Prints error, verbose custom, fd-specific stderr+ipc, single function', testPrintErrorFunction, 'stderr', 'ipc');\ntest('Prints error, verbose custom, fd-specific ipc+stderr, single function', testPrintErrorFunction, 'ipc', 'stderr');\ntest('Prints error, verbose custom, fd-specific fd3+ipc, single function', testPrintErrorFunction, 'fd3', 'ipc');\ntest('Prints error, verbose custom, fd-specific ipc+fd3, single function', testPrintErrorFunction, 'ipc', 'fd3');\n\nconst testVerboseMessage = async (t, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype: 'error',\n\t\teventProperty: 'message',\n\t});\n\tt.is(stderr, `Command failed with exit code 2: noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('\"verbose\" function receives verboseObject.message', testVerboseMessage, false);\ntest('\"verbose\" function receives verboseObject.message, sync', testVerboseMessage, true);\n"
  },
  {
    "path": "test/verbose/custom-event.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {runVerboseSubprocess} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testVerboseType = async (t, type, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'type'});\n\tt.is(stderr, type);\n};\n\ntest('\"verbose\" function receives verboseObject.type \"command\"', testVerboseType, 'command', false);\ntest('\"verbose\" function receives verboseObject.type \"output\"', testVerboseType, 'output', false);\ntest('\"verbose\" function receives verboseObject.type \"ipc\"', testVerboseType, 'ipc', false);\ntest('\"verbose\" function receives verboseObject.type \"error\"', testVerboseType, 'error', false);\ntest('\"verbose\" function receives verboseObject.type \"duration\"', testVerboseType, 'duration', false);\ntest('\"verbose\" function receives verboseObject.type \"command\", sync', testVerboseType, 'command', true);\ntest('\"verbose\" function receives verboseObject.type \"output\", sync', testVerboseType, 'output', true);\ntest('\"verbose\" function receives verboseObject.type \"error\", sync', testVerboseType, 'error', true);\ntest('\"verbose\" function receives verboseObject.type \"duration\", sync', testVerboseType, 'duration', true);\n\nconst testVerboseTimestamp = async (t, type, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'timestamp'});\n\tt.true(Number.isInteger(new Date(stderr).getTime()));\n};\n\ntest('\"verbose\" function receives verboseObject.timestamp, \"command\"', testVerboseTimestamp, 'command', false);\ntest('\"verbose\" function receives verboseObject.timestamp, \"output\"', testVerboseTimestamp, 'output', false);\ntest('\"verbose\" function receives verboseObject.timestamp, \"ipc\"', testVerboseTimestamp, 'ipc', false);\ntest('\"verbose\" function receives verboseObject.timestamp, \"error\"', testVerboseTimestamp, 'error', false);\ntest('\"verbose\" function receives verboseObject.timestamp, \"duration\"', testVerboseTimestamp, 'duration', false);\ntest('\"verbose\" function receives verboseObject.timestamp, \"command\", sync', testVerboseTimestamp, 'command', true);\ntest('\"verbose\" function receives verboseObject.timestamp, \"output\", sync', testVerboseTimestamp, 'output', true);\ntest('\"verbose\" function receives verboseObject.timestamp, \"error\", sync', testVerboseTimestamp, 'error', true);\ntest('\"verbose\" function receives verboseObject.timestamp, \"duration\", sync', testVerboseTimestamp, 'duration', true);\n\nconst testVerbosePiped = async (t, type, isSync, expectedOutputs) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\tparentFixture: 'nested-pipe-verbose.js',\n\t\tdestinationFile: 'noop-verbose.js',\n\t\tdestinationArguments: ['. . .'],\n\t\teventProperty: 'piped',\n\t});\n\tt.true(expectedOutputs.map(expectedOutput => expectedOutput.join('\\n')).includes(stderr));\n};\n\ntest('\"verbose\" function receives verboseObject.piped, \"command\"', testVerbosePiped, 'command', false, [[false, true]]);\ntest('\"verbose\" function receives verboseObject.piped, \"output\"', testVerbosePiped, 'output', false, [[true]]);\ntest('\"verbose\" function receives verboseObject.piped, \"ipc\"', testVerbosePiped, 'ipc', false, [[false, true], [true, false]]);\ntest('\"verbose\" function receives verboseObject.piped, \"error\"', testVerbosePiped, 'error', false, [[false, true], [true, false]]);\ntest('\"verbose\" function receives verboseObject.piped, \"duration\"', testVerbosePiped, 'duration', false, [[false, true], [true, false]]);\ntest('\"verbose\" function receives verboseObject.piped, \"command\", sync', testVerbosePiped, 'command', true, [[false, true]]);\ntest('\"verbose\" function receives verboseObject.piped, \"output\", sync', testVerbosePiped, 'output', true, [[true]]);\ntest('\"verbose\" function receives verboseObject.piped, \"error\", sync', testVerbosePiped, 'error', true, [[false, true], [true, false]]);\ntest('\"verbose\" function receives verboseObject.piped, \"duration\", sync', testVerbosePiped, 'duration', true, [[false, true], [true, false]]);\n"
  },
  {
    "path": "test/verbose/custom-id.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {QUOTE, runVerboseSubprocess} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testVerboseCommandId = async (t, type, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'commandId'});\n\tt.is(stderr, '0');\n};\n\ntest('\"verbose\" function receives verboseObject.commandId, \"command\"', testVerboseCommandId, 'command', false);\ntest('\"verbose\" function receives verboseObject.commandId, \"output\"', testVerboseCommandId, 'output', false);\ntest('\"verbose\" function receives verboseObject.commandId, \"ipc\"', testVerboseCommandId, 'ipc', false);\ntest('\"verbose\" function receives verboseObject.commandId, \"error\"', testVerboseCommandId, 'error', false);\ntest('\"verbose\" function receives verboseObject.commandId, \"duration\"', testVerboseCommandId, 'duration', false);\ntest('\"verbose\" function receives verboseObject.commandId, \"command\", sync', testVerboseCommandId, 'command', true);\ntest('\"verbose\" function receives verboseObject.commandId, \"output\", sync', testVerboseCommandId, 'output', true);\ntest('\"verbose\" function receives verboseObject.commandId, \"error\", sync', testVerboseCommandId, 'error', true);\ntest('\"verbose\" function receives verboseObject.commandId, \"duration\", sync', testVerboseCommandId, 'duration', true);\n\nconst testVerboseEscapedCommand = async (t, type, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'escapedCommand'});\n\tt.is(stderr, `noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"command\"', testVerboseEscapedCommand, 'command', false);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"output\"', testVerboseEscapedCommand, 'output', false);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"ipc\"', testVerboseEscapedCommand, 'ipc', false);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"error\"', testVerboseEscapedCommand, 'error', false);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"duration\"', testVerboseEscapedCommand, 'duration', false);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"command\", sync', testVerboseEscapedCommand, 'command', true);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"output\", sync', testVerboseEscapedCommand, 'output', true);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"error\", sync', testVerboseEscapedCommand, 'error', true);\ntest('\"verbose\" function receives verboseObject.escapedCommand, \"duration\", sync', testVerboseEscapedCommand, 'duration', true);\n"
  },
  {
    "path": "test/verbose/custom-ipc.js",
    "content": "import {inspect} from 'node:util';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {\n\tgetNormalizedLine,\n\tgetNormalizedLines,\n\ttestTimestamp,\n\trunVerboseSubprocess,\n} from '../helpers/verbose.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {foobarObject} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testPrintIpcCustom = async (t, fdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\ttype: 'ipc',\n\t\tfdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] * . .`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints IPC, verbose custom', testPrintIpcCustom, undefined, true);\ntest('Prints IPC, verbose custom, fd-specific stdout', testPrintIpcCustom, 'stdout', false);\ntest('Prints IPC, verbose custom, fd-specific stderr', testPrintIpcCustom, 'stderr', false);\ntest('Prints IPC, verbose custom, fd-specific fd3', testPrintIpcCustom, 'fd3', false);\ntest('Prints IPC, verbose custom, fd-specific ipc', testPrintIpcCustom, 'ipc', true);\n\nconst testPrintIpcOrder = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-multiple.js',\n\t\ttype: 'ipc',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] * . .`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints IPC, verbose custom, fd-specific stdout+stderr', testPrintIpcOrder, 'stdout', 'stderr', false);\ntest('Prints IPC, verbose custom, fd-specific stderr+stdout', testPrintIpcOrder, 'stderr', 'stdout', false);\ntest('Prints IPC, verbose custom, fd-specific stdout+fd3', testPrintIpcOrder, 'stdout', 'fd3', false);\ntest('Prints IPC, verbose custom, fd-specific fd3+stdout', testPrintIpcOrder, 'fd3', 'stdout', false);\ntest('Prints IPC, verbose custom, fd-specific stdout+ipc', testPrintIpcOrder, 'stdout', 'ipc', false);\ntest('Prints IPC, verbose custom, fd-specific ipc+stdout', testPrintIpcOrder, 'ipc', 'stdout', true);\ntest('Prints IPC, verbose custom, fd-specific stderr+fd3', testPrintIpcOrder, 'stderr', 'fd3', false);\ntest('Prints IPC, verbose custom, fd-specific fd3+stderr', testPrintIpcOrder, 'fd3', 'stderr', false);\ntest('Prints IPC, verbose custom, fd-specific stderr+ipc', testPrintIpcOrder, 'stderr', 'ipc', false);\ntest('Prints IPC, verbose custom, fd-specific ipc+stderr', testPrintIpcOrder, 'ipc', 'stderr', true);\ntest('Prints IPC, verbose custom, fd-specific fd3+ipc', testPrintIpcOrder, 'fd3', 'ipc', false);\ntest('Prints IPC, verbose custom, fd-specific ipc+fd3', testPrintIpcOrder, 'ipc', 'fd3', true);\n\nconst testPrintIpcFunction = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-function.js',\n\t\ttype: 'ipc',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] * . .`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints IPC, verbose custom, fd-specific stdout+stderr, single function', testPrintIpcFunction, 'stdout', 'stderr', false);\ntest('Prints IPC, verbose custom, fd-specific stderr+stdout, single function', testPrintIpcFunction, 'stderr', 'stdout', false);\ntest('Prints IPC, verbose custom, fd-specific stdout+fd3, single function', testPrintIpcFunction, 'stdout', 'fd3', false);\ntest('Prints IPC, verbose custom, fd-specific fd3+stdout, single function', testPrintIpcFunction, 'fd3', 'stdout', false);\ntest('Prints IPC, verbose custom, fd-specific stdout+ipc, single function', testPrintIpcFunction, 'stdout', 'ipc', false);\ntest('Prints IPC, verbose custom, fd-specific ipc+stdout, single function', testPrintIpcFunction, 'ipc', 'stdout', true);\ntest('Prints IPC, verbose custom, fd-specific stderr+fd3, single function', testPrintIpcFunction, 'stderr', 'fd3', false);\ntest('Prints IPC, verbose custom, fd-specific fd3+stderr, single function', testPrintIpcFunction, 'fd3', 'stderr', false);\ntest('Prints IPC, verbose custom, fd-specific stderr+ipc, single function', testPrintIpcFunction, 'stderr', 'ipc', false);\ntest('Prints IPC, verbose custom, fd-specific ipc+stderr, single function', testPrintIpcFunction, 'ipc', 'stderr', true);\ntest('Prints IPC, verbose custom, fd-specific fd3+ipc, single function', testPrintIpcFunction, 'fd3', 'ipc', false);\ntest('Prints IPC, verbose custom, fd-specific ipc+fd3, single function', testPrintIpcFunction, 'ipc', 'fd3', true);\n\ntest('\"verbose\" function receives verboseObject.message', async t => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\ttype: 'ipc',\n\t\teventProperty: 'message',\n\t});\n\tt.is(stderr, '. .');\n});\n\ntest('\"verbose\" function receives verboseObject.message line-wise', async t => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\ttype: 'ipc',\n\t\toutput: '.\\n.',\n\t});\n\tt.deepEqual(getNormalizedLines(stderr), [`${testTimestamp} [0] * .`, `${testTimestamp} [0] * .`]);\n});\n\ntest('\"verbose\" function receives verboseObject.message serialized', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-echo.js', {\n\t\tipcInput: foobarObject,\n\t\toptionsFixture: 'custom-print.js',\n\t\toptionsInput: {type: 'ipc'},\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] * ${inspect(foobarObject)}`);\n});\n"
  },
  {
    "path": "test/verbose/custom-options.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {runVerboseSubprocess} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testVerboseOptionsExplicit = async (t, type, isSync) => {\n\tconst maxBuffer = 1000;\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-option.js',\n\t\toptionName: 'maxBuffer',\n\t\tmaxBuffer,\n\t});\n\tt.is(stderr, `${maxBuffer}`);\n};\n\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"command\"', testVerboseOptionsExplicit, 'command', false);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"output\"', testVerboseOptionsExplicit, 'output', false);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"ipc\"', testVerboseOptionsExplicit, 'ipc', false);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"error\"', testVerboseOptionsExplicit, 'error', false);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"duration\"', testVerboseOptionsExplicit, 'duration', false);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"command\", sync', testVerboseOptionsExplicit, 'command', true);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"output\", sync', testVerboseOptionsExplicit, 'output', true);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"error\", sync', testVerboseOptionsExplicit, 'error', true);\ntest('\"verbose\" function receives verboseObject.options explicitly set, \"duration\", sync', testVerboseOptionsExplicit, 'duration', true);\n\nconst testVerboseOptionsDefault = async (t, type, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-option.js',\n\t\toptionName: 'maxBuffer',\n\t});\n\tt.is(stderr, 'undefined');\n};\n\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"command\"', testVerboseOptionsDefault, 'command', false);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"output\"', testVerboseOptionsDefault, 'output', false);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"ipc\"', testVerboseOptionsDefault, 'ipc', false);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"error\"', testVerboseOptionsDefault, 'error', false);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"duration\"', testVerboseOptionsDefault, 'duration', false);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"command\", sync', testVerboseOptionsDefault, 'command', true);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"output\", sync', testVerboseOptionsDefault, 'output', true);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"error\", sync', testVerboseOptionsDefault, 'error', true);\ntest('\"verbose\" function receives verboseObject.options before default values and normalization, \"duration\", sync', testVerboseOptionsDefault, 'duration', true);\n"
  },
  {
    "path": "test/verbose/custom-output.js",
    "content": "import {inspect} from 'node:util';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {\n\tgetNormalizedLine,\n\tgetNormalizedLines,\n\ttestTimestamp,\n\trunVerboseSubprocess,\n} from '../helpers/verbose.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {foobarObject} from '../helpers/input.js';\n\nsetFixtureDirectory();\n\nconst testPrintOutputCustom = async (t, fdNumber, isSync, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\tisSync,\n\t\ttype: 'output',\n\t\tfdNumber,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0]   . .`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints stdout, verbose custom', testPrintOutputCustom, undefined, false, true);\ntest('Prints stdout, verbose custom, fd-specific stdout', testPrintOutputCustom, 'stdout', false, true);\ntest('Prints stdout, verbose custom, fd-specific stderr', testPrintOutputCustom, 'stderr', false, false);\ntest('Prints stdout, verbose custom, fd-specific fd3', testPrintOutputCustom, 'fd3', false, false);\ntest('Prints stdout, verbose custom, fd-specific ipc', testPrintOutputCustom, 'ipc', false, false);\ntest('Prints stdout, verbose custom, sync', testPrintOutputCustom, undefined, true, true);\ntest('Prints stdout, verbose custom, fd-specific stdout, sync', testPrintOutputCustom, 'stdout', true, true);\ntest('Prints stdout, verbose custom, fd-specific stderr, sync', testPrintOutputCustom, 'stderr', true, false);\ntest('Prints stdout, verbose custom, fd-specific fd3, sync', testPrintOutputCustom, 'fd3', true, false);\ntest('Prints stdout, verbose custom, fd-specific ipc, sync', testPrintOutputCustom, 'ipc', true, false);\n\nconst testPrintOutputOrder = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-multiple.js',\n\t\ttype: 'output',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0]   . .`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints stdout, verbose custom, fd-specific stdout+stderr', testPrintOutputOrder, 'stdout', 'stderr', true);\ntest('Prints stdout, verbose custom, fd-specific stderr+stdout', testPrintOutputOrder, 'stderr', 'stdout', false);\ntest('Prints stdout, verbose custom, fd-specific stdout+fd3', testPrintOutputOrder, 'stdout', 'fd3', true);\ntest('Prints stdout, verbose custom, fd-specific fd3+stdout', testPrintOutputOrder, 'fd3', 'stdout', false);\ntest('Prints stdout, verbose custom, fd-specific stdout+ipc', testPrintOutputOrder, 'stdout', 'ipc', true);\ntest('Prints stdout, verbose custom, fd-specific ipc+stdout', testPrintOutputOrder, 'ipc', 'stdout', false);\ntest('Prints stdout, verbose custom, fd-specific stderr+fd3', testPrintOutputOrder, 'stderr', 'fd3', false);\ntest('Prints stdout, verbose custom, fd-specific fd3+stderr', testPrintOutputOrder, 'fd3', 'stderr', false);\ntest('Prints stdout, verbose custom, fd-specific stderr+ipc', testPrintOutputOrder, 'stderr', 'ipc', false);\ntest('Prints stdout, verbose custom, fd-specific ipc+stderr', testPrintOutputOrder, 'ipc', 'stderr', false);\ntest('Prints stdout, verbose custom, fd-specific fd3+ipc', testPrintOutputOrder, 'fd3', 'ipc', false);\ntest('Prints stdout, verbose custom, fd-specific ipc+fd3', testPrintOutputOrder, 'ipc', 'fd3', false);\n\nconst testPrintOutputFunction = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-function.js',\n\t\ttype: 'output',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0]   . .`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints stdout, verbose custom, fd-specific stdout+stderr, single function', testPrintOutputFunction, 'stdout', 'stderr', true);\ntest('Prints stdout, verbose custom, fd-specific stderr+stdout, single function', testPrintOutputFunction, 'stderr', 'stdout', false);\ntest('Prints stdout, verbose custom, fd-specific stdout+fd3, single function', testPrintOutputFunction, 'stdout', 'fd3', true);\ntest('Prints stdout, verbose custom, fd-specific fd3+stdout, single function', testPrintOutputFunction, 'fd3', 'stdout', false);\ntest('Prints stdout, verbose custom, fd-specific stdout+ipc, single function', testPrintOutputFunction, 'stdout', 'ipc', true);\ntest('Prints stdout, verbose custom, fd-specific ipc+stdout, single function', testPrintOutputFunction, 'ipc', 'stdout', false);\ntest('Prints stdout, verbose custom, fd-specific stderr+fd3, single function', testPrintOutputFunction, 'stderr', 'fd3', false);\ntest('Prints stdout, verbose custom, fd-specific fd3+stderr, single function', testPrintOutputFunction, 'fd3', 'stderr', false);\ntest('Prints stdout, verbose custom, fd-specific stderr+ipc, single function', testPrintOutputFunction, 'stderr', 'ipc', false);\ntest('Prints stdout, verbose custom, fd-specific ipc+stderr, single function', testPrintOutputFunction, 'ipc', 'stderr', false);\ntest('Prints stdout, verbose custom, fd-specific fd3+ipc, single function', testPrintOutputFunction, 'fd3', 'ipc', false);\ntest('Prints stdout, verbose custom, fd-specific ipc+fd3, single function', testPrintOutputFunction, 'ipc', 'fd3', false);\n\nconst testVerboseMessage = async (t, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype: 'output',\n\t\teventProperty: 'message',\n\t});\n\tt.is(stderr, '. .');\n};\n\ntest('\"verbose\" function receives verboseObject.message', testVerboseMessage, false);\ntest('\"verbose\" function receives verboseObject.message, sync', testVerboseMessage, true);\n\nconst testPrintOutputMultiline = async (t, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\tisSync,\n\t\ttype: 'output',\n\t\toutput: '.\\n.',\n\t});\n\tt.deepEqual(getNormalizedLines(stderr), [`${testTimestamp} [0]   .`, `${testTimestamp} [0]   .`]);\n};\n\ntest('\"verbose\" function receives verboseObject.message line-wise', testPrintOutputMultiline, false);\ntest('\"verbose\" function receives verboseObject.message line-wise, sync', testPrintOutputMultiline, true);\n\ntest('\"verbose\" function receives verboseObject.message serialized', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', {optionsFixture: 'custom-object-stdout.js'});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0]   ${inspect(foobarObject)}`);\n});\n"
  },
  {
    "path": "test/verbose/custom-reject.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {runVerboseSubprocess} from '../helpers/verbose.js';\nimport {earlyErrorOptions, earlyErrorOptionsSync} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\n// eslint-disable-next-line max-params\nconst testVerboseReject = async (t, type, options, isSync, expectedOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-option.js',\n\t\toptionName: 'reject',\n\t\t...options,\n\t});\n\tt.is(stderr, expectedOutput.map(String).join('\\n'));\n};\n\ntest('\"verbose\" function receives verboseObject.options.reject, \"command\"', testVerboseReject, 'command', {}, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"output\"', testVerboseReject, 'output', {}, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"ipc\"', testVerboseReject, 'ipc', {}, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"error\"', testVerboseReject, 'error', {}, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"duration\"', testVerboseReject, 'duration', {}, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"command\", spawn error', testVerboseReject, 'command', earlyErrorOptions, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"output\", spawn error', testVerboseReject, 'output', earlyErrorOptions, false, []);\ntest('\"verbose\" function receives verboseObject.options.reject, \"ipc\", spawn error', testVerboseReject, 'ipc', earlyErrorOptions, false, []);\ntest('\"verbose\" function receives verboseObject.options.reject, \"error\", spawn error', testVerboseReject, 'error', earlyErrorOptions, false, [undefined, undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"duration\", spawn error', testVerboseReject, 'duration', earlyErrorOptions, false, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"command\", sync', testVerboseReject, 'command', {}, true, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"output\", sync', testVerboseReject, 'output', {}, true, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"error\", sync', testVerboseReject, 'error', {}, true, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"duration\", sync', testVerboseReject, 'duration', {}, true, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"command\", spawn error, sync', testVerboseReject, 'command', earlyErrorOptionsSync, true, [undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"output\", spawn error, sync', testVerboseReject, 'output', earlyErrorOptionsSync, true, []);\ntest('\"verbose\" function receives verboseObject.options.reject, \"error\", spawn error, sync', testVerboseReject, 'error', earlyErrorOptionsSync, true, [undefined, undefined]);\ntest('\"verbose\" function receives verboseObject.options.reject, \"duration\", spawn error, sync', testVerboseReject, 'duration', earlyErrorOptionsSync, true, [undefined]);\n"
  },
  {
    "path": "test/verbose/custom-result.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {runVerboseSubprocess} from '../helpers/verbose.js';\nimport {\n\tearlyErrorOptions,\n\tearlyErrorOptionsSync,\n\texpectedEarlyError,\n\texpectedEarlyErrorSync,\n} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testVerboseResultEnd = async (t, type, isSync) => {\n\tconst {stderr: parentStderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-result.js',\n\t});\n\tconst {failed, exitCode, stdout, stderr, ipcOutput, durationMs} = JSON.parse(parentStderr);\n\tt.true(failed);\n\tt.is(exitCode, 2);\n\tt.is(stdout, '. .');\n\tt.is(stderr, '');\n\tt.is(typeof durationMs, 'number');\n\tt.deepEqual(ipcOutput, isSync ? [] : ['. .']);\n};\n\ntest('\"verbose\" function receives verboseObject.result, \"error\"', testVerboseResultEnd, 'error', false);\ntest('\"verbose\" function receives verboseObject.result, \"duration\"', testVerboseResultEnd, 'duration', false);\ntest('\"verbose\" function receives verboseObject.result, \"error\", sync', testVerboseResultEnd, 'error', true);\ntest('\"verbose\" function receives verboseObject.result, \"duration\", sync', testVerboseResultEnd, 'duration', true);\n\n// eslint-disable-next-line max-params\nconst testVerboseResultEndSpawn = async (t, type, options, expectedOutput, isSync) => {\n\tconst {stderr: parentStderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-result.js',\n\t\t...options,\n\t});\n\tconst lastLine = parentStderr.split('\\n').at(-1);\n\tconst result = JSON.parse(lastLine);\n\tt.like(result, expectedOutput);\n\tt.true(result.failed);\n\tt.is(result.exitCode, undefined);\n\tt.is(result.stdout, undefined);\n\tt.is(result.stderr, undefined);\n\tt.is(typeof result.durationMs, 'number');\n\tt.deepEqual(result.ipcOutput, []);\n};\n\ntest('\"verbose\" function receives verboseObject.result, \"error\", spawn error', testVerboseResultEndSpawn, 'error', earlyErrorOptions, expectedEarlyError, false);\ntest('\"verbose\" function receives verboseObject.result, \"duration\", spawn error', testVerboseResultEndSpawn, 'duration', earlyErrorOptions, expectedEarlyError, false);\ntest('\"verbose\" function receives verboseObject.result, \"error\", spawn error, sync', testVerboseResultEndSpawn, 'error', earlyErrorOptionsSync, expectedEarlyErrorSync, true);\ntest('\"verbose\" function receives verboseObject.result, \"duration\", spawn error, sync', testVerboseResultEndSpawn, 'duration', earlyErrorOptionsSync, expectedEarlyErrorSync, true);\n\nconst testVerboseResultStart = async (t, type, options, isSync) => {\n\tconst {stderr: parentStderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-result.js',\n\t\t...options,\n\t});\n\tt.is(parentStderr, '');\n};\n\ntest('\"verbose\" function does not receive verboseObject.result, \"command\"', testVerboseResultStart, 'command', {}, false);\ntest('\"verbose\" function does not receive verboseObject.result, \"output\"', testVerboseResultStart, 'output', {}, false);\ntest('\"verbose\" function does not receive verboseObject.result, \"ipc\"', testVerboseResultStart, 'ipc', {}, false);\ntest('\"verbose\" function does not receive verboseObject.result, \"command\", spawn error', testVerboseResultStart, 'command', earlyErrorOptions, false);\ntest('\"verbose\" function does not receive verboseObject.result, \"output\", spawn error', testVerboseResultStart, 'output', earlyErrorOptions, false);\ntest('\"verbose\" function does not receive verboseObject.result, \"ipc\", spawn error', testVerboseResultStart, 'ipc', earlyErrorOptions, false);\ntest('\"verbose\" function does not receive verboseObject.result, \"command\", sync', testVerboseResultStart, 'command', {}, true);\ntest('\"verbose\" function does not receive verboseObject.result, \"output\", sync', testVerboseResultStart, 'output', {}, true);\ntest('\"verbose\" function does not receive verboseObject.result, \"command\", spawn error, sync', testVerboseResultStart, 'command', earlyErrorOptionsSync, true);\ntest('\"verbose\" function does not receive verboseObject.result, \"output\", spawn error, sync', testVerboseResultStart, 'output', earlyErrorOptionsSync, true);\n"
  },
  {
    "path": "test/verbose/custom-start.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {\n\tQUOTE,\n\tgetNormalizedLine,\n\ttestTimestamp,\n\trunVerboseSubprocess,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintCommandCustom = async (t, fdNumber, worker, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print.js',\n\t\tworker,\n\t\tisSync,\n\t\ttype: 'command',\n\t\tfdNumber,\n\t});\n\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('Prints command, verbose custom', testPrintCommandCustom, undefined, false, false);\ntest('Prints command, verbose custom, fd-specific stdout', testPrintCommandCustom, 'stdout', false, false);\ntest('Prints command, verbose custom, fd-specific stderr', testPrintCommandCustom, 'stderr', false, false);\ntest('Prints command, verbose custom, fd-specific fd3', testPrintCommandCustom, 'fd3', false, false);\ntest('Prints command, verbose custom, fd-specific ipc', testPrintCommandCustom, 'ipc', false, false);\ntest('Prints command, verbose custom, sync', testPrintCommandCustom, undefined, false, true);\ntest('Prints command, verbose custom, fd-specific stdout, sync', testPrintCommandCustom, 'stdout', false, true);\ntest('Prints command, verbose custom, fd-specific stderr, sync', testPrintCommandCustom, 'stderr', false, true);\ntest('Prints command, verbose custom, fd-specific fd3, sync', testPrintCommandCustom, 'fd3', false, true);\ntest('Prints command, verbose custom, fd-specific ipc, sync', testPrintCommandCustom, 'ipc', false, true);\ntest('Prints command, verbose custom, worker', testPrintCommandCustom, undefined, true, false);\ntest('Prints command, verbose custom, fd-specific stdout, worker', testPrintCommandCustom, 'stdout', true, false);\ntest('Prints command, verbose custom, fd-specific stderr, worker', testPrintCommandCustom, 'stderr', true, false);\ntest('Prints command, verbose custom, fd-specific fd3, worker', testPrintCommandCustom, 'fd3', true, false);\ntest('Prints command, verbose custom, fd-specific ipc, worker', testPrintCommandCustom, 'ipc', true, false);\ntest('Prints command, verbose custom, worker, sync', testPrintCommandCustom, undefined, true, true);\ntest('Prints command, verbose custom, fd-specific stdout, worker, sync', testPrintCommandCustom, 'stdout', true, true);\ntest('Prints command, verbose custom, fd-specific stderr, worker, sync', testPrintCommandCustom, 'stderr', true, true);\ntest('Prints command, verbose custom, fd-specific fd3, worker, sync', testPrintCommandCustom, 'fd3', true, true);\ntest('Prints command, verbose custom, fd-specific ipc, worker, sync', testPrintCommandCustom, 'ipc', true, true);\n\nconst testPrintCommandOrder = async (t, fdNumber, secondFdNumber, hasOutput) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\toptionsFixture: 'custom-print-multiple.js',\n\t\ttype: 'command',\n\t\tfdNumber,\n\t\tsecondFdNumber,\n\t\t...fullStdio,\n\t});\n\n\tif (hasOutput) {\n\t\tt.is(getNormalizedLine(stderr), `${testTimestamp} [0] $ noop-verbose.js ${QUOTE}. .${QUOTE}`);\n\t} else {\n\t\tt.is(stderr, '');\n\t}\n};\n\ntest('Prints command, verbose custom, fd-specific stdout+stderr', testPrintCommandOrder, 'stdout', 'stderr', true);\ntest('Prints command, verbose custom, fd-specific stderr+stdout', testPrintCommandOrder, 'stderr', 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stdout+fd3', testPrintCommandOrder, 'stdout', 'fd3', true);\ntest('Prints command, verbose custom, fd-specific fd3+stdout', testPrintCommandOrder, 'fd3', 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stdout+ipc', testPrintCommandOrder, 'stdout', 'ipc', true);\ntest('Prints command, verbose custom, fd-specific ipc+stdout', testPrintCommandOrder, 'ipc', 'stdout', false);\ntest('Prints command, verbose custom, fd-specific stderr+fd3', testPrintCommandOrder, 'stderr', 'fd3', true);\ntest('Prints command, verbose custom, fd-specific fd3+stderr', testPrintCommandOrder, 'fd3', 'stderr', false);\ntest('Prints command, verbose custom, fd-specific stderr+ipc', testPrintCommandOrder, 'stderr', 'ipc', true);\ntest('Prints command, verbose custom, fd-specific ipc+stderr', testPrintCommandOrder, 'ipc', 'stderr', false);\ntest('Prints command, verbose custom, fd-specific fd3+ipc', testPrintCommandOrder, 'fd3', 'ipc', true);\ntest('Prints command, verbose custom, fd-specific ipc+fd3', testPrintCommandOrder, 'ipc', 'fd3', false);\n\nconst testVerboseMessage = async (t, isSync) => {\n\tconst {stderr} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype: 'command',\n\t\teventProperty: 'message',\n\t});\n\tt.is(stderr, `noop-verbose.js ${QUOTE}. .${QUOTE}`);\n};\n\ntest('\"verbose\" function receives verboseObject.message', testVerboseMessage, false);\ntest('\"verbose\" function receives verboseObject.message, sync', testVerboseMessage, true);\n"
  },
  {
    "path": "test/verbose/custom-throw.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {runVerboseSubprocess} from '../helpers/verbose.js';\nimport {earlyErrorOptions, earlyErrorOptionsSync} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testCommandThrowPropagate = async (t, type, options, isSync) => {\n\tconst {nestedResult} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-throw.js',\n\t\terrorMessage: foobarString,\n\t\t...options,\n\t});\n\tt.true(nestedResult instanceof Error);\n\tt.is(nestedResult.message, foobarString);\n};\n\ntest('Propagate verbose exception in \"verbose\" function, \"command\"', testCommandThrowPropagate, 'command', {}, false);\ntest('Propagate verbose exception in \"verbose\" function, \"error\"', testCommandThrowPropagate, 'error', {}, false);\ntest('Propagate verbose exception in \"verbose\" function, \"duration\"', testCommandThrowPropagate, 'duration', {}, false);\ntest('Propagate verbose exception in \"verbose\" function, \"command\", spawn error', testCommandThrowPropagate, 'command', earlyErrorOptions, false);\ntest('Propagate verbose exception in \"verbose\" function, \"error\", spawn error', testCommandThrowPropagate, 'error', earlyErrorOptions, false);\ntest('Propagate verbose exception in \"verbose\" function, \"duration\", spawn error', testCommandThrowPropagate, 'duration', earlyErrorOptions, false);\ntest('Propagate verbose exception in \"verbose\" function, \"command\", sync', testCommandThrowPropagate, 'command', {}, true);\ntest('Propagate verbose exception in \"verbose\" function, \"error\", sync', testCommandThrowPropagate, 'error', {}, true);\ntest('Propagate verbose exception in \"verbose\" function, \"duration\", sync', testCommandThrowPropagate, 'duration', {}, true);\ntest('Propagate verbose exception in \"verbose\" function, \"command\", spawn error, sync', testCommandThrowPropagate, 'command', earlyErrorOptionsSync, true);\ntest('Propagate verbose exception in \"verbose\" function, \"error\", spawn error, sync', testCommandThrowPropagate, 'error', earlyErrorOptionsSync, true);\ntest('Propagate verbose exception in \"verbose\" function, \"duration\", spawn error, sync', testCommandThrowPropagate, 'duration', earlyErrorOptionsSync, true);\n\nconst testCommandThrowHandle = async (t, type, isSync) => {\n\tconst {nestedResult} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-throw.js',\n\t\terrorMessage: foobarString,\n\t});\n\tt.true(nestedResult instanceof Error);\n\tt.true(nestedResult.stack.startsWith(isSync ? 'ExecaSyncError' : 'ExecaError'));\n\tt.true(nestedResult.cause instanceof Error);\n\tt.is(nestedResult.cause.message, foobarString);\n};\n\ntest('Handle exceptions in \"verbose\" function, \"output\"', testCommandThrowHandle, 'output', false);\ntest('Handle exceptions in \"verbose\" function, \"ipc\"', testCommandThrowHandle, 'ipc', false);\ntest('Handle exceptions in \"verbose\" function, \"output\", sync', testCommandThrowHandle, 'output', true);\n\nconst testCommandThrowWrap = async (t, type, options, isSync) => {\n\tconst {nestedResult} = await runVerboseSubprocess({\n\t\tisSync,\n\t\ttype,\n\t\toptionsFixture: 'custom-throw.js',\n\t\terrorMessage: foobarString,\n\t\t...options,\n\t});\n\tt.true(nestedResult instanceof Error);\n\tt.true(nestedResult.stack.startsWith(isSync ? 'ExecaSyncError' : 'ExecaError'));\n\tt.true(nestedResult.cause instanceof Error);\n\tt.not(nestedResult.cause.message, foobarString);\n};\n\ntest('Propagate wrapped exception in \"verbose\" function, \"output\", spawn error', testCommandThrowWrap, 'output', earlyErrorOptions, false);\ntest('Propagate wrapped exception in \"verbose\" function, \"ipc\", spawn error', testCommandThrowWrap, 'ipc', earlyErrorOptions, false);\ntest('Propagate wrapped exception in \"verbose\" function, \"output\", spawn error, sync', testCommandThrowWrap, 'output', earlyErrorOptionsSync, true);\n"
  },
  {
    "path": "test/verbose/error.js",
    "content": "import test from 'ava';\nimport {red} from 'yoctocolors';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\tQUOTE,\n\trunErrorSubprocess,\n\trunEarlyErrorSubprocess,\n\tgetErrorLine,\n\tgetErrorLines,\n\ttestTimestamp,\n\tgetVerboseOption,\n\tstdoutNoneOption,\n\tstdoutShortOption,\n\tstdoutFullOption,\n\tstderrNoneOption,\n\tstderrShortOption,\n\tstderrFullOption,\n\tfd3NoneOption,\n\tfd3ShortOption,\n\tfd3FullOption,\n\tipcNoneOption,\n\tipcShortOption,\n\tipcFullOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintError = async (t, verbose, isSync) => {\n\tconst stderr = await runErrorSubprocess(t, verbose, isSync);\n\tt.is(getErrorLine(stderr), `${testTimestamp} [0] × Command failed with exit code 2: noop-fail.js 1 ${foobarString}`);\n};\n\ntest('Prints error, verbose \"short\"', testPrintError, 'short', false);\ntest('Prints error, verbose \"full\"', testPrintError, 'full', false);\ntest('Prints error, verbose \"short\", fd-specific stdout', testPrintError, stdoutShortOption, false);\ntest('Prints error, verbose \"full\", fd-specific stdout', testPrintError, stdoutFullOption, false);\ntest('Prints error, verbose \"short\", fd-specific stderr', testPrintError, stderrShortOption, false);\ntest('Prints error, verbose \"full\", fd-specific stderr', testPrintError, stderrFullOption, false);\ntest('Prints error, verbose \"short\", fd-specific fd3', testPrintError, fd3ShortOption, false);\ntest('Prints error, verbose \"full\", fd-specific fd3', testPrintError, fd3FullOption, false);\ntest('Prints error, verbose \"short\", fd-specific ipc', testPrintError, ipcShortOption, false);\ntest('Prints error, verbose \"full\", fd-specific ipc', testPrintError, ipcFullOption, false);\ntest('Prints error, verbose \"short\", sync', testPrintError, 'short', true);\ntest('Prints error, verbose \"full\", sync', testPrintError, 'full', true);\ntest('Prints error, verbose \"short\", fd-specific stdout, sync', testPrintError, stdoutShortOption, true);\ntest('Prints error, verbose \"full\", fd-specific stdout, sync', testPrintError, stdoutFullOption, true);\ntest('Prints error, verbose \"short\", fd-specific stderr, sync', testPrintError, stderrShortOption, true);\ntest('Prints error, verbose \"full\", fd-specific stderr, sync', testPrintError, stderrFullOption, true);\ntest('Prints error, verbose \"short\", fd-specific fd3, sync', testPrintError, fd3ShortOption, true);\ntest('Prints error, verbose \"full\", fd-specific fd3, sync', testPrintError, fd3FullOption, true);\ntest('Prints error, verbose \"short\", fd-specific ipc, sync', testPrintError, ipcShortOption, true);\ntest('Prints error, verbose \"full\", fd-specific ipc, sync', testPrintError, ipcFullOption, true);\n\nconst testNoPrintError = async (t, verbose, isSync) => {\n\tconst stderr = await runErrorSubprocess(t, verbose, isSync, false);\n\tt.is(getErrorLine(stderr), undefined);\n};\n\ntest('Does not print error, verbose \"none\"', testNoPrintError, 'none', false);\ntest('Does not print error, verbose default', testNoPrintError, undefined, false);\ntest('Does not print error, verbose \"none\", fd-specific stdout', testNoPrintError, stdoutNoneOption, false);\ntest('Does not print error, verbose \"none\", fd-specific stderr', testNoPrintError, stderrNoneOption, false);\ntest('Does not print error, verbose \"none\", fd-specific fd3', testNoPrintError, fd3NoneOption, false);\ntest('Does not print error, verbose \"none\", fd-specific ipc', testNoPrintError, ipcNoneOption, false);\ntest('Does not print error, verbose default, fd-specific', testNoPrintError, {}, false);\ntest('Does not print error, verbose \"none\", sync', testNoPrintError, 'none', true);\ntest('Does not print error, verbose default, sync', testNoPrintError, undefined, true);\ntest('Does not print error, verbose \"none\", fd-specific stdout, sync', testNoPrintError, stdoutNoneOption, true);\ntest('Does not print error, verbose \"none\", fd-specific stderr, sync', testNoPrintError, stderrNoneOption, true);\ntest('Does not print error, verbose \"none\", fd-specific fd3, sync', testNoPrintError, fd3NoneOption, true);\ntest('Does not print error, verbose \"none\", fd-specific ipc, sync', testNoPrintError, ipcNoneOption, true);\ntest('Does not print error, verbose default, fd-specific, sync', testNoPrintError, {}, true);\n\nconst testPrintNoError = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short', isSync});\n\tt.is(getErrorLine(stderr), undefined);\n};\n\ntest('Does not print error if none', testPrintNoError, false);\ntest('Does not print error if none, sync', testPrintNoError, true);\n\nconst testPrintErrorEarly = async (t, isSync) => {\n\tconst stderr = await runEarlyErrorSubprocess(t, isSync);\n\tt.is(getErrorLine(stderr), undefined);\n};\n\ntest('Prints early validation error', testPrintErrorEarly, false);\ntest('Prints early validation error, sync', testPrintErrorEarly, true);\n\ntest('Does not repeat stdout|stderr with error', async t => {\n\tconst stderr = await runErrorSubprocess(t, 'short');\n\tt.deepEqual(getErrorLines(stderr), [`${testTimestamp} [0] × Command failed with exit code 2: noop-fail.js 1 ${foobarString}`]);\n});\n\ntest('Prints error differently if \"reject\" is false', async t => {\n\tconst {stderr} = await nestedSubprocess('noop-fail.js', ['1', foobarString], {verbose: 'short', reject: false});\n\tt.deepEqual(getErrorLines(stderr), [`${testTimestamp} [0] ‼ Command failed with exit code 2: noop-fail.js 1 ${foobarString}`]);\n});\n\nconst testPipeError = async (t, parentFixture, sourceVerbose, destinationVerbose) => {\n\tconst {stderr} = await t.throwsAsync(nestedSubprocess('noop-fail.js', ['1'], {\n\t\tparentFixture,\n\t\tsourceOptions: getVerboseOption(sourceVerbose),\n\t\tdestinationFile: 'stdin-fail.js',\n\t\tdestinationOptions: getVerboseOption(destinationVerbose),\n\t}));\n\n\tconst lines = getErrorLines(stderr);\n\tt.is(lines.includes(`${testTimestamp} [0] × Command failed with exit code 2: noop-fail.js 1`), sourceVerbose);\n\tt.is(lines.includes(`${testTimestamp} [${sourceVerbose ? 1 : 0}] × Command failed with exit code 2: stdin-fail.js`), destinationVerbose);\n};\n\ntest('Prints both errors piped with .pipe(\"file\")', testPipeError, 'nested-pipe-file.js', true, true);\ntest('Prints both errors piped with .pipe`command`', testPipeError, 'nested-pipe-script.js', true, true);\ntest('Prints both errors piped with .pipe(subprocess)', testPipeError, 'nested-pipe-subprocesses.js', true, true);\ntest('Prints first error piped with .pipe(\"file\")', testPipeError, 'nested-pipe-file.js', true, false);\ntest('Prints first error piped with .pipe`command`', testPipeError, 'nested-pipe-script.js', true, false);\ntest('Prints first error piped with .pipe(subprocess)', testPipeError, 'nested-pipe-subprocesses.js', true, false);\ntest('Prints second error piped with .pipe(\"file\")', testPipeError, 'nested-pipe-file.js', false, true);\ntest('Prints second error piped with .pipe`command`', testPipeError, 'nested-pipe-script.js', false, true);\ntest('Prints second error piped with .pipe(subprocess)', testPipeError, 'nested-pipe-subprocesses.js', false, true);\ntest('Prints neither errors piped with .pipe(\"file\")', testPipeError, 'nested-pipe-file.js', false, false);\ntest('Prints neither errors piped with .pipe`command`', testPipeError, 'nested-pipe-script.js', false, false);\ntest('Prints neither errors piped with .pipe(subprocess)', testPipeError, 'nested-pipe-subprocesses.js', false, false);\n\ntest('Quotes spaces from error', async t => {\n\tconst {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', ['foo bar'], {parentFixture: 'nested-fail.js', verbose: 'short'}));\n\tt.deepEqual(getErrorLines(stderr), [\n\t\t`${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}foo bar${QUOTE}`,\n\t\t`${testTimestamp} [0] × foo bar`,\n\t]);\n});\n\ntest('Quotes special punctuation from error', async t => {\n\tconst {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', ['%'], {parentFixture: 'nested-fail.js', verbose: 'short'}));\n\tt.deepEqual(getErrorLines(stderr), [\n\t\t`${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}%${QUOTE}`,\n\t\t`${testTimestamp} [0] × %`,\n\t]);\n});\n\ntest('Does not escape internal characters from error', async t => {\n\tconst {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', ['ã'], {parentFixture: 'nested-fail.js', verbose: 'short'}));\n\tt.deepEqual(getErrorLines(stderr), [\n\t\t`${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}ã${QUOTE}`,\n\t\t`${testTimestamp} [0] × ã`,\n\t]);\n});\n\ntest('Escapes and strips color sequences from error', async t => {\n\tconst {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', [red(foobarString)], {parentFixture: 'nested-fail.js', verbose: 'short'}, {env: {FORCE_COLOR: '1'}}));\n\tt.deepEqual(getErrorLines(stderr), [\n\t\t`${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}\\\\u001b[31m${foobarString}\\\\u001b[39m${QUOTE}`,\n\t\t`${testTimestamp} [0] × ${foobarString}`,\n\t]);\n});\n\ntest('Escapes control characters from error', async t => {\n\tconst {stderr} = await t.throwsAsync(nestedSubprocess('noop-forever.js', ['\\u0001'], {parentFixture: 'nested-fail.js', verbose: 'short'}));\n\tt.deepEqual(getErrorLines(stderr), [\n\t\t`${testTimestamp} [0] × Command was killed with SIGTERM (Termination): noop-forever.js ${QUOTE}\\\\u0001${QUOTE}`,\n\t\t`${testTimestamp} [0] × \\\\u0001`,\n\t]);\n});\n"
  },
  {
    "path": "test/verbose/info.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {execa, execaSync} from '../../index.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\tQUOTE,\n\tgetCommandLine,\n\tgetOutputLine,\n\tgetNormalizedLines,\n\ttestTimestamp,\n} from '../helpers/verbose.js';\nimport {earlyErrorOptions, earlyErrorOptionsSync} from '../helpers/early-error.js';\n\nsetFixtureDirectory();\n\nconst testVerboseGeneral = async (t, execaMethod) => {\n\tconst {all} = await execaMethod('verbose-script.js', {env: {NODE_DEBUG: 'execa'}, all: true});\n\tt.deepEqual(getNormalizedLines(all), [\n\t\t`${testTimestamp} [0] $ node -e ${QUOTE}console.error(1)${QUOTE}`,\n\t\t'1',\n\t\t`${testTimestamp} [0] √ (done in 0ms)`,\n\t\t`${testTimestamp} [1] $ node -e ${QUOTE}process.exit(2)${QUOTE}`,\n\t\t`${testTimestamp} [1] ‼ Command failed with exit code 2: node -e ${QUOTE}process.exit(2)${QUOTE}`,\n\t\t`${testTimestamp} [1] ‼ (done in 0ms)`,\n\t]);\n};\n\ntest('Prints command, NODE_DEBUG=execa + \"inherit\"', testVerboseGeneral, execa);\ntest('Prints command, NODE_DEBUG=execa + \"inherit\", sync', testVerboseGeneral, execaSync);\n\ntest('NODE_DEBUG=execa changes verbose default value to \"full\"', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {}, {env: {NODE_DEBUG: 'execa'}});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n});\n\nconst testDebugEnvPriority = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short', isSync}, {env: {NODE_DEBUG: 'execa'}});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);\n\tt.is(getOutputLine(stderr), undefined);\n};\n\ntest('NODE_DEBUG=execa has lower priority', testDebugEnvPriority, false);\ntest('NODE_DEBUG=execa has lower priority, sync', testDebugEnvPriority, true);\n\nconst invalidFalseMessage = 'renamed to \"verbose: \\'none\\'\"';\nconst invalidTrueMessage = 'renamed to \"verbose: \\'short\\'\"';\nconst invalidUnknownMessage = 'Allowed values are: \\'none\\', \\'short\\', \\'full\\'';\n\nconst testInvalidVerbose = (t, verbose, expectedMessage, execaMethod) => {\n\tconst {message} = t.throws(() => {\n\t\texecaMethod('empty.js', {verbose});\n\t});\n\tt.true(message.includes(expectedMessage));\n};\n\ntest('Does not allow \"verbose: false\"', testInvalidVerbose, false, invalidFalseMessage, execa);\ntest('Does not allow \"verbose: false\", sync', testInvalidVerbose, false, invalidFalseMessage, execaSync);\ntest('Does not allow \"verbose: true\"', testInvalidVerbose, true, invalidTrueMessage, execa);\ntest('Does not allow \"verbose: true\", sync', testInvalidVerbose, true, invalidTrueMessage, execaSync);\ntest('Does not allow \"verbose: \\'unknown\\'\"', testInvalidVerbose, 'unknown', invalidUnknownMessage, execa);\ntest('Does not allow \"verbose: \\'unknown\\'\", sync', testInvalidVerbose, 'unknown', invalidUnknownMessage, execaSync);\n\nconst testValidationError = async (t, isSync) => {\n\tconst {stderr, nestedResult} = await nestedSubprocess('empty.js', {verbose: 'full', isSync, timeout: []});\n\tt.deepEqual(getNormalizedLines(stderr), [`${testTimestamp} [0] $ empty.js`]);\n\tt.true(nestedResult instanceof Error);\n};\n\ntest('Prints validation errors', testValidationError, false);\ntest('Prints validation errors, sync', testValidationError, true);\n\ntest('Prints early spawn errors', async t => {\n\tconst {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptions, verbose: 'full'});\n\tt.deepEqual(getNormalizedLines(stderr), [\n\t\t`${testTimestamp} [0] $ empty.js`,\n\t\t`${testTimestamp} [0] × Command failed with ERR_INVALID_ARG_TYPE: empty.js`,\n\t\t`${testTimestamp} [0] × The \"options.detached\" property must be of type boolean. Received type string ('true')`,\n\t\t`${testTimestamp} [0] × (done in 0ms)`,\n\t]);\n});\n\ntest('Prints early spawn errors, sync', async t => {\n\tconst {stderr} = await nestedSubprocess('empty.js', {...earlyErrorOptionsSync, verbose: 'full', isSync: true});\n\tt.deepEqual(getNormalizedLines(stderr), [\n\t\t`${testTimestamp} [0] $ empty.js`,\n\t\t`${testTimestamp} [0] × Command failed with ERR_OUT_OF_RANGE: empty.js`,\n\t\t`${testTimestamp} [0] × The value of \"options.maxBuffer\" is out of range. It must be a positive number. Received false`,\n\t\t`${testTimestamp} [0] × (done in 0ms)`,\n\t]);\n});\n"
  },
  {
    "path": "test/verbose/ipc.js",
    "content": "import {on} from 'node:events';\nimport {inspect} from 'node:util';\nimport test from 'ava';\nimport {red} from 'yoctocolors';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarObject} from '../helpers/input.js';\nimport {nestedSubprocess, nestedInstance} from '../helpers/nested.js';\nimport {\n\tgetIpcLine,\n\tgetIpcLines,\n\ttestTimestamp,\n\tipcNoneOption,\n\tipcShortOption,\n\tipcFullOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintIpc = async (t, verbose) => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', {ipc: true, verbose});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);\n};\n\ntest('Prints IPC, verbose \"full\"', testPrintIpc, 'full');\ntest('Prints IPC, verbose \"full\", fd-specific', testPrintIpc, ipcFullOption);\n\nconst testNoPrintIpc = async (t, verbose) => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', {ipc: true, verbose});\n\tt.is(getIpcLine(stderr), undefined);\n};\n\ntest('Does not print IPC, verbose default', testNoPrintIpc, undefined);\ntest('Does not print IPC, verbose \"none\"', testNoPrintIpc, 'none');\ntest('Does not print IPC, verbose \"short\"', testNoPrintIpc, 'short');\ntest('Does not print IPC, verbose default, fd-specific', testNoPrintIpc, {});\ntest('Does not print IPC, verbose \"none\", fd-specific', testNoPrintIpc, ipcNoneOption);\ntest('Does not print IPC, verbose \"short\", fd-specific', testNoPrintIpc, ipcShortOption);\n\nconst testNoIpc = async (t, ipc) => {\n\tconst {nestedResult, stderr} = await nestedSubprocess('ipc-send.js', {ipc, verbose: 'full'});\n\tt.true(nestedResult instanceof Error);\n\tt.true(nestedResult.message.includes('sendMessage() can only be used'));\n\tt.is(getIpcLine(stderr), undefined);\n};\n\ntest('Does not print IPC, ipc: false', testNoIpc, false);\ntest('Does not print IPC, ipc: default', testNoIpc, undefined);\n\ntest('Prints objects from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send-json.js', [JSON.stringify(foobarObject)], {ipc: true, verbose: 'full'});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * ${inspect(foobarObject)}`);\n});\n\ntest('Prints multiline arrays from IPC', async t => {\n\tconst bigArray = Array.from({length: 100}, (_, index) => index);\n\tconst {stderr} = await nestedSubprocess('ipc-send-json.js', [JSON.stringify(bigArray)], {ipc: true, verbose: 'full'});\n\tconst ipcLines = getIpcLines(stderr);\n\tt.is(ipcLines[0], `${testTimestamp} [0] * [`);\n\tt.is(ipcLines.at(-2), `${testTimestamp} [0] *   96, 97, 98, 99`);\n\tt.is(ipcLines.at(-1), `${testTimestamp} [0] * ]`);\n});\n\ntest('Does not quote spaces from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', ['foo bar'], {ipc: true, verbose: 'full'});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * foo bar`);\n});\n\ntest('Does not quote newlines from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', ['foo\\nbar'], {ipc: true, verbose: 'full'});\n\tt.deepEqual(getIpcLines(stderr), [\n\t\t`${testTimestamp} [0] * foo`,\n\t\t`${testTimestamp} [0] * bar`,\n\t]);\n});\n\ntest('Does not quote special punctuation from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', ['%'], {ipc: true, verbose: 'full'});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * %`);\n});\n\ntest('Does not escape internal characters from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', ['ã'], {ipc: true, verbose: 'full'});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * ã`);\n});\n\ntest('Strips color sequences from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', [red(foobarString)], {ipc: true, verbose: 'full'}, {env: {FORCE_COLOR: '1'}});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * ${foobarString}`);\n});\n\ntest('Escapes control characters from IPC', async t => {\n\tconst {stderr} = await nestedSubprocess('ipc-send.js', ['\\u0001'], {ipc: true, verbose: 'full'});\n\tt.is(getIpcLine(stderr), `${testTimestamp} [0] * \\\\u0001`);\n});\n\ntest('Prints IPC progressively', async t => {\n\tconst subprocess = nestedInstance('ipc-send-forever.js', {ipc: true, verbose: 'full'});\n\tfor await (const chunk of on(subprocess.stderr, 'data')) {\n\t\tconst ipcLine = getIpcLine(chunk.toString());\n\t\tif (ipcLine !== undefined) {\n\t\t\tt.is(ipcLine, `${testTimestamp} [0] * ${foobarString}`);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsubprocess.kill();\n\tawait t.throwsAsync(subprocess);\n});\n"
  },
  {
    "path": "test/verbose/log.js",
    "content": "import {stripVTControlCharacters} from 'node:util';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {getNormalizedLines, getCommandLine, getCompletionLine} from '../helpers/verbose.js';\nimport {PARALLEL_COUNT} from '../helpers/parallel.js';\n\nsetFixtureDirectory();\n\nconst testNoStdout = async (t, verbose, isSync) => {\n\tconst {stdout} = await nestedSubprocess('noop.js', [foobarString], {verbose, stdio: 'inherit', isSync});\n\tt.is(stdout, foobarString);\n};\n\ntest('Logs on stderr not stdout, verbose \"none\"', testNoStdout, 'none', false);\ntest('Logs on stderr not stdout, verbose \"short\"', testNoStdout, 'short', false);\ntest('Logs on stderr not stdout, verbose \"full\"', testNoStdout, 'full', false);\ntest('Logs on stderr not stdout, verbose \"none\", sync', testNoStdout, 'none', true);\ntest('Logs on stderr not stdout, verbose \"short\", sync', testNoStdout, 'short', true);\ntest('Logs on stderr not stdout, verbose \"full\", sync', testNoStdout, 'full', true);\n\nconst testColor = async (t, expectedResult, forceColor) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'short'}, {env: {FORCE_COLOR: forceColor}});\n\tt.is(stderr !== stripVTControlCharacters(stderr), expectedResult);\n};\n\ntest('Prints with colors if supported', testColor, true, '1');\ntest('Prints without colors if not supported', testColor, false, '0');\n\ntest.serial('Prints lines in order when interleaved with subprocess stderr', async t => {\n\tconst results = await Promise.all(Array.from({length: PARALLEL_COUNT}, () =>\n\t\tnestedSubprocess('noop-fd.js', ['2', `${foobarString}\\n`], {verbose: 'full', stderr: 'inherit'}, {all: true}),\n\t));\n\tfor (const {all} of results) {\n\t\tt.deepEqual(\n\t\t\tgetNormalizedLines(all),\n\t\t\t[getCommandLine(all), foobarString, getCompletionLine(all)],\n\t\t);\n\t}\n});\n"
  },
  {
    "path": "test/verbose/output-buffer.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUppercase} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\tgetOutputLine,\n\ttestTimestamp,\n\tstdoutNoneOption,\n\tstdoutFullOption,\n\tstderrFullOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintOutputNoBuffer = async (t, verbose, buffer, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, buffer, isSync});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n};\n\ntest('Prints stdout, buffer: false', testPrintOutputNoBuffer, 'full', false, false);\ntest('Prints stdout, buffer: false, fd-specific buffer', testPrintOutputNoBuffer, 'full', {stdout: false}, false);\ntest('Prints stdout, buffer: false, fd-specific verbose', testPrintOutputNoBuffer, stdoutFullOption, false, false);\ntest('Prints stdout, buffer: false, sync', testPrintOutputNoBuffer, 'full', false, true);\ntest('Prints stdout, buffer: false, fd-specific buffer, sync', testPrintOutputNoBuffer, 'full', {stdout: false}, true);\ntest('Prints stdout, buffer: false, fd-specific verbose, sync', testPrintOutputNoBuffer, stdoutFullOption, false, true);\n\nconst testPrintOutputNoBufferFalse = async (t, verbose, buffer, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, buffer, isSync});\n\tt.is(getOutputLine(stderr), undefined);\n};\n\ntest('Does not print stdout, buffer: false, fd-specific none', testPrintOutputNoBufferFalse, stdoutNoneOption, false, false);\ntest('Does not print stdout, buffer: false, different fd', testPrintOutputNoBufferFalse, stderrFullOption, false, false);\ntest('Does not print stdout, buffer: false, different fd, fd-specific buffer', testPrintOutputNoBufferFalse, stderrFullOption, {stdout: false}, false);\ntest('Does not print stdout, buffer: false, fd-specific none, sync', testPrintOutputNoBufferFalse, stdoutNoneOption, false, true);\ntest('Does not print stdout, buffer: false, different fd, sync', testPrintOutputNoBufferFalse, stderrFullOption, false, true);\ntest('Does not print stdout, buffer: false, different fd, fd-specific buffer, sync', testPrintOutputNoBufferFalse, stderrFullOption, {stdout: false}, true);\n\nconst testPrintOutputNoBufferTransform = async (t, buffer, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\toptionsFixture: 'generator-uppercase.js',\n\t\tverbose: 'full',\n\t\tbuffer,\n\t\tisSync,\n\t});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarUppercase}`);\n};\n\ntest('Prints stdout, buffer: false, transform', testPrintOutputNoBufferTransform, false, false);\ntest('Prints stdout, buffer: false, transform, fd-specific buffer', testPrintOutputNoBufferTransform, {stdout: false}, false);\ntest('Prints stdout, buffer: false, transform, sync', testPrintOutputNoBufferTransform, false, true);\ntest('Prints stdout, buffer: false, transform, fd-specific buffer, sync', testPrintOutputNoBufferTransform, {stdout: false}, true);\n"
  },
  {
    "path": "test/verbose/output-enable.js",
    "content": "import test from 'ava';\nimport {red} from 'yoctocolors';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarUtf16Uint8Array} from '../helpers/input.js';\nimport {fullStdio} from '../helpers/stdio.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\trunErrorSubprocess,\n\tgetOutputLine,\n\tgetOutputLines,\n\ttestTimestamp,\n\tstdoutNoneOption,\n\tstdoutShortOption,\n\tstdoutFullOption,\n\tstderrNoneOption,\n\tstderrShortOption,\n\tstderrFullOption,\n\tfd3NoneOption,\n\tfd3ShortOption,\n\tfd3FullOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintOutput = async (t, verbose, fdNumber, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop-fd.js', [`${fdNumber}`, foobarString], {verbose, isSync});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n};\n\ntest('Prints stdout, verbose \"full\"', testPrintOutput, 'full', 1, false);\ntest('Prints stderr, verbose \"full\"', testPrintOutput, 'full', 2, false);\ntest('Prints stdout, verbose \"full\", fd-specific', testPrintOutput, stdoutFullOption, 1, false);\ntest('Prints stderr, verbose \"full\", fd-specific', testPrintOutput, stderrFullOption, 2, false);\ntest('Prints stdout, verbose \"full\", sync', testPrintOutput, 'full', 1, true);\ntest('Prints stderr, verbose \"full\", sync', testPrintOutput, 'full', 2, true);\ntest('Prints stdout, verbose \"full\", fd-specific, sync', testPrintOutput, stdoutFullOption, 1, true);\ntest('Prints stderr, verbose \"full\", fd-specific, sync', testPrintOutput, stderrFullOption, 2, true);\n\nconst testNoPrintOutput = async (t, verbose, fdNumber, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop-fd.js', [`${fdNumber}`, foobarString], {verbose, ...fullStdio, isSync});\n\tt.is(getOutputLine(stderr), undefined);\n};\n\ntest('Does not print stdout, verbose default', testNoPrintOutput, undefined, 1, false);\ntest('Does not print stdout, verbose \"none\"', testNoPrintOutput, 'none', 1, false);\ntest('Does not print stdout, verbose \"short\"', testNoPrintOutput, 'short', 1, false);\ntest('Does not print stderr, verbose default', testNoPrintOutput, undefined, 2, false);\ntest('Does not print stderr, verbose \"none\"', testNoPrintOutput, 'none', 2, false);\ntest('Does not print stderr, verbose \"short\"', testNoPrintOutput, 'short', 2, false);\ntest('Does not print stdio[*], verbose default', testNoPrintOutput, undefined, 3, false);\ntest('Does not print stdio[*], verbose \"none\"', testNoPrintOutput, 'none', 3, false);\ntest('Does not print stdio[*], verbose \"short\"', testNoPrintOutput, 'short', 3, false);\ntest('Does not print stdio[*], verbose \"full\"', testNoPrintOutput, 'full', 3, false);\ntest('Does not print stdout, verbose default, fd-specific', testNoPrintOutput, {}, 1, false);\ntest('Does not print stdout, verbose \"none\", fd-specific', testNoPrintOutput, stdoutNoneOption, 1, false);\ntest('Does not print stdout, verbose \"short\", fd-specific', testNoPrintOutput, stdoutShortOption, 1, false);\ntest('Does not print stderr, verbose default, fd-specific', testNoPrintOutput, {}, 2, false);\ntest('Does not print stderr, verbose \"none\", fd-specific', testNoPrintOutput, stderrNoneOption, 2, false);\ntest('Does not print stderr, verbose \"short\", fd-specific', testNoPrintOutput, stderrShortOption, 2, false);\ntest('Does not print stdio[*], verbose default, fd-specific', testNoPrintOutput, {}, 3, false);\ntest('Does not print stdio[*], verbose \"none\", fd-specific', testNoPrintOutput, fd3NoneOption, 3, false);\ntest('Does not print stdio[*], verbose \"short\", fd-specific', testNoPrintOutput, fd3ShortOption, 3, false);\ntest('Does not print stdio[*], verbose \"full\", fd-specific', testNoPrintOutput, fd3FullOption, 3, false);\ntest('Does not print stdout, verbose default, sync', testNoPrintOutput, undefined, 1, true);\ntest('Does not print stdout, verbose \"none\", sync', testNoPrintOutput, 'none', 1, true);\ntest('Does not print stdout, verbose \"short\", sync', testNoPrintOutput, 'short', 1, true);\ntest('Does not print stderr, verbose default, sync', testNoPrintOutput, undefined, 2, true);\ntest('Does not print stderr, verbose \"none\", sync', testNoPrintOutput, 'none', 2, true);\ntest('Does not print stderr, verbose \"short\", sync', testNoPrintOutput, 'short', 2, true);\ntest('Does not print stdio[*], verbose default, sync', testNoPrintOutput, undefined, 3, true);\ntest('Does not print stdio[*], verbose \"none\", sync', testNoPrintOutput, 'none', 3, true);\ntest('Does not print stdio[*], verbose \"short\", sync', testNoPrintOutput, 'short', 3, true);\ntest('Does not print stdio[*], verbose \"full\", sync', testNoPrintOutput, 'full', 3, true);\ntest('Does not print stdout, verbose default, fd-specific, sync', testNoPrintOutput, {}, 1, true);\ntest('Does not print stdout, verbose \"none\", fd-specific, sync', testNoPrintOutput, stdoutNoneOption, 1, true);\ntest('Does not print stdout, verbose \"short\", fd-specific, sync', testNoPrintOutput, stdoutShortOption, 1, true);\ntest('Does not print stderr, verbose default, fd-specific, sync', testNoPrintOutput, {}, 2, true);\ntest('Does not print stderr, verbose \"none\", fd-specific, sync', testNoPrintOutput, stderrNoneOption, 2, true);\ntest('Does not print stderr, verbose \"short\", fd-specific, sync', testNoPrintOutput, stderrShortOption, 2, true);\ntest('Does not print stdio[*], verbose default, fd-specific, sync', testNoPrintOutput, {}, 3, true);\ntest('Does not print stdio[*], verbose \"none\", fd-specific, sync', testNoPrintOutput, fd3NoneOption, 3, true);\ntest('Does not print stdio[*], verbose \"short\", fd-specific, sync', testNoPrintOutput, fd3ShortOption, 3, true);\ntest('Does not print stdio[*], verbose \"full\", fd-specific, sync', testNoPrintOutput, fd3FullOption, 3, true);\n\nconst testPrintError = async (t, isSync) => {\n\tconst stderr = await runErrorSubprocess(t, 'full', isSync);\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n};\n\ntest('Prints stdout after errors', testPrintError, false);\ntest('Prints stdout after errors, sync', testPrintError, true);\n\ntest('Does not quote spaces from stdout', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['foo bar'], {verbose: 'full'});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   foo bar`);\n});\n\ntest('Does not quote special punctuation from stdout', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['%'], {verbose: 'full'});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   %`);\n});\n\ntest('Does not escape internal characters from stdout', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['ã'], {verbose: 'full'});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ã`);\n});\n\ntest('Strips color sequences from stdout', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [red(foobarString)], {verbose: 'full'}, {env: {FORCE_COLOR: '1'}});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n});\n\ntest('Escapes control characters from stdout', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['\\u0001'], {verbose: 'full'});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   \\\\u0001`);\n});\n\nconst testStdioSame = async (t, fdNumber) => {\n\tconst {nestedResult: {stdio}} = await nestedSubprocess('noop-fd.js', [`${fdNumber}`, foobarString], {verbose: 'full'});\n\tt.is(stdio[fdNumber], foobarString);\n};\n\ntest('Does not change subprocess.stdout', testStdioSame, 1);\ntest('Does not change subprocess.stderr', testStdioSame, 2);\n\nconst testSingleNewline = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop-fd.js', ['1', '\\n'], {verbose: 'full', isSync});\n\tt.deepEqual(getOutputLines(stderr), [`${testTimestamp} [0]   `]);\n};\n\ntest('Prints stdout, single newline', testSingleNewline, false);\ntest('Prints stdout, single newline, sync', testSingleNewline, true);\n\nconst testUtf16 = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('stdin.js', {\n\t\tverbose: 'full',\n\t\tinput: foobarUtf16Uint8Array,\n\t\tencoding: 'utf16le',\n\t\tisSync,\n\t});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n};\n\ntest('Can use encoding UTF16, verbose \"full\"', testUtf16, false);\ntest('Can use encoding UTF16, verbose \"full\", sync', testUtf16, true);\n"
  },
  {
    "path": "test/verbose/output-mixed.js",
    "content": "import {inspect} from 'node:util';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString, foobarObject} from '../helpers/input.js';\nimport {simpleFull, noNewlinesChunks} from '../helpers/lines.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {getOutputLine, getOutputLines, testTimestamp} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testLines = async (t, lines, stripFinalNewline, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop-fd.js', ['1', simpleFull], {\n\t\tverbose: 'full',\n\t\tlines,\n\t\tstripFinalNewline,\n\t\tisSync,\n\t});\n\tt.deepEqual(getOutputLines(stderr), noNewlinesChunks.map(line => `${testTimestamp} [0]   ${line}`));\n};\n\ntest('Prints stdout, \"lines: true\"', testLines, true, false, false);\ntest('Prints stdout, \"lines: true\", fd-specific', testLines, {stdout: true}, false, false);\ntest('Prints stdout, \"lines: true\", stripFinalNewline', testLines, true, true, false);\ntest('Prints stdout, \"lines: true\", sync', testLines, true, false, true);\ntest('Prints stdout, \"lines: true\", fd-specific, sync', testLines, {stdout: true}, false, true);\ntest('Prints stdout, \"lines: true\", stripFinalNewline, sync', testLines, true, true, true);\n\nconst testOnlyTransforms = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\toptionsFixture: 'generator-uppercase.js',\n\t\tverbose: 'full',\n\t\tisSync,\n\t});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString.toUpperCase()}`);\n};\n\ntest('Prints stdout with only transforms', testOnlyTransforms, false);\ntest('Prints stdout with only transforms, sync', testOnlyTransforms, true);\n\ntest('Prints stdout with only duplexes', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\toptionsFixture: 'generator-duplex.js',\n\t\tverbose: 'full',\n\t});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString.toUpperCase()}`);\n});\n\nconst testObjectMode = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', {\n\t\toptionsFixture: 'generator-object.js',\n\t\tverbose: 'full',\n\t\tisSync,\n\t});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${inspect(foobarObject)}`);\n};\n\ntest('Prints stdout with object transforms', testObjectMode, false);\ntest('Prints stdout with object transforms, sync', testObjectMode, true);\n\nconst testBigArray = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', {\n\t\toptionsFixture: 'generator-big-array.js',\n\t\tverbose: 'full',\n\t\tisSync,\n\t});\n\tconst lines = getOutputLines(stderr);\n\tt.is(lines[0], `${testTimestamp} [0]   [`);\n\tt.true(lines[1].startsWith(`${testTimestamp} [0]      0,  1,`));\n\tt.is(lines.at(-1), `${testTimestamp} [0]   ]`);\n};\n\ntest('Prints stdout with big object transforms', testBigArray, false);\ntest('Prints stdout with big object transforms, sync', testBigArray, true);\n\nconst testObjectModeString = async (t, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', {\n\t\toptionsFixture: 'generator-string-object.js',\n\t\tverbose: 'full',\n\t\tisSync,\n\t});\n\tt.deepEqual(getOutputLines(stderr), noNewlinesChunks.map(line => `${testTimestamp} [0]   ${line}`));\n};\n\ntest('Prints stdout with string transforms in objectMode', testObjectModeString, false);\ntest('Prints stdout with string transforms in objectMode, sync', testObjectModeString, true);\n"
  },
  {
    "path": "test/verbose/output-noop.js",
    "content": "import {rm, readFile} from 'node:fs/promises';\nimport test from 'ava';\nimport tempfile from 'tempfile';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {getOutputLine, testTimestamp} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testNoOutputOptions = async (t, isSync, options) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'full', isSync, ...options});\n\tt.is(getOutputLine(stderr), undefined);\n};\n\ntest('Does not print stdout, encoding \"buffer\"', testNoOutputOptions, false, {encoding: 'buffer'});\ntest('Does not print stdout, encoding \"hex\"', testNoOutputOptions, false, {encoding: 'hex'});\ntest('Does not print stdout, encoding \"base64\"', testNoOutputOptions, false, {encoding: 'base64'});\ntest('Does not print stdout, stdout \"ignore\"', testNoOutputOptions, false, {stdout: 'ignore'});\ntest('Does not print stdout, stdout \"inherit\"', testNoOutputOptions, false, {stdout: 'inherit'});\ntest('Does not print stdout, stdout 1', testNoOutputOptions, false, {stdout: 1});\ntest('Does not print stdout, encoding \"buffer\", sync', testNoOutputOptions, true, {encoding: 'buffer'});\ntest('Does not print stdout, encoding \"hex\", sync', testNoOutputOptions, true, {encoding: 'hex'});\ntest('Does not print stdout, encoding \"base64\", sync', testNoOutputOptions, true, {encoding: 'base64'});\ntest('Does not print stdout, stdout \"ignore\", sync', testNoOutputOptions, true, {stdout: 'ignore'});\ntest('Does not print stdout, stdout \"inherit\", sync', testNoOutputOptions, true, {stdout: 'inherit'});\ntest('Does not print stdout, stdout 1, sync', testNoOutputOptions, true, {stdout: 1});\n\nconst testNoOutputDynamic = async (t, isSync, optionsFixture) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'full', isSync, optionsFixture});\n\tt.is(getOutputLine(stderr), undefined);\n};\n\ntest('Does not print stdout, stdout Writable', testNoOutputDynamic, false, 'writable.js');\ntest('Does not print stdout, stdout WritableStream', testNoOutputDynamic, false, 'writable-web.js');\ntest('Does not print stdout, stdout Writable, sync', testNoOutputDynamic, true, 'writable.js');\ntest('Does not print stdout, stdout WritableStream, sync', testNoOutputDynamic, true, 'writable-web.js');\n\nconst testNoOutputStream = async (t, parentFixture) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'full', parentFixture});\n\tt.is(getOutputLine(stderr), undefined);\n};\n\ntest('Does not print stdout, .pipe(stream)', testNoOutputStream, 'nested-pipe-stream.js');\ntest('Does not print stdout, .pipe(subprocess)', testNoOutputStream, 'nested-pipe-subprocess.js');\n\nconst testStdoutFile = async (t, isSync, optionsFixture) => {\n\tconst file = tempfile();\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\tverbose: 'full',\n\t\tstdout: {file},\n\t\tisSync,\n\t\toptionsFixture,\n\t});\n\tt.is(getOutputLine(stderr), undefined);\n\tconst contents = await readFile(file, 'utf8');\n\tt.is(contents.trim(), foobarString);\n\tawait rm(file);\n};\n\ntest('Does not print stdout, stdout { file }', testStdoutFile, false);\ntest('Does not print stdout, stdout fileUrl', testStdoutFile, false, 'file-url.js');\ntest('Does not print stdout, stdout { file }, sync', testStdoutFile, true);\ntest('Does not print stdout, stdout fileUrl, sync', testStdoutFile, true, 'file-url.js');\n\nconst testPrintOutputOptions = async (t, options, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose: 'full', isSync, ...options});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n};\n\ntest('Prints stdout, stdout \"pipe\"', testPrintOutputOptions, {stdout: 'pipe'}, false);\ntest('Prints stdout, stdout \"overlapped\"', testPrintOutputOptions, {stdout: 'overlapped'}, false);\ntest('Prints stdout, stdout null', testPrintOutputOptions, {stdout: null}, false);\ntest('Prints stdout, stdout [\"pipe\"]', testPrintOutputOptions, {stdout: ['pipe']}, false);\ntest('Prints stdout, stdout \"pipe\", sync', testPrintOutputOptions, {stdout: 'pipe'}, true);\ntest('Prints stdout, stdout null, sync', testPrintOutputOptions, {stdout: null}, true);\ntest('Prints stdout, stdout [\"pipe\"], sync', testPrintOutputOptions, {stdout: ['pipe']}, true);\n"
  },
  {
    "path": "test/verbose/output-pipe.js",
    "content": "import test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\tgetOutputLine,\n\tgetOutputLines,\n\ttestTimestamp,\n\tgetVerboseOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPipeOutput = async (t, parentFixture, sourceVerbose, destinationVerbose) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\tparentFixture,\n\t\tsourceOptions: getVerboseOption(sourceVerbose, 'full'),\n\t\tdestinationFile: 'stdin.js',\n\t\tdestinationOptions: getVerboseOption(destinationVerbose, 'full'),\n\t});\n\n\tconst lines = getOutputLines(stderr);\n\tconst id = sourceVerbose && destinationVerbose ? 1 : 0;\n\tt.deepEqual(lines, destinationVerbose\n\t\t? [`${testTimestamp} [${id}]   ${foobarString}`]\n\t\t: []);\n};\n\ntest('Prints stdout if both verbose with .pipe(\"file\")', testPipeOutput, 'nested-pipe-file.js', true, true);\ntest('Prints stdout if both verbose with .pipe`command`', testPipeOutput, 'nested-pipe-script.js', true, true);\ntest('Prints stdout if both verbose with .pipe(subprocess)', testPipeOutput, 'nested-pipe-subprocesses.js', true, true);\ntest('Prints stdout if only second verbose with .pipe(\"file\")', testPipeOutput, 'nested-pipe-file.js', false, true);\ntest('Prints stdout if only second verbose with .pipe`command`', testPipeOutput, 'nested-pipe-script.js', false, true);\ntest('Prints stdout if only second verbose with .pipe(subprocess)', testPipeOutput, 'nested-pipe-subprocesses.js', false, true);\ntest('Does not print stdout if only first verbose with .pipe(\"file\")', testPipeOutput, 'nested-pipe-file.js', true, false);\ntest('Does not print stdout if only first verbose with .pipe`command`', testPipeOutput, 'nested-pipe-script.js', true, false);\ntest('Does not print stdout if only first verbose with .pipe(subprocess)', testPipeOutput, 'nested-pipe-subprocesses.js', true, false);\ntest('Does not print stdout if neither verbose with .pipe(\"file\")', testPipeOutput, 'nested-pipe-file.js', false, false);\ntest('Does not print stdout if neither verbose with .pipe`command`', testPipeOutput, 'nested-pipe-script.js', false, false);\ntest('Does not print stdout if neither verbose with .pipe(subprocess)', testPipeOutput, 'nested-pipe-subprocesses.js', false, false);\n\nconst testPrintOutputFixture = async (t, parentFixture) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {parentFixture, verbose: 'full', unpipe: true});\n\tt.is(getOutputLine(stderr), `${testTimestamp} [0]   ${foobarString}`);\n};\n\ntest('Prints stdout, .pipe(stream) + .unpipe()', testPrintOutputFixture, 'nested-pipe-stream.js');\ntest('Prints stdout, .pipe(subprocess) + .unpipe()', testPrintOutputFixture, 'nested-pipe-subprocess.js');\n"
  },
  {
    "path": "test/verbose/output-progressive.js",
    "content": "import {on} from 'node:events';\nimport test from 'ava';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess, nestedInstance} from '../helpers/nested.js';\nimport {getOutputLine, getOutputLines, testTimestamp} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\ntest('Prints stdout one line at a time', async t => {\n\tconst subprocess = nestedInstance('noop-progressive.js', [foobarString], {verbose: 'full'});\n\n\tfor await (const chunk of on(subprocess.stderr, 'data')) {\n\t\tconst outputLine = getOutputLine(chunk.toString().trim());\n\t\tif (outputLine !== undefined) {\n\t\t\tt.is(outputLine, `${testTimestamp} [0]   ${foobarString}`);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tawait subprocess;\n});\n\ntest.serial('Prints stdout progressively, interleaved', async t => {\n\tconst subprocess = nestedInstance('noop-repeat.js', ['1', `${foobarString}\\n`], {parentFixture: 'nested-double.js', verbose: 'full'});\n\n\tlet firstSubprocessPrinted = false;\n\tlet secondSubprocessPrinted = false;\n\tfor await (const chunk of on(subprocess.stderr, 'data')) {\n\t\tconst outputLine = getOutputLine(chunk.toString().trim());\n\t\tif (outputLine === undefined) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (outputLine.includes(foobarString)) {\n\t\t\tt.is(outputLine, `${testTimestamp} [0]   ${foobarString}`);\n\t\t\tfirstSubprocessPrinted ||= true;\n\t\t} else {\n\t\t\tt.is(outputLine, `${testTimestamp} [1]   ${foobarString.toUpperCase()}`);\n\t\t\tsecondSubprocessPrinted ||= true;\n\t\t}\n\n\t\tif (firstSubprocessPrinted && secondSubprocessPrinted) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tsubprocess.kill();\n\tawait t.throwsAsync(subprocess);\n});\n\nconst testInterleaved = async (t, expectedLines, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop-132.js', {verbose: 'full', isSync});\n\tt.deepEqual(getOutputLines(stderr), expectedLines.map(line => `${testTimestamp} [0]   ${line}`));\n};\n\ntest('Prints stdout + stderr interleaved', testInterleaved, [1, 2, 3], false);\ntest('Prints stdout + stderr not interleaved, sync', testInterleaved, [1, 3, 2], true);\n"
  },
  {
    "path": "test/verbose/start.js",
    "content": "import test from 'ava';\nimport {red} from 'yoctocolors';\nimport {setFixtureDirectory} from '../helpers/fixtures-directory.js';\nimport {foobarString} from '../helpers/input.js';\nimport {nestedSubprocess} from '../helpers/nested.js';\nimport {\n\tQUOTE,\n\trunErrorSubprocess,\n\trunEarlyErrorSubprocess,\n\tgetCommandLine,\n\tgetCommandLines,\n\ttestTimestamp,\n\tgetVerboseOption,\n\tstdoutNoneOption,\n\tstdoutShortOption,\n\tstdoutFullOption,\n\tstderrNoneOption,\n\tstderrShortOption,\n\tstderrFullOption,\n\tfd3NoneOption,\n\tfd3ShortOption,\n\tfd3FullOption,\n\tipcNoneOption,\n\tipcShortOption,\n\tipcFullOption,\n} from '../helpers/verbose.js';\n\nsetFixtureDirectory();\n\nconst testPrintCommand = async (t, verbose, worker, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, worker, isSync});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);\n};\n\ntest('Prints command, verbose \"short\"', testPrintCommand, 'short', false, false);\ntest('Prints command, verbose \"full\"', testPrintCommand, 'full', false, false);\ntest('Prints command, verbose \"short\", fd-specific stdout', testPrintCommand, stdoutShortOption, false, false);\ntest('Prints command, verbose \"full\", fd-specific stdout', testPrintCommand, stdoutFullOption, false, false);\ntest('Prints command, verbose \"short\", fd-specific stderr', testPrintCommand, stderrShortOption, false, false);\ntest('Prints command, verbose \"full\", fd-specific stderr', testPrintCommand, stderrFullOption, false, false);\ntest('Prints command, verbose \"short\", fd-specific fd3', testPrintCommand, fd3ShortOption, false, false);\ntest('Prints command, verbose \"full\", fd-specific fd3', testPrintCommand, fd3FullOption, false, false);\ntest('Prints command, verbose \"short\", fd-specific ipc', testPrintCommand, ipcShortOption, false, false);\ntest('Prints command, verbose \"full\", fd-specific ipc', testPrintCommand, ipcFullOption, false, false);\ntest('Prints command, verbose \"short\", sync', testPrintCommand, 'short', false, true);\ntest('Prints command, verbose \"full\", sync', testPrintCommand, 'full', false, true);\ntest('Prints command, verbose \"short\", fd-specific stdout, sync', testPrintCommand, stdoutShortOption, false, true);\ntest('Prints command, verbose \"full\", fd-specific stdout, sync', testPrintCommand, stdoutFullOption, false, true);\ntest('Prints command, verbose \"short\", fd-specific stderr, sync', testPrintCommand, stderrShortOption, false, true);\ntest('Prints command, verbose \"full\", fd-specific stderr, sync', testPrintCommand, stderrFullOption, false, true);\ntest('Prints command, verbose \"short\", fd-specific fd3, sync', testPrintCommand, fd3ShortOption, false, true);\ntest('Prints command, verbose \"full\", fd-specific fd3, sync', testPrintCommand, fd3FullOption, false, true);\ntest('Prints command, verbose \"short\", fd-specific ipc, sync', testPrintCommand, ipcShortOption, false, true);\ntest('Prints command, verbose \"full\", fd-specific ipc, sync', testPrintCommand, ipcFullOption, false, true);\ntest('Prints command, verbose \"short\", worker', testPrintCommand, 'short', true, false);\ntest('Prints command, verbose \"full\", worker', testPrintCommand, 'full', true, false);\ntest('Prints command, verbose \"short\", fd-specific stdout, worker', testPrintCommand, stdoutShortOption, true, false);\ntest('Prints command, verbose \"full\", fd-specific stdout, worker', testPrintCommand, stdoutFullOption, true, false);\ntest('Prints command, verbose \"short\", fd-specific stderr, worker', testPrintCommand, stderrShortOption, true, false);\ntest('Prints command, verbose \"full\", fd-specific stderr, worker', testPrintCommand, stderrFullOption, true, false);\ntest('Prints command, verbose \"short\", fd-specific fd3, worker', testPrintCommand, fd3ShortOption, true, false);\ntest('Prints command, verbose \"full\", fd-specific fd3, worker', testPrintCommand, fd3FullOption, true, false);\ntest('Prints command, verbose \"short\", fd-specific ipc, worker', testPrintCommand, ipcShortOption, true, false);\ntest('Prints command, verbose \"full\", fd-specific ipc, worker', testPrintCommand, ipcFullOption, true, false);\ntest('Prints command, verbose \"short\", worker, sync', testPrintCommand, 'short', true, true);\ntest('Prints command, verbose \"full\", worker, sync', testPrintCommand, 'full', true, true);\ntest('Prints command, verbose \"short\", fd-specific stdout, worker, sync', testPrintCommand, stdoutShortOption, true, true);\ntest('Prints command, verbose \"full\", fd-specific stdout, worker, sync', testPrintCommand, stdoutFullOption, true, true);\ntest('Prints command, verbose \"short\", fd-specific stderr, worker, sync', testPrintCommand, stderrShortOption, true, true);\ntest('Prints command, verbose \"full\", fd-specific stderr, worker, sync', testPrintCommand, stderrFullOption, true, true);\ntest('Prints command, verbose \"short\", fd-specific fd3, worker, sync', testPrintCommand, fd3ShortOption, true, true);\ntest('Prints command, verbose \"full\", fd-specific fd3, worker, sync', testPrintCommand, fd3FullOption, true, true);\ntest('Prints command, verbose \"short\", fd-specific ipc, worker, sync', testPrintCommand, ipcShortOption, true, true);\ntest('Prints command, verbose \"full\", fd-specific ipc, worker, sync', testPrintCommand, ipcFullOption, true, true);\n\nconst testNoPrintCommand = async (t, verbose, isSync) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {verbose, isSync});\n\tt.is(stderr, '');\n};\n\ntest('Does not print command, verbose \"none\"', testNoPrintCommand, 'none', false);\ntest('Does not print command, verbose default', testNoPrintCommand, undefined, false);\ntest('Does not print command, verbose \"none\", fd-specific stdout', testNoPrintCommand, stdoutNoneOption, false);\ntest('Does not print command, verbose \"none\", fd-specific stderr', testNoPrintCommand, stderrNoneOption, false);\ntest('Does not print command, verbose \"none\", fd-specific fd3', testNoPrintCommand, fd3NoneOption, false);\ntest('Does not print command, verbose \"none\", fd-specific ipc', testNoPrintCommand, ipcNoneOption, false);\ntest('Does not print command, verbose default, fd-specific', testNoPrintCommand, {}, false);\ntest('Does not print command, verbose \"none\", sync', testNoPrintCommand, 'none', true);\ntest('Does not print command, verbose default, sync', testNoPrintCommand, undefined, true);\ntest('Does not print command, verbose \"none\", fd-specific stdout, sync', testNoPrintCommand, stdoutNoneOption, true);\ntest('Does not print command, verbose \"none\", fd-specific stderr, sync', testNoPrintCommand, stderrNoneOption, true);\ntest('Does not print command, verbose \"none\", fd-specific fd3, sync', testNoPrintCommand, fd3NoneOption, true);\ntest('Does not print command, verbose \"none\", fd-specific ipc, sync', testNoPrintCommand, ipcNoneOption, true);\ntest('Does not print command, verbose default, fd-specific, sync', testNoPrintCommand, {}, true);\n\nconst testPrintCommandError = async (t, isSync) => {\n\tconst stderr = await runErrorSubprocess(t, 'short', isSync);\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop-fail.js 1 ${foobarString}`);\n};\n\ntest('Prints command after errors', testPrintCommandError, false);\ntest('Prints command after errors, sync', testPrintCommandError, true);\n\nconst testPrintCommandEarly = async (t, isSync) => {\n\tconst stderr = await runEarlyErrorSubprocess(t, isSync);\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${foobarString}`);\n};\n\ntest('Prints command before early validation errors', testPrintCommandEarly, false);\ntest('Prints command before early validation errors, sync', testPrintCommandEarly, true);\n\nconst testPipeCommand = async (t, parentFixture, sourceVerbose, destinationVerbose) => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [foobarString], {\n\t\tparentFixture,\n\t\tsourceOptions: getVerboseOption(sourceVerbose),\n\t\tdestinationFile: 'stdin.js',\n\t\tdestinationOptions: getVerboseOption(destinationVerbose),\n\t});\n\n\tconst pipeSymbol = parentFixture === 'nested-pipe-subprocesses.js' ? '$' : '|';\n\tconst lines = getCommandLines(stderr);\n\tt.is(lines.includes(`${testTimestamp} [0] $ noop.js ${foobarString}`), sourceVerbose);\n\tt.is(lines.includes(`${testTimestamp} [${sourceVerbose ? 1 : 0}] ${pipeSymbol} stdin.js`), destinationVerbose);\n};\n\ntest('Prints both commands piped with .pipe(\"file\")', testPipeCommand, 'nested-pipe-file.js', true, true);\ntest('Prints both commands piped with .pipe`command`', testPipeCommand, 'nested-pipe-script.js', true, true);\ntest('Prints both commands piped with .pipe(subprocess)', testPipeCommand, 'nested-pipe-subprocesses.js', true, true);\ntest('Prints first command piped with .pipe(\"file\")', testPipeCommand, 'nested-pipe-file.js', true, false);\ntest('Prints first command piped with .pipe`command`', testPipeCommand, 'nested-pipe-script.js', true, false);\ntest('Prints first command piped with .pipe(subprocess)', testPipeCommand, 'nested-pipe-subprocesses.js', true, false);\ntest('Prints second command piped with .pipe(\"file\")', testPipeCommand, 'nested-pipe-file.js', false, true);\ntest('Prints second command piped with .pipe`command`', testPipeCommand, 'nested-pipe-script.js', false, true);\ntest('Prints second command piped with .pipe(subprocess)', testPipeCommand, 'nested-pipe-subprocesses.js', false, true);\ntest('Prints neither commands piped with .pipe(\"file\")', testPipeCommand, 'nested-pipe-file.js', false, false);\ntest('Prints neither commands piped with .pipe`command`', testPipeCommand, 'nested-pipe-script.js', false, false);\ntest('Prints neither commands piped with .pipe(subprocess)', testPipeCommand, 'nested-pipe-subprocesses.js', false, false);\n\ntest('Quotes spaces from command', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['foo bar'], {verbose: 'short'});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${QUOTE}foo bar${QUOTE}`);\n});\n\ntest('Quotes special punctuation from command', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['%'], {verbose: 'short'});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${QUOTE}%${QUOTE}`);\n});\n\ntest('Does not escape internal characters from command', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['ã'], {verbose: 'short'});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${QUOTE}ã${QUOTE}`);\n});\n\ntest('Escapes color sequences from command', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', [red(foobarString)], {verbose: 'short'}, {env: {FORCE_COLOR: '1'}});\n\tt.true(getCommandLine(stderr).includes(`${QUOTE}\\\\u001b[31m${foobarString}\\\\u001b[39m${QUOTE}`));\n});\n\ntest('Escapes control characters from command', async t => {\n\tconst {stderr} = await nestedSubprocess('noop.js', ['\\u0001'], {verbose: 'short'});\n\tt.is(getCommandLine(stderr), `${testTimestamp} [0] $ noop.js ${QUOTE}\\\\u0001${QUOTE}`);\n});\n"
  },
  {
    "path": "test-d/arguments/encoding-option.test-d.ts",
    "content": "import {expectError} from 'tsd';\nimport {execa, execaSync} from '../../index.js';\n\nawait execa('unicorns', {encoding: 'utf8'});\nexecaSync('unicorns', {encoding: 'utf8'});\n/* eslint-disable unicorn/text-encoding-identifier-case */\nexpectError(await execa('unicorns', {encoding: 'utf-8'}));\nexpectError(execaSync('unicorns', {encoding: 'utf-8'}));\nexpectError(await execa('unicorns', {encoding: 'UTF8'}));\nexpectError(execaSync('unicorns', {encoding: 'UTF8'}));\n/* eslint-enable unicorn/text-encoding-identifier-case */\n\nawait execa('unicorns', {encoding: 'utf16le'});\nexecaSync('unicorns', {encoding: 'utf16le'});\nexpectError(await execa('unicorns', {encoding: 'utf-16le'}));\nexpectError(execaSync('unicorns', {encoding: 'utf-16le'}));\nexpectError(await execa('unicorns', {encoding: 'ucs2'}));\nexpectError(execaSync('unicorns', {encoding: 'ucs2'}));\nexpectError(await execa('unicorns', {encoding: 'ucs-2'}));\nexpectError(execaSync('unicorns', {encoding: 'ucs-2'}));\n\nawait execa('unicorns', {encoding: 'buffer'});\nexecaSync('unicorns', {encoding: 'buffer'});\nexpectError(await execa('unicorns', {encoding: null}));\nexpectError(execaSync('unicorns', {encoding: null}));\n\nawait execa('unicorns', {encoding: 'hex'});\nexecaSync('unicorns', {encoding: 'hex'});\n\nawait execa('unicorns', {encoding: 'base64'});\nexecaSync('unicorns', {encoding: 'base64'});\n\nawait execa('unicorns', {encoding: 'base64url'});\nexecaSync('unicorns', {encoding: 'base64url'});\n\nawait execa('unicorns', {encoding: 'latin1'});\nexecaSync('unicorns', {encoding: 'latin1'});\nexpectError(await execa('unicorns', {encoding: 'binary'}));\nexpectError(execaSync('unicorns', {encoding: 'binary'}));\n\nawait execa('unicorns', {encoding: 'ascii'});\nexecaSync('unicorns', {encoding: 'ascii'});\n\nexpectError(await execa('unicorns', {encoding: 'utf8' as string}));\nexpectError(execaSync('unicorns', {encoding: 'utf8' as string}));\n\nexpectError(await execa('unicorns', {encoding: 'unknownEncoding'}));\nexpectError(execaSync('unicorns', {encoding: 'unknownEncoding'}));\n"
  },
  {
    "path": "test-d/arguments/env.test-d.ts",
    "content": "import process, {type env} from 'node:process';\nimport {expectType, expectAssignable} from 'tsd';\nimport {execa, type Options, type Result} from '../../index.js';\n\ntype NodeEnv = 'production' | 'development' | 'test';\n\n// Libraries like Next.js or Remix do the following type augmentation.\n// The following type tests ensure this works with Execa.\n// See https://github.com/sindresorhus/execa/pull/1141 and https://github.com/sindresorhus/execa/issues/1132\ndeclare global {\n\t// eslint-disable-next-line @typescript-eslint/no-namespace\n\tnamespace NodeJS {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-definitions\n\t\tinterface ProcessEnv {\n\t\t\treadonly NODE_ENV: NodeEnv;\n\t\t}\n\t}\n}\n\n// The global types are impacted\nexpectType<NodeEnv>(process.env.NODE_ENV);\nexpectType<NodeEnv>('' as (typeof env)['NODE_ENV']);\nexpectType<NodeEnv>('' as NodeJS.ProcessEnv['NODE_ENV']);\nexpectType<NodeEnv>('' as globalThis.NodeJS.ProcessEnv['NODE_ENV']);\n\n// But Execa's types are not impacted\nexpectType<string | undefined>('' as Exclude<Options['env'], undefined>['NODE_ENV']);\nexpectAssignable<Result>(await execa({env: {test: 'example'}})`unicorns`);\nexpectAssignable<Result>(await execa({env: {test: 'example'} as const})`unicorns`);\nexpectAssignable<Result>(await execa({env: {test: undefined}})`unicorns`);\nexpectAssignable<Result>(await execa({env: {test: undefined} as const})`unicorns`);\n"
  },
  {
    "path": "test-d/arguments/options.test-d.ts",
    "content": "import * as process from 'node:process';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype Options,\n\ttype SyncOptions,\n} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\n\nexpectAssignable<Options>({preferLocal: false});\nexpectAssignable<Options>({cleanup: false});\nexpectNotAssignable<Options>({other: false});\nexpectAssignable<SyncOptions>({preferLocal: false});\nexpectNotAssignable<SyncOptions>({cleanup: false});\nexpectNotAssignable<SyncOptions>({other: false});\n\nawait execa('unicorns', {preferLocal: false});\nexecaSync('unicorns', {preferLocal: false});\nawait execa('unicorns', {preferLocal: false as boolean});\nexecaSync('unicorns', {preferLocal: false as boolean});\nexpectError(await execa('unicorns', {preferLocal: 'false'}));\nexpectError(execaSync('unicorns', {preferLocal: 'false'}));\n\nawait execa('unicorns', {localDir: '.'});\nexecaSync('unicorns', {localDir: '.'});\nawait execa('unicorns', {localDir: '.' as string});\nexecaSync('unicorns', {localDir: '.' as string});\nawait execa('unicorns', {localDir: fileUrl});\nexecaSync('unicorns', {localDir: fileUrl});\nexpectError(await execa('unicorns', {localDir: false}));\nexpectError(execaSync('unicorns', {localDir: false}));\n\nawait execa('unicorns', {node: true});\nexecaSync('unicorns', {node: true});\nawait execa('unicorns', {node: true as boolean});\nexecaSync('unicorns', {node: true as boolean});\nexpectError(await execa('unicorns', {node: 'true'}));\nexpectError(execaSync('unicorns', {node: 'true'}));\n\nawait execa('unicorns', {nodePath: './node'});\nexecaSync('unicorns', {nodePath: './node'});\nawait execa('unicorns', {nodePath: './node' as string});\nexecaSync('unicorns', {nodePath: './node' as string});\nawait execa('unicorns', {nodePath: fileUrl});\nexecaSync('unicorns', {nodePath: fileUrl});\nexpectError(await execa('unicorns', {nodePath: false}));\nexpectError(execaSync('unicorns', {nodePath: false}));\n\nawait execa('unicorns', {nodeOptions: ['--async-stack-traces'] as const});\nexecaSync('unicorns', {nodeOptions: ['--async-stack-traces'] as const});\nawait execa('unicorns', {nodeOptions: ['--async-stack-traces'] as string[]});\nexecaSync('unicorns', {nodeOptions: ['--async-stack-traces'] as string[]});\nexpectError(await execa('unicorns', {nodeOptions: [false] as const}));\nexpectError(execaSync('unicorns', {nodeOptions: [false] as const}));\n\nawait execa('unicorns', {input: ''});\nexecaSync('unicorns', {input: ''});\nawait execa('unicorns', {input: '' as string});\nexecaSync('unicorns', {input: '' as string});\nawait execa('unicorns', {input: new Uint8Array()});\nexecaSync('unicorns', {input: new Uint8Array()});\nawait execa('unicorns', {input: process.stdin});\nexecaSync('unicorns', {input: process.stdin});\nexpectError(await execa('unicorns', {input: false}));\nexpectError(execaSync('unicorns', {input: false}));\n\nawait execa('unicorns', {inputFile: ''});\nexecaSync('unicorns', {inputFile: ''});\nawait execa('unicorns', {inputFile: '' as string});\nexecaSync('unicorns', {inputFile: '' as string});\nawait execa('unicorns', {inputFile: fileUrl});\nexecaSync('unicorns', {inputFile: fileUrl});\nexpectError(await execa('unicorns', {inputFile: false}));\nexpectError(execaSync('unicorns', {inputFile: false}));\n\nawait execa('unicorns', {lines: false});\nexecaSync('unicorns', {lines: false});\nawait execa('unicorns', {lines: false as boolean});\nexecaSync('unicorns', {lines: false as boolean});\nexpectError(await execa('unicorns', {lines: 'false'}));\nexpectError(execaSync('unicorns', {lines: 'false'}));\n\nawait execa('unicorns', {reject: false});\nexecaSync('unicorns', {reject: false});\nawait execa('unicorns', {reject: false as boolean});\nexecaSync('unicorns', {reject: false as boolean});\nexpectError(await execa('unicorns', {reject: 'false'}));\nexpectError(execaSync('unicorns', {reject: 'false'}));\n\nawait execa('unicorns', {stripFinalNewline: false});\nexecaSync('unicorns', {stripFinalNewline: false});\nawait execa('unicorns', {stripFinalNewline: false as boolean});\nexecaSync('unicorns', {stripFinalNewline: false as boolean});\nexpectError(await execa('unicorns', {stripFinalNewline: 'false'}));\nexpectError(execaSync('unicorns', {stripFinalNewline: 'false'}));\n\nawait execa('unicorns', {extendEnv: false});\nexecaSync('unicorns', {extendEnv: false});\nawait execa('unicorns', {extendEnv: false as boolean});\nexecaSync('unicorns', {extendEnv: false as boolean});\nexpectError(await execa('unicorns', {extendEnv: 'false'}));\nexpectError(execaSync('unicorns', {extendEnv: 'false'}));\n\nawait execa('unicorns', {cwd: '.'});\nexecaSync('unicorns', {cwd: '.'});\nawait execa('unicorns', {cwd: '.' as string});\nexecaSync('unicorns', {cwd: '.' as string});\nawait execa('unicorns', {cwd: fileUrl});\nexecaSync('unicorns', {cwd: fileUrl});\nexpectError(await execa('unicorns', {cwd: false}));\nexpectError(execaSync('unicorns', {cwd: false}));\n\n/* eslint-disable @typescript-eslint/naming-convention */\nawait execa('unicorns', {env: {PATH: ''}});\nexecaSync('unicorns', {env: {PATH: ''}});\nconst env: Record<string, string> = {PATH: ''};\nawait execa('unicorns', {env});\nexecaSync('unicorns', {env});\n/* eslint-enable @typescript-eslint/naming-convention */\nexpectError(await execa('unicorns', {env: false}));\nexpectError(execaSync('unicorns', {env: false}));\n\nawait execa('unicorns', {argv0: ''});\nexecaSync('unicorns', {argv0: ''});\nawait execa('unicorns', {argv0: '' as string});\nexecaSync('unicorns', {argv0: '' as string});\nexpectError(await execa('unicorns', {argv0: false}));\nexpectError(execaSync('unicorns', {argv0: false}));\n\nawait execa('unicorns', {uid: 0});\nexecaSync('unicorns', {uid: 0});\nawait execa('unicorns', {uid: 0 as number});\nexecaSync('unicorns', {uid: 0 as number});\nexpectError(await execa('unicorns', {uid: '0'}));\nexpectError(execaSync('unicorns', {uid: '0'}));\n\nawait execa('unicorns', {gid: 0});\nexecaSync('unicorns', {gid: 0});\nawait execa('unicorns', {gid: 0 as number});\nexecaSync('unicorns', {gid: 0 as number});\nexpectError(await execa('unicorns', {gid: '0'}));\nexpectError(execaSync('unicorns', {gid: '0'}));\n\nawait execa('unicorns', {shell: true});\nexecaSync('unicorns', {shell: true});\nawait execa('unicorns', {shell: true as boolean});\nexecaSync('unicorns', {shell: true as boolean});\nawait execa('unicorns', {shell: '/bin/sh'});\nexecaSync('unicorns', {shell: '/bin/sh'});\nawait execa('unicorns', {shell: '/bin/sh' as string});\nexecaSync('unicorns', {shell: '/bin/sh' as string});\nawait execa('unicorns', {shell: fileUrl});\nexecaSync('unicorns', {shell: fileUrl});\nexpectError(await execa('unicorns', {shell: {}}));\nexpectError(execaSync('unicorns', {shell: {}}));\n\nawait execa('unicorns', {timeout: 1000});\nexecaSync('unicorns', {timeout: 1000});\nawait execa('unicorns', {timeout: 1000 as number});\nexecaSync('unicorns', {timeout: 1000 as number});\nexpectError(await execa('unicorns', {timeout: '1000'}));\nexpectError(execaSync('unicorns', {timeout: '1000'}));\n\nawait execa('unicorns', {maxBuffer: 1000});\nexecaSync('unicorns', {maxBuffer: 1000});\nawait execa('unicorns', {maxBuffer: 1000 as number});\nexecaSync('unicorns', {maxBuffer: 1000 as number});\nexpectError(await execa('unicorns', {maxBuffer: '1000'}));\nexpectError(execaSync('unicorns', {maxBuffer: '1000'}));\n\nawait execa('unicorns', {killSignal: 'SIGTERM'});\nexecaSync('unicorns', {killSignal: 'SIGTERM'});\nexpectError(await execa('unicorns', {killSignal: 'SIGTERM' as string}));\nexpectError(execaSync('unicorns', {killSignal: 'SIGTERM' as string}));\nawait execa('unicorns', {killSignal: 9});\nexecaSync('unicorns', {killSignal: 9});\nawait execa('unicorns', {killSignal: 9 as number});\nexecaSync('unicorns', {killSignal: 9 as number});\nexpectError(await execa('unicorns', {killSignal: false}));\nexpectError(execaSync('unicorns', {killSignal: false}));\nexpectError(await execa('unicorns', {killSignal: 'Sigterm'}));\nexpectError(execaSync('unicorns', {killSignal: 'Sigterm'}));\nexpectError(await execa('unicorns', {killSignal: 'sigterm'}));\nexpectError(execaSync('unicorns', {killSignal: 'sigterm'}));\nexpectError(await execa('unicorns', {killSignal: 'SIGOTHER'}));\nexpectError(execaSync('unicorns', {killSignal: 'SIGOTHER'}));\nexpectError(await execa('unicorns', {killSignal: 'SIGEMT'}));\nexpectError(execaSync('unicorns', {killSignal: 'SIGEMT'}));\nexpectError(await execa('unicorns', {killSignal: 'SIGCLD'}));\nexpectError(execaSync('unicorns', {killSignal: 'SIGCLD'}));\nexpectError(await execa('unicorns', {killSignal: 'SIGRT1'}));\nexpectError(execaSync('unicorns', {killSignal: 'SIGRT1'}));\n\nawait execa('unicorns', {forceKillAfterDelay: false});\nexpectError(execaSync('unicorns', {forceKillAfterDelay: false}));\nawait execa('unicorns', {forceKillAfterDelay: true});\nexpectError(execaSync('unicorns', {forceKillAfterDelay: true}));\nawait execa('unicorns', {forceKillAfterDelay: false as boolean});\nexpectError(execaSync('unicorns', {forceKillAfterDelay: false as boolean}));\nawait execa('unicorns', {forceKillAfterDelay: 42});\nexpectError(execaSync('unicorns', {forceKillAfterDelay: 42}));\nawait execa('unicorns', {forceKillAfterDelay: 42 as number});\nexpectError(execaSync('unicorns', {forceKillAfterDelay: 42 as number}));\nexpectError(await execa('unicorns', {forceKillAfterDelay: 'true'}));\nexpectError(execaSync('unicorns', {forceKillAfterDelay: 'true'}));\n\nawait execa('unicorns', {windowsVerbatimArguments: true});\nexecaSync('unicorns', {windowsVerbatimArguments: true});\nawait execa('unicorns', {windowsVerbatimArguments: true as boolean});\nexecaSync('unicorns', {windowsVerbatimArguments: true as boolean});\nexpectError(await execa('unicorns', {windowsVerbatimArguments: 'true'}));\nexpectError(execaSync('unicorns', {windowsVerbatimArguments: 'true'}));\n\nawait execa('unicorns', {windowsHide: false});\nexecaSync('unicorns', {windowsHide: false});\nawait execa('unicorns', {windowsHide: false as boolean});\nexecaSync('unicorns', {windowsHide: false as boolean});\nexpectError(await execa('unicorns', {windowsHide: 'false'}));\nexpectError(execaSync('unicorns', {windowsHide: 'false'}));\n\nawait execa('unicorns', {cleanup: false});\nexpectError(execaSync('unicorns', {cleanup: false}));\nawait execa('unicorns', {cleanup: false as boolean});\nexpectError(execaSync('unicorns', {cleanup: false as boolean}));\nexpectError(await execa('unicorns', {cleanup: 'false'}));\nexpectError(execaSync('unicorns', {cleanup: 'false'}));\n\nawait execa('unicorns', {buffer: false});\nexecaSync('unicorns', {buffer: false});\nawait execa('unicorns', {buffer: false as boolean});\nexecaSync('unicorns', {buffer: false as boolean});\nexpectError(await execa('unicorns', {buffer: 'false'}));\nexpectError(execaSync('unicorns', {buffer: 'false'}));\n\nawait execa('unicorns', {all: true});\nexecaSync('unicorns', {all: true});\nawait execa('unicorns', {all: true as boolean});\nexecaSync('unicorns', {all: true as boolean});\nexpectError(await execa('unicorns', {all: 'true'}));\nexpectError(execaSync('unicorns', {all: 'true'}));\n\nawait execa('unicorns', {ipc: true});\nexpectError(execaSync('unicorns', {ipc: true}));\nawait execa('unicorns', {ipc: true as boolean});\nexpectError(execaSync('unicorns', {ipc: true as boolean}));\nexpectError(await execa('unicorns', {ipc: 'true'}));\nexpectError(execaSync('unicorns', {ipc: 'true'}));\n\nawait execa('unicorns', {serialization: 'json'});\nexpectError(execaSync('unicorns', {serialization: 'json'}));\nawait execa('unicorns', {serialization: 'advanced'});\nexpectError(execaSync('unicorns', {serialization: 'advanced'}));\nexpectError(await execa('unicorns', {serialization: 'advanced' as string}));\nexpectError(execaSync('unicorns', {serialization: 'advanced' as string}));\nexpectError(await execa('unicorns', {serialization: 'other'}));\nexpectError(execaSync('unicorns', {serialization: 'other'}));\n\nawait execa('unicorns', {ipcInput: ''});\nexpectError(execaSync('unicorns', {ipcInput: ''}));\nawait execa('unicorns', {ipcInput: '' as string});\nexpectError(execaSync('unicorns', {ipcInput: '' as string}));\nawait execa('unicorns', {ipcInput: {}});\nexpectError(execaSync('unicorns', {ipcInput: {}}));\nawait execa('unicorns', {ipcInput: undefined});\nexecaSync('unicorns', {ipcInput: undefined});\nexpectError(await execa('unicorns', {ipcInput: 0n}));\nexpectError(execaSync('unicorns', {ipcInput: 0n}));\n\nawait execa('unicorns', {detached: true});\nexpectError(execaSync('unicorns', {detached: true}));\nawait execa('unicorns', {detached: true as boolean});\nexpectError(execaSync('unicorns', {detached: true as boolean}));\nexpectError(await execa('unicorns', {detached: 'true'}));\nexpectError(execaSync('unicorns', {detached: 'true'}));\n\nawait execa('unicorns', {cancelSignal: AbortSignal.abort()});\nexpectError(execaSync('unicorns', {cancelSignal: AbortSignal.abort()}));\nexpectError(await execa('unicorns', {cancelSignal: false}));\nexpectError(execaSync('unicorns', {cancelSignal: false}));\n\nawait execa('unicorns', {gracefulCancel: true, cancelSignal: AbortSignal.abort()});\nexpectError(execaSync('unicorns', {gracefulCancel: true, cancelSignal: AbortSignal.abort()}));\nawait execa('unicorns', {gracefulCancel: true as boolean, cancelSignal: AbortSignal.abort()});\nexpectError(execaSync('unicorns', {gracefulCancel: true as boolean, cancelSignal: AbortSignal.abort()}));\nexpectError(await execa('unicorns', {gracefulCancel: 'true', cancelSignal: AbortSignal.abort()}));\nexpectError(execaSync('unicorns', {gracefulCancel: 'true', cancelSignal: AbortSignal.abort()}));\n"
  },
  {
    "path": "test-d/arguments/specific.test-d.ts",
    "content": "import {expectType, expectError} from 'tsd';\nimport {execa, execaSync} from '../../index.js';\n\nawait execa('unicorns', {maxBuffer: {}});\nexpectError(await execa('unicorns', {maxBuffer: []}));\nawait execa('unicorns', {maxBuffer: {stdout: 0}});\nawait execa('unicorns', {maxBuffer: {stderr: 0}});\nawait execa('unicorns', {maxBuffer: {stdout: 0, stderr: 0} as const});\nawait execa('unicorns', {maxBuffer: {all: 0}});\nawait execa('unicorns', {maxBuffer: {fd1: 0}});\nawait execa('unicorns', {maxBuffer: {fd2: 0}});\nawait execa('unicorns', {maxBuffer: {fd3: 0}});\nawait execa('unicorns', {maxBuffer: {ipc: 0}});\nexpectError(await execa('unicorns', {maxBuffer: {stdout: '0'}}));\n\nexecaSync('unicorns', {maxBuffer: {}});\nexpectError(execaSync('unicorns', {maxBuffer: []}));\nexecaSync('unicorns', {maxBuffer: {stdout: 0}});\nexecaSync('unicorns', {maxBuffer: {stderr: 0}});\nexecaSync('unicorns', {maxBuffer: {stdout: 0, stderr: 0} as const});\nexecaSync('unicorns', {maxBuffer: {all: 0}});\nexecaSync('unicorns', {maxBuffer: {fd1: 0}});\nexecaSync('unicorns', {maxBuffer: {fd2: 0}});\nexecaSync('unicorns', {maxBuffer: {fd3: 0}});\nexecaSync('unicorns', {maxBuffer: {ipc: 0}});\nexpectError(execaSync('unicorns', {maxBuffer: {stdout: '0'}}));\n\nawait execa('unicorns', {verbose: {}});\nexpectError(await execa('unicorns', {verbose: []}));\nawait execa('unicorns', {verbose: {stdout: 'none'}});\nawait execa('unicorns', {verbose: {stderr: 'none'}});\nawait execa('unicorns', {verbose: {stdout: 'none', stderr: 'none'} as const});\nawait execa('unicorns', {verbose: {all: 'none'}});\nawait execa('unicorns', {verbose: {fd1: 'none'}});\nawait execa('unicorns', {verbose: {fd2: 'none'}});\nawait execa('unicorns', {verbose: {fd3: 'none'}});\nawait execa('unicorns', {verbose: {ipc: 'none'}});\nexpectError(await execa('unicorns', {verbose: {stdout: 'other'}}));\n\nexecaSync('unicorns', {verbose: {}});\nexpectError(execaSync('unicorns', {verbose: []}));\nexecaSync('unicorns', {verbose: {stdout: 'none'}});\nexecaSync('unicorns', {verbose: {stderr: 'none'}});\nexecaSync('unicorns', {verbose: {stdout: 'none', stderr: 'none'} as const});\nexecaSync('unicorns', {verbose: {all: 'none'}});\nexecaSync('unicorns', {verbose: {fd1: 'none'}});\nexecaSync('unicorns', {verbose: {fd2: 'none'}});\nexecaSync('unicorns', {verbose: {fd3: 'none'}});\nexecaSync('unicorns', {verbose: {ipc: 'none'}});\nexpectError(execaSync('unicorns', {verbose: {stdout: 'other'}}));\n\nawait execa('unicorns', {stripFinalNewline: {}});\nexpectError(await execa('unicorns', {stripFinalNewline: []}));\nawait execa('unicorns', {stripFinalNewline: {stdout: true}});\nawait execa('unicorns', {stripFinalNewline: {stderr: true}});\nawait execa('unicorns', {stripFinalNewline: {stdout: true, stderr: true} as const});\nawait execa('unicorns', {stripFinalNewline: {all: true}});\nawait execa('unicorns', {stripFinalNewline: {fd1: true}});\nawait execa('unicorns', {stripFinalNewline: {fd2: true}});\nawait execa('unicorns', {stripFinalNewline: {fd3: true}});\nawait execa('unicorns', {stripFinalNewline: {ipc: true}});\nexpectError(await execa('unicorns', {stripFinalNewline: {stdout: 'true'}}));\n\nexecaSync('unicorns', {stripFinalNewline: {}});\nexpectError(execaSync('unicorns', {stripFinalNewline: []}));\nexecaSync('unicorns', {stripFinalNewline: {stdout: true}});\nexecaSync('unicorns', {stripFinalNewline: {stderr: true}});\nexecaSync('unicorns', {stripFinalNewline: {stdout: true, stderr: true} as const});\nexecaSync('unicorns', {stripFinalNewline: {all: true}});\nexecaSync('unicorns', {stripFinalNewline: {fd1: true}});\nexecaSync('unicorns', {stripFinalNewline: {fd2: true}});\nexecaSync('unicorns', {stripFinalNewline: {fd3: true}});\nexecaSync('unicorns', {stripFinalNewline: {ipc: true}});\nexpectError(execaSync('unicorns', {stripFinalNewline: {stdout: 'true'}}));\n\nawait execa('unicorns', {lines: {}});\nexpectError(await execa('unicorns', {lines: []}));\nawait execa('unicorns', {lines: {stdout: true}});\nawait execa('unicorns', {lines: {stderr: true}});\nawait execa('unicorns', {lines: {stdout: true, stderr: true} as const});\nawait execa('unicorns', {lines: {all: true}});\nawait execa('unicorns', {lines: {fd1: true}});\nawait execa('unicorns', {lines: {fd2: true}});\nawait execa('unicorns', {lines: {fd3: true}});\nawait execa('unicorns', {lines: {ipc: true}});\nexpectError(await execa('unicorns', {lines: {stdout: 'true'}}));\n\nexecaSync('unicorns', {lines: {}});\nexpectError(execaSync('unicorns', {lines: []}));\nexecaSync('unicorns', {lines: {stdout: true}});\nexecaSync('unicorns', {lines: {stderr: true}});\nexecaSync('unicorns', {lines: {stdout: true, stderr: true} as const});\nexecaSync('unicorns', {lines: {all: true}});\nexecaSync('unicorns', {lines: {fd1: true}});\nexecaSync('unicorns', {lines: {fd2: true}});\nexecaSync('unicorns', {lines: {fd3: true}});\nexecaSync('unicorns', {lines: {ipc: true}});\nexpectError(execaSync('unicorns', {lines: {stdout: 'true'}}));\n\nawait execa('unicorns', {buffer: {}});\nexpectError(await execa('unicorns', {buffer: []}));\nawait execa('unicorns', {buffer: {stdout: true}});\nawait execa('unicorns', {buffer: {stderr: true}});\nawait execa('unicorns', {buffer: {stdout: true, stderr: true} as const});\nawait execa('unicorns', {buffer: {all: true}});\nawait execa('unicorns', {buffer: {fd1: true}});\nawait execa('unicorns', {buffer: {fd2: true}});\nawait execa('unicorns', {buffer: {fd3: true}});\nawait execa('unicorns', {buffer: {ipc: true}});\nexpectError(await execa('unicorns', {buffer: {stdout: 'true'}}));\n\nexecaSync('unicorns', {buffer: {}});\nexpectError(execaSync('unicorns', {buffer: []}));\nexecaSync('unicorns', {buffer: {stdout: true}});\nexecaSync('unicorns', {buffer: {stderr: true}});\nexecaSync('unicorns', {buffer: {stdout: true, stderr: true} as const});\nexecaSync('unicorns', {buffer: {all: true}});\nexecaSync('unicorns', {buffer: {fd1: true}});\nexecaSync('unicorns', {buffer: {fd2: true}});\nexecaSync('unicorns', {buffer: {fd3: true}});\nexecaSync('unicorns', {buffer: {ipc: true}});\nexpectError(execaSync('unicorns', {buffer: {stdout: 'true'}}));\n\nexpectError(await execa('unicorns', {preferLocal: {}}));\nexpectError(await execa('unicorns', {preferLocal: []}));\nexpectError(await execa('unicorns', {preferLocal: {stdout: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {stderr: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {stdout: 0, stderr: 0} as const}));\nexpectError(await execa('unicorns', {preferLocal: {all: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {fd1: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {fd2: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {fd3: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {ipc: 0}}));\nexpectError(await execa('unicorns', {preferLocal: {stdout: '0'}}));\n\nexpectError(execaSync('unicorns', {preferLocal: {}}));\nexpectError(execaSync('unicorns', {preferLocal: []}));\nexpectError(execaSync('unicorns', {preferLocal: {stdout: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {stderr: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {stdout: 0, stderr: 0} as const}));\nexpectError(execaSync('unicorns', {preferLocal: {all: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {fd1: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {fd2: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {fd3: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {ipc: 0}}));\nexpectError(execaSync('unicorns', {preferLocal: {stdout: '0'}}));\n\nexpectType<string[]>(execaSync('unicorns', {lines: {stdout: true, fd1: false}}).stdout);\nexpectType<string[]>(execaSync('unicorns', {lines: {stdout: true, all: false}}).stdout);\nexpectType<string[]>(execaSync('unicorns', {lines: {fd1: true, all: false}}).stdout);\nexpectType<string[]>(execaSync('unicorns', {lines: {stderr: true, fd2: false}}).stderr);\nexpectType<string[]>(execaSync('unicorns', {lines: {stderr: true, all: false}}).stderr);\nexpectType<string[]>(execaSync('unicorns', {lines: {fd2: true, all: false}}).stderr);\nexpectType<string[]>(execaSync('unicorns', {lines: {fd1: false, stdout: true}}).stdout);\nexpectType<string[]>(execaSync('unicorns', {lines: {all: false, stdout: true}}).stdout);\nexpectType<string[]>(execaSync('unicorns', {lines: {all: false, fd1: true}}).stdout);\nexpectType<string[]>(execaSync('unicorns', {lines: {fd2: false, stderr: true}}).stderr);\nexpectType<string[]>(execaSync('unicorns', {lines: {all: false, stderr: true}}).stderr);\nexpectType<string[]>(execaSync('unicorns', {lines: {all: false, fd2: true}}).stderr);\n"
  },
  {
    "path": "test-d/convert/duplex.test-d.ts",
    "content": "import type {Duplex} from 'node:stream';\nimport {expectType, expectError} from 'tsd';\nimport {execa} from '../../index.js';\n\nconst subprocess = execa('unicorns');\n\nexpectType<Duplex>(subprocess.duplex());\n\nsubprocess.duplex({from: 'stdout'});\nsubprocess.duplex({from: 'stderr'});\nsubprocess.duplex({from: 'all'});\nsubprocess.duplex({from: 'fd3'});\nsubprocess.duplex({to: 'fd3'});\nsubprocess.duplex({from: 'stdout', to: 'stdin'});\nsubprocess.duplex({from: 'stdout', to: 'fd3'});\nexpectError(subprocess.duplex({from: 'stdout' as string}));\nexpectError(subprocess.duplex({to: 'fd3' as string}));\nexpectError(subprocess.duplex({from: 'stdin'}));\nexpectError(subprocess.duplex({from: 'stderr', to: 'stdout'}));\nexpectError(subprocess.duplex({from: 'fd'}));\nexpectError(subprocess.duplex({from: 'fdNotANumber'}));\nexpectError(subprocess.duplex({to: 'fd'}));\nexpectError(subprocess.duplex({to: 'fdNotANumber'}));\n\nsubprocess.duplex({binary: false});\nexpectError(subprocess.duplex({binary: 'false'}));\n\nsubprocess.duplex({preserveNewlines: false});\nexpectError(subprocess.duplex({preserveNewlines: 'false'}));\n\nexpectError(subprocess.duplex('stdout'));\nexpectError(subprocess.duplex({other: 'stdout'}));\n"
  },
  {
    "path": "test-d/convert/iterable.test-d.ts",
    "content": "import {expectType, expectError} from 'tsd';\nimport {execa} from '../../index.js';\n\nconst subprocess = execa('unicorns');\nconst bufferSubprocess = execa('unicorns', {encoding: 'buffer', all: true});\nconst hexSubprocess = execa('unicorns', {encoding: 'hex', all: true});\n\nconst asyncIteration = async () => {\n\tfor await (const line of subprocess) {\n\t\texpectType<string>(line);\n\t}\n\n\tfor await (const line of subprocess.iterable()) {\n\t\texpectType<string>(line);\n\t}\n\n\tfor await (const line of subprocess.iterable({binary: false})) {\n\t\texpectType<string>(line);\n\t}\n\n\tfor await (const line of subprocess.iterable({binary: true})) {\n\t\texpectType<Uint8Array>(line);\n\t}\n\n\tfor await (const line of subprocess.iterable({} as {binary: boolean})) {\n\t\texpectType<string | Uint8Array>(line);\n\t}\n\n\tfor await (const line of bufferSubprocess) {\n\t\texpectType<Uint8Array>(line);\n\t}\n\n\tfor await (const line of bufferSubprocess.iterable()) {\n\t\texpectType<Uint8Array>(line);\n\t}\n\n\tfor await (const line of bufferSubprocess.iterable({binary: false})) {\n\t\texpectType<Uint8Array>(line);\n\t}\n\n\tfor await (const line of bufferSubprocess.iterable({binary: true})) {\n\t\texpectType<Uint8Array>(line);\n\t}\n\n\tfor await (const line of bufferSubprocess.iterable({} as {binary: boolean})) {\n\t\texpectType<Uint8Array>(line);\n\t}\n};\n\nawait asyncIteration();\n\nexpectType<AsyncIterableIterator<string>>(subprocess.iterable());\nexpectType<AsyncIterableIterator<string>>(subprocess.iterable({binary: false}));\nexpectType<AsyncIterableIterator<Uint8Array>>(subprocess.iterable({binary: true}));\nexpectType<AsyncIterableIterator<string | Uint8Array>>(subprocess.iterable({} as {binary: boolean}));\n\nexpectType<AsyncIterableIterator<Uint8Array>>(bufferSubprocess.iterable());\nexpectType<AsyncIterableIterator<Uint8Array>>(bufferSubprocess.iterable({binary: false}));\nexpectType<AsyncIterableIterator<Uint8Array>>(bufferSubprocess.iterable({binary: true}));\nexpectType<AsyncIterableIterator<Uint8Array>>(bufferSubprocess.iterable({} as {binary: boolean}));\n\nexpectType<AsyncIterableIterator<Uint8Array>>(hexSubprocess.iterable());\nexpectType<AsyncIterableIterator<Uint8Array>>(hexSubprocess.iterable({binary: false}));\nexpectType<AsyncIterableIterator<Uint8Array>>(hexSubprocess.iterable({binary: true}));\nexpectType<AsyncIterableIterator<Uint8Array>>(hexSubprocess.iterable({} as {binary: boolean}));\n\nsubprocess.iterable({});\nsubprocess.iterable({from: 'stdout'});\nsubprocess.iterable({from: 'stderr'});\nsubprocess.iterable({from: 'all'});\nsubprocess.iterable({from: 'fd3'});\nexpectError(subprocess.iterable({from: 'fd3' as string}));\nexpectError(subprocess.iterable({from: 'stdin'}));\nexpectError(subprocess.iterable({from: 'fd'}));\nexpectError(subprocess.iterable({from: 'fdNotANumber'}));\nexpectError(subprocess.iterable({to: 'stdin'}));\n\nsubprocess.iterable({binary: false});\nexpectError(subprocess.iterable({binary: 'false'}));\n\nsubprocess.iterable({preserveNewlines: false});\nexpectError(subprocess.iterable({preserveNewlines: 'false'}));\n\nexpectError(subprocess.iterable('stdout'));\nexpectError(subprocess.iterable({other: 'stdout'}));\n"
  },
  {
    "path": "test-d/convert/readable.test-d.ts",
    "content": "import type {Readable} from 'node:stream';\nimport {expectType, expectError} from 'tsd';\nimport {execa} from '../../index.js';\n\nconst subprocess = execa('unicorns');\n\nexpectType<Readable>(subprocess.readable());\n\nsubprocess.readable({from: 'stdout'});\nsubprocess.readable({from: 'stderr'});\nsubprocess.readable({from: 'all'});\nsubprocess.readable({from: 'fd3'});\nexpectError(subprocess.readable({from: 'fd3' as string}));\nexpectError(subprocess.readable({from: 'stdin'}));\nexpectError(subprocess.readable({from: 'fd'}));\nexpectError(subprocess.readable({from: 'fdNotANumber'}));\nexpectError(subprocess.readable({to: 'stdin'}));\n\nsubprocess.readable({binary: false});\nexpectError(subprocess.readable({binary: 'false'}));\n\nsubprocess.readable({preserveNewlines: false});\nexpectError(subprocess.readable({preserveNewlines: 'false'}));\n\nexpectError(subprocess.readable('stdout'));\nexpectError(subprocess.readable({other: 'stdout'}));\n"
  },
  {
    "path": "test-d/convert/writable.test-d.ts",
    "content": "import type {Writable} from 'node:stream';\nimport {expectType, expectError} from 'tsd';\nimport {execa} from '../../index.js';\n\nconst subprocess = execa('unicorns');\n\nexpectType<Writable>(subprocess.writable());\n\nsubprocess.writable({to: 'stdin'});\nsubprocess.writable({to: 'fd3'});\nexpectError(subprocess.writable({to: 'fd3' as string}));\nexpectError(subprocess.writable({to: 'stdout'}));\nexpectError(subprocess.writable({to: 'fd'}));\nexpectError(subprocess.writable({to: 'fdNotANumber'}));\nexpectError(subprocess.writable({from: 'stdout'}));\n\nexpectError(subprocess.writable({binary: false}));\n\nexpectError(subprocess.writable({preserveNewlines: false}));\n\nexpectError(subprocess.writable('stdin'));\nexpectError(subprocess.writable({other: 'stdin'}));\n"
  },
  {
    "path": "test-d/ipc/get-each.test-d.ts",
    "content": "import {expectType, expectError} from 'tsd';\nimport {\n\tgetEachMessage,\n\texeca,\n\ttype Message,\n\ttype Options,\n} from '../../index.js';\n\nconst subprocess = execa('test', {ipc: true});\n\nfor await (const message of subprocess.getEachMessage()) {\n\texpectType<Message<'advanced'>>(message);\n}\n\nfor await (const message of execa('test', {ipc: true, serialization: 'json'}).getEachMessage()) {\n\texpectType<Message<'json'>>(message);\n}\n\nfor await (const message of getEachMessage()) {\n\texpectType<Message>(message);\n}\n\nexpectError(subprocess.getEachMessage(''));\nexpectError(getEachMessage(''));\n\nexeca('test', {ipcInput: ''}).getEachMessage();\nexeca('test', {ipcInput: '' as Message}).getEachMessage();\nexeca('test', {gracefulCancel: true, cancelSignal: AbortSignal.abort()}).getEachMessage();\nexeca('test', {} as Options).getEachMessage?.();\nexeca('test', {ipc: true as boolean}).getEachMessage?.();\nexeca('test', {ipcInput: '' as '' | undefined}).getEachMessage?.();\nexeca('test', {gracefulCancel: true as boolean | undefined, cancelSignal: AbortSignal.abort()}).getEachMessage?.();\n\nexpectType<undefined>(execa('test').getEachMessage);\nexpectType<undefined>(execa('test', {}).getEachMessage);\nexpectType<undefined>(execa('test', {ipc: false}).getEachMessage);\nexpectType<undefined>(execa('test', {ipcInput: undefined}).getEachMessage);\nexpectType<undefined>(execa('test', {gracefulCancel: undefined}).getEachMessage);\nexpectType<undefined>(execa('test', {gracefulCancel: false}).getEachMessage);\nexpectType<undefined>(execa('test', {ipc: false, ipcInput: ''}).getEachMessage);\nexpectType<undefined>(execa('test', {ipc: false, gracefulCancel: true, cancelSignal: AbortSignal.abort()}).getEachMessage);\n\nsubprocess.getEachMessage({reference: true} as const);\ngetEachMessage({reference: true} as const);\nsubprocess.getEachMessage({reference: true as boolean});\ngetEachMessage({reference: true as boolean});\nexpectError(subprocess.getEachMessage({reference: 'true'} as const));\nexpectError(getEachMessage({reference: 'true'} as const));\n"
  },
  {
    "path": "test-d/ipc/get-one.test-d.ts",
    "content": "import {expectType, expectError} from 'tsd';\nimport {\n\tgetOneMessage,\n\texeca,\n\ttype Message,\n\ttype Options,\n} from '../../index.js';\n\nconst subprocess = execa('test', {ipc: true});\nexpectType<Promise<Message<'advanced'>>>(subprocess.getOneMessage());\nconst jsonSubprocess = execa('test', {ipc: true, serialization: 'json'});\nexpectType<Promise<Message<'json'>>>(jsonSubprocess.getOneMessage());\nexpectType<Promise<Message>>(getOneMessage());\n\nexpectError(await subprocess.getOneMessage(''));\nexpectError(await getOneMessage(''));\nexpectError(await subprocess.getOneMessage({}, ''));\nexpectError(await getOneMessage({}, ''));\n\nawait execa('test', {ipcInput: ''}).getOneMessage();\nawait execa('test', {ipcInput: '' as Message}).getOneMessage();\nawait execa('test', {gracefulCancel: true, cancelSignal: AbortSignal.abort()}).getOneMessage();\nawait execa('test', {} as Options).getOneMessage?.();\nawait execa('test', {ipc: true as boolean}).getOneMessage?.();\nawait execa('test', {ipcInput: '' as '' | undefined}).getOneMessage?.();\nawait execa('test', {gracefulCancel: true as boolean | undefined, cancelSignal: AbortSignal.abort()}).getOneMessage?.();\n\nexpectType<undefined>(execa('test').getOneMessage);\nexpectType<undefined>(execa('test', {}).getOneMessage);\nexpectType<undefined>(execa('test', {ipc: false}).getOneMessage);\nexpectType<undefined>(execa('test', {ipcInput: undefined}).getOneMessage);\nexpectType<undefined>(execa('test', {gracefulCancel: undefined}).getOneMessage);\nexpectType<undefined>(execa('test', {gracefulCancel: false}).getOneMessage);\nexpectType<undefined>(execa('test', {ipc: false, ipcInput: ''}).getOneMessage);\nexpectType<undefined>(execa('test', {ipc: false, gracefulCancel: true, cancelSignal: AbortSignal.abort()}).getOneMessage);\n\nawait subprocess.getOneMessage({filter: undefined} as const);\nawait subprocess.getOneMessage({filter: (message: Message<'advanced'>) => true} as const);\nawait jsonSubprocess.getOneMessage({filter: (message: Message<'json'>) => true} as const);\nawait jsonSubprocess.getOneMessage({filter: (message: Message<'advanced'>) => true} as const);\nawait subprocess.getOneMessage({filter: (message: Message<'advanced'> | bigint) => true} as const);\nawait subprocess.getOneMessage({filter: () => true} as const);\nexpectError(await subprocess.getOneMessage({filter: (message: Message<'advanced'>) => ''} as const));\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexpectError(await subprocess.getOneMessage({filter(message: Message<'advanced'>) {}} as const));\nexpectError(await subprocess.getOneMessage({filter: (message: Message<'json'>) => true} as const));\nexpectError(await subprocess.getOneMessage({filter: (message: '') => true} as const));\nexpectError(await subprocess.getOneMessage({filter: true} as const));\n\nawait getOneMessage({filter: undefined} as const);\nawait getOneMessage({filter: (message: Message) => true} as const);\nawait getOneMessage({filter: (message: Message<'advanced'>) => true} as const);\nawait getOneMessage({filter: (message: Message | bigint) => true} as const);\nawait getOneMessage({filter: () => true} as const);\nexpectError(await getOneMessage({filter: (message: Message) => ''} as const));\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexpectError(await getOneMessage({filter(message: Message) {}} as const));\nexpectError(await getOneMessage({filter: (message: Message<'json'>) => true} as const));\nexpectError(await getOneMessage({filter: (message: '') => true} as const));\nexpectError(await getOneMessage({filter: true} as const));\n\nexpectError(await subprocess.getOneMessage({unknownOption: true} as const));\nexpectError(await getOneMessage({unknownOption: true} as const));\n\nawait subprocess.getOneMessage({reference: true} as const);\nawait getOneMessage({reference: true} as const);\nawait subprocess.getOneMessage({reference: true as boolean});\nawait getOneMessage({reference: true as boolean});\nexpectError(await subprocess.getOneMessage({reference: 'true'} as const));\nexpectError(await getOneMessage({reference: 'true'} as const));\n"
  },
  {
    "path": "test-d/ipc/graceful.ts",
    "content": "import {expectType, expectError} from 'tsd';\nimport {getCancelSignal, execa} from '../../index.js';\n\nexpectType<Promise<AbortSignal>>(getCancelSignal());\n\nexpectError(await getCancelSignal(''));\n\nexpectError(execa('test').getCancelSignal);\n"
  },
  {
    "path": "test-d/ipc/message.test-d.ts",
    "content": "import {File} from 'node:buffer';\nimport {expectAssignable, expectNotAssignable} from 'tsd';\nimport {sendMessage, type Message} from '../../index.js';\n\nawait sendMessage('');\nexpectAssignable<Message>('');\nexpectAssignable<Message<'advanced'>>('');\nexpectAssignable<Message<'json'>>('');\n\nawait sendMessage(0);\nexpectAssignable<Message>(0);\nexpectAssignable<Message<'advanced'>>(0);\nexpectAssignable<Message<'json'>>(0);\n\nawait sendMessage(true);\nexpectAssignable<Message>(true);\nexpectAssignable<Message<'advanced'>>(true);\nexpectAssignable<Message<'json'>>(true);\n\nawait sendMessage([] as const);\nexpectAssignable<Message>([] as const);\nexpectAssignable<Message<'advanced'>>([] as const);\nexpectAssignable<Message<'json'>>([] as const);\n\nawait sendMessage([true] as const);\nexpectAssignable<Message>([true] as const);\nexpectAssignable<Message<'advanced'>>([true] as const);\nexpectAssignable<Message<'json'>>([true] as const);\n\nawait sendMessage([undefined] as const);\nexpectAssignable<Message>([undefined] as const);\nexpectAssignable<Message<'advanced'>>([undefined] as const);\nexpectNotAssignable<Message<'json'>>([undefined] as const);\n\nawait sendMessage([0n] as const);\nexpectAssignable<Message>([0n] as const);\nexpectAssignable<Message<'advanced'>>([0n] as const);\nexpectNotAssignable<Message<'json'>>([0n] as const);\n\nawait sendMessage({} as const);\nexpectAssignable<Message>({} as const);\nexpectAssignable<Message<'advanced'>>({} as const);\nexpectAssignable<Message<'json'>>({} as const);\n\nawait sendMessage({test: true} as const);\nexpectAssignable<Message>({test: true} as const);\nexpectAssignable<Message<'advanced'>>({test: true} as const);\nexpectAssignable<Message<'json'>>({test: true} as const);\n\nawait sendMessage({test: undefined} as const);\nexpectAssignable<Message>({test: undefined} as const);\nexpectAssignable<Message<'advanced'>>({test: undefined} as const);\nexpectNotAssignable<Message<'json'>>({test: undefined} as const);\n\nawait sendMessage({test: 0n} as const);\nexpectAssignable<Message>({test: 0n} as const);\nexpectAssignable<Message<'advanced'>>({test: 0n} as const);\nexpectNotAssignable<Message<'json'>>({test: 0n} as const);\n\nawait sendMessage(null);\nexpectAssignable<Message>(null);\nexpectAssignable<Message<'advanced'>>(null);\nexpectAssignable<Message<'json'>>(null);\n\nawait sendMessage(Number.NaN);\nexpectAssignable<Message>(Number.NaN);\nexpectAssignable<Message<'advanced'>>(Number.NaN);\nexpectAssignable<Message<'json'>>(Number.NaN);\n\nawait sendMessage(Number.POSITIVE_INFINITY);\nexpectAssignable<Message>(Number.POSITIVE_INFINITY);\nexpectAssignable<Message<'advanced'>>(Number.POSITIVE_INFINITY);\nexpectAssignable<Message<'json'>>(Number.POSITIVE_INFINITY);\n\nawait sendMessage(new Map());\nexpectAssignable<Message>(new Map());\nexpectAssignable<Message<'advanced'>>(new Map());\nexpectNotAssignable<Message<'json'>>(new Map());\n\nawait sendMessage(new Set());\nexpectAssignable<Message>(new Set());\nexpectAssignable<Message<'advanced'>>(new Set());\nexpectNotAssignable<Message<'json'>>(new Set());\n\nawait sendMessage(new Date());\nexpectAssignable<Message>(new Date());\nexpectAssignable<Message<'advanced'>>(new Date());\nexpectNotAssignable<Message<'json'>>(new Date());\n\nawait sendMessage(/regexp/);\nexpectAssignable<Message>(/regexp/);\nexpectAssignable<Message<'advanced'>>(/regexp/);\nexpectNotAssignable<Message<'json'>>(/regexp/);\n\nawait sendMessage(new Blob());\nexpectAssignable<Message>(new Blob());\nexpectAssignable<Message<'advanced'>>(new Blob());\nexpectNotAssignable<Message<'json'>>(new Blob());\n\nawait sendMessage(new File([], ''));\nexpectAssignable<Message>(new File([], ''));\nexpectAssignable<Message<'advanced'>>(new File([], ''));\nexpectNotAssignable<Message<'json'>>(new File([], ''));\n\nawait sendMessage(new DataView(new ArrayBuffer(0)));\nexpectAssignable<Message>(new DataView(new ArrayBuffer(0)));\nexpectAssignable<Message<'advanced'>>(new DataView(new ArrayBuffer(0)));\nexpectNotAssignable<Message<'json'>>(new DataView(new ArrayBuffer(0)));\n\nawait sendMessage(new ArrayBuffer(0));\nexpectAssignable<Message>(new ArrayBuffer(0));\nexpectAssignable<Message<'advanced'>>(new ArrayBuffer(0));\nexpectNotAssignable<Message<'json'>>(new ArrayBuffer(0));\n\nawait sendMessage(new SharedArrayBuffer(0));\nexpectAssignable<Message>(new SharedArrayBuffer(0));\nexpectAssignable<Message<'advanced'>>(new SharedArrayBuffer(0));\nexpectNotAssignable<Message<'json'>>(new SharedArrayBuffer(0));\n\nawait sendMessage(new Uint8Array());\nexpectAssignable<Message>(new Uint8Array());\nexpectAssignable<Message<'advanced'>>(new Uint8Array());\nexpectNotAssignable<Message<'json'>>(new Uint8Array());\n\nawait sendMessage(AbortSignal.abort());\nexpectAssignable<Message>(AbortSignal.abort());\nexpectAssignable<Message<'advanced'>>(AbortSignal.abort());\nexpectNotAssignable<Message<'json'>>(AbortSignal.abort());\n\nawait sendMessage(new Error('test'));\nexpectAssignable<Message>(new Error('test'));\nexpectAssignable<Message<'advanced'>>(new Error('test'));\nexpectNotAssignable<Message<'json'>>(new Error('test'));\n"
  },
  {
    "path": "test-d/ipc/send.test-d.ts",
    "content": "import {expectType, expectError} from 'tsd';\nimport {\n\tsendMessage,\n\texeca,\n\ttype Message,\n\ttype Options,\n} from '../../index.js';\n\nconst subprocess = execa('test', {ipc: true});\nexpectType<void>(await subprocess.sendMessage(''));\nexpectType<Promise<void>>(sendMessage(''));\n\nexpectError(await subprocess.sendMessage());\nexpectError(await sendMessage());\nexpectError(await subprocess.sendMessage(undefined));\nexpectError(await sendMessage(undefined));\nexpectError(await subprocess.sendMessage(0n));\nexpectError(await sendMessage(0n));\nexpectError(await subprocess.sendMessage(Symbol('test')));\nexpectError(await sendMessage(Symbol('test')));\n\nawait execa('test', {ipcInput: ''}).sendMessage('');\nawait execa('test', {ipcInput: '' as Message}).sendMessage('');\nawait execa('test', {gracefulCancel: true, cancelSignal: AbortSignal.abort()}).sendMessage('');\nawait execa('test', {} as Options).sendMessage?.('');\nawait execa('test', {ipc: true as boolean}).sendMessage?.('');\nawait execa('test', {ipcInput: '' as '' | undefined}).sendMessage?.('');\nawait execa('test', {gracefulCancel: true as boolean | undefined, cancelSignal: AbortSignal.abort()}).sendMessage?.('');\n\nexpectType<undefined>(execa('test').sendMessage);\nexpectType<undefined>(execa('test', {}).sendMessage);\nexpectType<undefined>(execa('test', {ipc: false}).sendMessage);\nexpectType<undefined>(execa('test', {ipcInput: undefined}).sendMessage);\nexpectType<undefined>(execa('test', {gracefulCancel: undefined}).sendMessage);\nexpectType<undefined>(execa('test', {gracefulCancel: false}).sendMessage);\nexpectType<undefined>(execa('test', {ipc: false, ipcInput: ''}).sendMessage);\nexpectType<undefined>(execa('test', {ipc: false, gracefulCancel: true, cancelSignal: AbortSignal.abort()}).sendMessage);\n\nawait subprocess.sendMessage('', {} as const);\nawait sendMessage('', {} as const);\nawait subprocess.sendMessage('', {strict: true} as const);\nawait sendMessage('', {strict: true} as const);\nawait subprocess.sendMessage('', {strict: true as boolean});\nawait sendMessage('', {strict: true as boolean});\nexpectError(await subprocess.sendMessage('', true));\nexpectError(await sendMessage('', true));\nexpectError(await subprocess.sendMessage('', {strict: 'true'}));\nexpectError(await sendMessage('', {strict: 'true'}));\nexpectError(await subprocess.sendMessage('', {unknown: true}));\nexpectError(await sendMessage('', {unknown: true}));\nexpectError(await subprocess.sendMessage('', {strict: true}, {}));\nexpectError(await sendMessage('', {strict: true}, {}));\n"
  },
  {
    "path": "test-d/methods/command.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\t$,\n\texecaNode,\n\texecaCommand,\n\texecaCommandSync,\n\tparseCommandString,\n\ttype Result,\n\ttype ResultPromise,\n\ttype SyncResult,\n} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError(parseCommandString());\nexpectError(parseCommandString(true));\nexpectError(parseCommandString(['unicorns', 'arg']));\n\nexpectType<string[]>(parseCommandString(''));\nexpectType<string[]>(parseCommandString('unicorns foo bar'));\n\nexpectType<Result<{}>>(await execa`${parseCommandString('unicorns foo bar')}`);\nexpectType<SyncResult<{}>>(execaSync`${parseCommandString('unicorns foo bar')}`);\nexpectType<Result<{}>>(await $`${parseCommandString('unicorns foo bar')}`);\nexpectType<SyncResult<{}>>($.sync`${parseCommandString('unicorns foo bar')}`);\nexpectType<Result<{}>>(await execaNode`${parseCommandString('foo bar')}`);\n\nexpectType<Result<{}>>(await execa`unicorns ${parseCommandString('foo bar')}`);\nexpectType<Result<{}>>(await execa('unicorns', parseCommandString('foo bar')));\nexpectType<Result<{}>>(await execa('unicorns', ['foo', ...parseCommandString('bar')]));\n\nexpectError(execaCommand());\nexpectError(execaCommand(true));\nexpectError(execaCommand(['unicorns', 'arg']));\nexpectAssignable<ResultPromise>(execaCommand('unicorns'));\nexpectError(execaCommand(fileUrl));\n\nexpectError(execaCommand('unicorns', []));\nexpectError(execaCommand('unicorns', ['foo']));\nexpectError(execaCommand('unicorns', 'foo'));\nexpectError(execaCommand('unicorns', [true]));\n\nexpectAssignable<ResultPromise>(execaCommand('unicorns', {}));\nexpectError(execaCommand('unicorns', [], {}));\nexpectError(execaCommand('unicorns', [], []));\nexpectError(execaCommand('unicorns', {other: true}));\n\nexpectAssignable<ResultPromise>(execaCommand`unicorns`);\nexpectType<Result<{}>>(await execaCommand('unicorns'));\nexpectType<Result<{}>>(await execaCommand`unicorns`);\n\nexpectAssignable<typeof execaCommand>(execaCommand({}));\nexpectAssignable<ResultPromise>(execaCommand({})('unicorns'));\nexpectAssignable<ResultPromise>(execaCommand({})`unicorns`);\n\nexpectAssignable<{stdout: string}>(await execaCommand('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await execaCommand({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: string}>(await execaCommand({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execaCommand({encoding: 'buffer'})({})`unicorns`);\n\nexpectType<Result<{}>>(await execaCommand`${'unicorns'}`);\nexpectType<Result<{}>>(await execaCommand`unicorns ${'foo'}`);\nexpectError(await execaCommand`unicorns ${'foo'} ${'bar'}`);\nexpectError(await execaCommand`unicorns ${1}`);\nexpectError(await execaCommand`unicorns ${stringArray}`);\nexpectError(await execaCommand`unicorns ${[1, 2]}`);\nexpectType<Result<{}>>(await execaCommand`unicorns ${false.toString()}`);\nexpectError(await execaCommand`unicorns ${false}`);\n\nexpectError(await execaCommand`unicorns ${await execaCommand`echo foo`}`);\nexpectError(await execaCommand`unicorns ${await execaCommand({reject: false})`echo foo`}`);\nexpectError(await execaCommand`unicorns ${execaCommand`echo foo`}`);\nexpectError(await execaCommand`unicorns ${[await execaCommand`echo foo`, 'bar']}`);\nexpectError(await execaCommand`unicorns ${[execaCommand`echo foo`, 'bar']}`);\n\nexpectError(execaCommandSync());\nexpectError(execaCommandSync(true));\nexpectError(execaCommandSync(['unicorns', 'arg']));\nexpectType<SyncResult<{}>>(execaCommandSync('unicorns'));\nexpectError(execaCommandSync(fileUrl));\nexpectError(execaCommandSync('unicorns', []));\nexpectError(execaCommandSync('unicorns', ['foo']));\nexpectType<SyncResult<{}>>(execaCommandSync('unicorns', {}));\nexpectError(execaCommandSync('unicorns', [], {}));\nexpectError(execaCommandSync('unicorns', 'foo'));\nexpectError(execaCommandSync('unicorns', [true]));\nexpectError(execaCommandSync('unicorns', [], []));\nexpectError(execaCommandSync('unicorns', {other: true}));\nexpectType<SyncResult<{}>>(execaCommandSync`unicorns`);\nexpectAssignable<typeof execaCommandSync>(execaCommandSync({}));\nexpectType<SyncResult<{}>>(execaCommandSync({})('unicorns'));\nexpectType<SyncResult<{}>>(execaCommandSync({})`unicorns`);\nexpectType<SyncResult<{}>>(execaCommandSync('unicorns'));\nexpectType<SyncResult<{}>>(execaCommandSync`unicorns`);\nexpectAssignable<{stdout: string}>(execaCommandSync('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(execaCommandSync({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: string}>(execaCommandSync({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(execaCommandSync({encoding: 'buffer'})({})`unicorns`);\nexpectType<SyncResult<{}>>(execaCommandSync`${'unicorns'}`);\nexpectType<SyncResult<{}>>(execaCommandSync`unicorns ${'foo'}`);\nexpectError(execaCommandSync`unicorns ${'foo'} ${'bar'}`);\nexpectError(execaCommandSync`unicorns ${1}`);\nexpectError(execaCommandSync`unicorns ${stringArray}`);\nexpectError(execaCommandSync`unicorns ${[1, 2]}`);\nexpectError(execaCommandSync`unicorns ${execaCommandSync`echo foo`}`);\nexpectError(execaCommandSync`unicorns ${[execaCommandSync`echo foo`, 'bar']}`);\nexpectType<SyncResult<{}>>(execaCommandSync`unicorns ${false.toString()}`);\nexpectError(execaCommandSync`unicorns ${false}`);\n"
  },
  {
    "path": "test-d/methods/list.test-d.ts",
    "content": "import {expectAssignable} from 'tsd';\nimport {\n\ttype ExecaMethod,\n\ttype ExecaSyncMethod,\n\ttype ExecaNodeMethod,\n\ttype ExecaScriptMethod,\n\ttype ExecaScriptSyncMethod,\n\texeca,\n\texecaSync,\n\texecaNode,\n\t$,\n} from '../../index.js';\n\nconst options = {preferLocal: true} as const;\nconst secondOptions = {node: true} as const;\n\nexpectAssignable<ExecaMethod>(execa);\nexpectAssignable<ExecaMethod>(execa({}));\nexpectAssignable<ExecaMethod>(execa({})({}));\nexpectAssignable<ExecaMethod>(execa(options));\nexpectAssignable<ExecaMethod>(execa(options)(secondOptions));\nexpectAssignable<ExecaMethod>(execa(options)({}));\nexpectAssignable<ExecaMethod>(execa({})(options));\n\nexpectAssignable<ExecaSyncMethod>(execaSync);\nexpectAssignable<ExecaSyncMethod>(execaSync({}));\nexpectAssignable<ExecaSyncMethod>(execaSync({})({}));\nexpectAssignable<ExecaSyncMethod>(execaSync(options));\nexpectAssignable<ExecaSyncMethod>(execaSync(options)(secondOptions));\nexpectAssignable<ExecaSyncMethod>(execaSync(options)({}));\nexpectAssignable<ExecaSyncMethod>(execaSync({})(options));\n\nexpectAssignable<ExecaNodeMethod>(execaNode);\nexpectAssignable<ExecaNodeMethod>(execaNode({}));\nexpectAssignable<ExecaNodeMethod>(execaNode({})({}));\nexpectAssignable<ExecaNodeMethod>(execaNode(options));\nexpectAssignable<ExecaNodeMethod>(execaNode(options)(secondOptions));\nexpectAssignable<ExecaNodeMethod>(execaNode(options)({}));\nexpectAssignable<ExecaNodeMethod>(execaNode({})(options));\n\nexpectAssignable<ExecaScriptMethod>($);\nexpectAssignable<ExecaScriptMethod>($({}));\nexpectAssignable<ExecaScriptMethod>($({})({}));\nexpectAssignable<ExecaScriptMethod>($(options));\nexpectAssignable<ExecaScriptMethod>($(options)(secondOptions));\nexpectAssignable<ExecaScriptMethod>($(options)({}));\nexpectAssignable<ExecaScriptMethod>($({})(options));\n\nexpectAssignable<ExecaScriptSyncMethod>($.sync);\nexpectAssignable<ExecaScriptSyncMethod>($.sync({}));\nexpectAssignable<ExecaScriptSyncMethod>($.sync({})({}));\nexpectAssignable<ExecaScriptSyncMethod>($.sync(options));\nexpectAssignable<ExecaScriptSyncMethod>($.sync(options)(secondOptions));\nexpectAssignable<ExecaScriptSyncMethod>($.sync(options)({}));\nexpectAssignable<ExecaScriptSyncMethod>($.sync({})(options));\n\nexpectAssignable<ExecaScriptSyncMethod>($.s);\nexpectAssignable<ExecaScriptSyncMethod>($.s({}));\nexpectAssignable<ExecaScriptSyncMethod>($.s({})({}));\nexpectAssignable<ExecaScriptSyncMethod>($.s(options));\nexpectAssignable<ExecaScriptSyncMethod>($.s(options)(secondOptions));\nexpectAssignable<ExecaScriptSyncMethod>($.s(options)({}));\nexpectAssignable<ExecaScriptSyncMethod>($.s({})(options));\n"
  },
  {
    "path": "test-d/methods/main-async.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {execa, type Result, type ResultPromise} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError(execa());\nexpectError(execa(true));\nexpectError(execa(['unicorns', 'arg']));\nexpectAssignable<ResultPromise>(execa('unicorns'));\nexpectAssignable<ResultPromise>(execa(fileUrl));\n\nexpectAssignable<ResultPromise>(execa('unicorns', []));\nexpectAssignable<ResultPromise>(execa('unicorns', ['foo']));\nexpectError(execa('unicorns', 'foo'));\nexpectError(execa('unicorns', [true]));\n\nexpectAssignable<ResultPromise>(execa('unicorns', {}));\nexpectAssignable<ResultPromise>(execa('unicorns', [], {}));\nexpectError(execa('unicorns', [], []));\nexpectError(execa('unicorns', {other: true}));\n\nexpectAssignable<ResultPromise>(execa`unicorns`);\nexpectType<Result<{}>>(await execa('unicorns'));\nexpectType<Result<{}>>(await execa`unicorns`);\n\nexpectAssignable<typeof execa>(execa({}));\nexpectAssignable<ResultPromise>(execa({})('unicorns'));\nexpectAssignable<ResultPromise>(execa({})`unicorns`);\n\nexpectAssignable<{stdout: string}>(await execa('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execa('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await execa('unicorns', ['foo']));\nexpectAssignable<{stdout: Uint8Array}>(await execa('unicorns', ['foo'], {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await execa({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execa({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execa({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execa({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: string}>(await execa({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execa({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execa({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execa({encoding: 'buffer'})({})`unicorns`);\n\nexpectType<Result<{}>>(await execa`${'unicorns'}`);\nexpectType<Result<{}>>(await execa`unicorns ${'foo'}`);\nexpectType<Result<{}>>(await execa`unicorns ${'foo'} ${'bar'}`);\nexpectType<Result<{}>>(await execa`unicorns ${1}`);\nexpectType<Result<{}>>(await execa`unicorns ${stringArray}`);\nexpectType<Result<{}>>(await execa`unicorns ${[1, 2]}`);\nexpectType<Result<{}>>(await execa`unicorns ${false.toString()}`);\nexpectError(await execa`unicorns ${false}`);\n\nexpectType<Result<{}>>(await execa`unicorns ${await execa`echo foo`}`);\nexpectType<Result<{}>>(await execa`unicorns ${await execa({reject: false})`echo foo`}`);\nexpectError(await execa`unicorns ${execa`echo foo`}`);\nexpectType<Result<{}>>(await execa`unicorns ${[await execa`echo foo`, 'bar']}`);\nexpectError(await execa`unicorns ${[execa`echo foo`, 'bar']}`);\n"
  },
  {
    "path": "test-d/methods/main-sync.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {execaSync, type SyncResult} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError(execaSync());\nexpectError(execaSync(true));\nexpectError(execaSync(['unicorns', 'arg']));\nexpectType<SyncResult<{}>>(execaSync('unicorns'));\nexpectType<SyncResult<{}>>(execaSync(fileUrl));\n\nexpectType<SyncResult<{}>>(execaSync('unicorns', []));\nexpectType<SyncResult<{}>>(execaSync('unicorns', ['foo']));\nexpectError(execaSync('unicorns', 'foo'));\nexpectError(execaSync('unicorns', [true]));\n\nexpectType<SyncResult<{}>>(execaSync('unicorns', {}));\nexpectType<SyncResult<{}>>(execaSync('unicorns', [], {}));\nexpectError(execaSync('unicorns', [], []));\nexpectError(execaSync('unicorns', {other: true}));\n\nexpectType<SyncResult<{}>>(execaSync`unicorns`);\nexpectType<SyncResult<{}>>(execaSync('unicorns'));\nexpectType<SyncResult<{}>>(execaSync`unicorns`);\n\nexpectAssignable<typeof execaSync>(execaSync({}));\nexpectType<SyncResult<{}>>(execaSync({})('unicorns'));\nexpectType<SyncResult<{}>>(execaSync({})`unicorns`);\n\nexpectAssignable<{stdout: string}>(execaSync('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaSync('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(execaSync('unicorns', ['foo']));\nexpectAssignable<{stdout: Uint8Array}>(execaSync('unicorns', ['foo'], {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(execaSync({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaSync({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaSync({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(execaSync({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: string}>(execaSync({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(execaSync({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(execaSync({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(execaSync({encoding: 'buffer'})({})`unicorns`);\n\nexpectType<SyncResult<{}>>(execaSync`${'unicorns'}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${'foo'}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${'foo'} ${'bar'}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${1}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${stringArray}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${[1, 2]}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${false.toString()}`);\nexpectError(execaSync`unicorns ${false}`);\n\nexpectType<SyncResult<{}>>(execaSync`unicorns ${execaSync`echo foo`}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${execaSync({reject: false})`echo foo`}`);\nexpectType<SyncResult<{}>>(execaSync`unicorns ${[execaSync`echo foo`, 'bar']}`);\n"
  },
  {
    "path": "test-d/methods/node.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {execaNode, type Result, type ResultPromise} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError(execaNode());\nexpectError(execaNode(true));\nexpectError(execaNode(['unicorns', 'arg']));\nexpectAssignable<ResultPromise>(execaNode('unicorns'));\nexpectAssignable<ResultPromise>(execaNode(fileUrl));\n\nexpectAssignable<ResultPromise>(execaNode('unicorns', []));\nexpectAssignable<ResultPromise>(execaNode('unicorns', ['foo']));\nexpectError(execaNode('unicorns', 'foo'));\nexpectError(execaNode('unicorns', [true]));\n\nexpectAssignable<ResultPromise>(execaNode('unicorns', {}));\nexpectAssignable<ResultPromise>(execaNode('unicorns', [], {}));\nexpectError(execaNode('unicorns', [], []));\nexpectError(execaNode('unicorns', {other: true}));\n\nexpectAssignable<ResultPromise>(execaNode`unicorns`);\nexpectType<Result<{}>>(await execaNode('unicorns'));\nexpectType<Result<{}>>(await execaNode`unicorns`);\n\nexpectAssignable<typeof execaNode>(execaNode({}));\nexpectAssignable<ResultPromise>(execaNode({})('unicorns'));\nexpectAssignable<ResultPromise>(execaNode({})`unicorns`);\n\nexpectAssignable<{stdout: string}>(await execaNode('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await execaNode('unicorns', ['foo']));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode('unicorns', ['foo'], {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await execaNode({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: string}>(await execaNode({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execaNode({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execaNode({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await execaNode({encoding: 'buffer'})({})`unicorns`);\n\nexpectType<Result<{}>>(await execaNode`${'unicorns'}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${'foo'}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${'foo'} ${'bar'}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${1}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${stringArray}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${[1, 2]}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${false.toString()}`);\nexpectError(await execaNode`unicorns ${false}`);\n\nexpectType<Result<{}>>(await execaNode`unicorns ${await execaNode`echo foo`}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${await execaNode({reject: false})`echo foo`}`);\nexpectError(await execaNode`unicorns ${execaNode`echo foo`}`);\nexpectType<Result<{}>>(await execaNode`unicorns ${[await execaNode`echo foo`, 'bar']}`);\nexpectError(await execaNode`unicorns ${[execaNode`echo foo`, 'bar']}`);\n\nexpectAssignable<ResultPromise>(execaNode('unicorns', {nodePath: './node'}));\nexpectAssignable<ResultPromise>(execaNode('unicorns', {nodePath: fileUrl}));\nexpectAssignable<{stdout: string}>(await execaNode('unicorns', {nodeOptions: ['--async-stack-traces']}));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode('unicorns', {nodeOptions: ['--async-stack-traces'], encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces']}));\nexpectAssignable<{stdout: Uint8Array}>(await execaNode('unicorns', ['foo'], {nodeOptions: ['--async-stack-traces'], encoding: 'buffer'}));\n"
  },
  {
    "path": "test-d/methods/script-s.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {$, type SyncResult} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError($.s());\nexpectError($.s(true));\nexpectError($.s(['unicorns', 'arg']));\nexpectType<SyncResult<{}>>($.s('unicorns'));\nexpectType<SyncResult<{}>>($.s(fileUrl));\n\nexpectType<SyncResult<{}>>($.s('unicorns', []));\nexpectType<SyncResult<{}>>($.s('unicorns', ['foo']));\nexpectError($.s('unicorns', 'foo'));\nexpectError($.s('unicorns', [true]));\n\nexpectType<SyncResult<{}>>($.s('unicorns', {}));\nexpectType<SyncResult<{}>>($.s('unicorns', [], {}));\nexpectError($.s('unicorns', [], []));\nexpectError($.s('unicorns', {other: true}));\n\nexpectType<SyncResult<{}>>($.s`unicorns`);\nexpectType<SyncResult<{}>>($.s('unicorns'));\nexpectType<SyncResult<{}>>($.s`unicorns`);\n\nexpectAssignable<typeof $.s>($.s({}));\nexpectType<SyncResult<{}>>($.s({})('unicorns'));\nexpectType<SyncResult<{}>>($({}).s('unicorns'));\nexpectType<SyncResult<{}>>($.s({})`unicorns`);\nexpectType<SyncResult<{}>>($({}).s`unicorns`);\n\nexpectAssignable<{stdout: string}>($.s('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.s('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>($.s('unicorns', ['foo']));\nexpectAssignable<{stdout: Uint8Array}>($.s('unicorns', ['foo'], {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>($.s({})('unicorns'));\nexpectAssignable<{stdout: string}>($({}).s('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.s({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).s('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.s({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($({})({encoding: 'buffer'}).s('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.s({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).s({})('unicorns'));\nexpectAssignable<{stdout: string}>($.s({})`unicorns`);\nexpectAssignable<{stdout: string}>($({}).s`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($.s({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).s`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($.s({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($({})({encoding: 'buffer'}).s`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($.s({encoding: 'buffer'})({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).s({})`unicorns`);\n\nexpectType<SyncResult<{}>>($.s`${'unicorns'}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${'foo'}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${'foo'} ${'bar'}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${1}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${stringArray}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${[1, 2]}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${false.toString()}`);\nexpectError($.s`unicorns ${false}`);\n\nexpectType<SyncResult<{}>>($.s`unicorns ${$.s`echo foo`}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${$.s({reject: false})`echo foo`}`);\nexpectType<SyncResult<{}>>($.s`unicorns ${[$.s`echo foo`, 'bar']}`);\n"
  },
  {
    "path": "test-d/methods/script-sync.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {$, type SyncResult} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError($.sync());\nexpectError($.sync(true));\nexpectError($.sync(['unicorns', 'arg']));\nexpectType<SyncResult<{}>>($.sync('unicorns'));\nexpectType<SyncResult<{}>>($.sync(fileUrl));\n\nexpectType<SyncResult<{}>>($.sync('unicorns', []));\nexpectType<SyncResult<{}>>($.sync('unicorns', ['foo']));\nexpectError($.sync('unicorns', 'foo'));\nexpectError($.sync('unicorns', [true]));\n\nexpectType<SyncResult<{}>>($.sync('unicorns', {}));\nexpectType<SyncResult<{}>>($.sync('unicorns', [], {}));\nexpectError($.sync('unicorns', [], []));\nexpectError($.sync('unicorns', {other: true}));\n\nexpectType<SyncResult<{}>>($.sync`unicorns`);\nexpectType<SyncResult<{}>>($.sync('unicorns'));\nexpectType<SyncResult<{}>>($.sync`unicorns`);\n\nexpectAssignable<typeof $.sync>($.sync({}));\nexpectType<SyncResult<{}>>($.sync({})('unicorns'));\nexpectType<SyncResult<{}>>($({}).sync('unicorns'));\nexpectType<SyncResult<{}>>($.sync({})`unicorns`);\nexpectType<SyncResult<{}>>($({}).sync`unicorns`);\n\nexpectAssignable<{stdout: string}>($.sync('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.sync('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>($.sync('unicorns', ['foo']));\nexpectAssignable<{stdout: Uint8Array}>($.sync('unicorns', ['foo'], {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>($.sync({})('unicorns'));\nexpectAssignable<{stdout: string}>($({}).sync('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.sync({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).sync('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.sync({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($({})({encoding: 'buffer'}).sync('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($.sync({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).sync({})('unicorns'));\nexpectAssignable<{stdout: string}>($.sync({})`unicorns`);\nexpectAssignable<{stdout: string}>($({}).sync`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($.sync({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).sync`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($.sync({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($({})({encoding: 'buffer'}).sync`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($.sync({encoding: 'buffer'})({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>($({encoding: 'buffer'}).sync({})`unicorns`);\n\nexpectType<SyncResult<{}>>($.sync`${'unicorns'}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${'foo'}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${'foo'} ${'bar'}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${1}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${stringArray}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${[1, 2]}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${false.toString()}`);\nexpectError($.sync`unicorns ${false}`);\n\nexpectType<SyncResult<{}>>($.sync`unicorns ${$.sync`echo foo`}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${$.sync({reject: false})`echo foo`}`);\nexpectType<SyncResult<{}>>($.sync`unicorns ${[$.sync`echo foo`, 'bar']}`);\n"
  },
  {
    "path": "test-d/methods/script.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {$, type Result, type ResultPromise} from '../../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\n\nexpectError($());\nexpectError($(true));\nexpectError($(['unicorns', 'arg']));\nexpectAssignable<ResultPromise>($('unicorns'));\nexpectAssignable<ResultPromise>($(fileUrl));\n\nexpectAssignable<ResultPromise>($('unicorns', []));\nexpectAssignable<ResultPromise>($('unicorns', ['foo']));\nexpectError($('unicorns', 'foo'));\nexpectError($('unicorns', [true]));\n\nexpectAssignable<ResultPromise>($('unicorns', {}));\nexpectAssignable<ResultPromise>($('unicorns', [], {}));\nexpectError($('unicorns', [], []));\nexpectError($('unicorns', {other: true}));\n\nexpectAssignable<ResultPromise>($`unicorns`);\nexpectType<Result<{}>>(await $('unicorns'));\nexpectType<Result<{}>>(await $`unicorns`);\n\nexpectAssignable<typeof $>($({}));\nexpectAssignable<ResultPromise>($({})('unicorns'));\nexpectAssignable<ResultPromise>($({})`unicorns`);\n\nexpectAssignable<{stdout: string}>(await $('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await $('unicorns', {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await $('unicorns', ['foo']));\nexpectAssignable<{stdout: Uint8Array}>(await $('unicorns', ['foo'], {encoding: 'buffer'}));\nexpectAssignable<{stdout: string}>(await $({})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await $({})({encoding: 'buffer'})('unicorns'));\nexpectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})({})('unicorns'));\nexpectAssignable<{stdout: string}>(await $({})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await $({})({encoding: 'buffer'})`unicorns`);\nexpectAssignable<{stdout: Uint8Array}>(await $({encoding: 'buffer'})({})`unicorns`);\n\nexpectType<Result<{}>>(await $`${'unicorns'}`);\nexpectType<Result<{}>>(await $`unicorns ${'foo'}`);\nexpectType<Result<{}>>(await $`unicorns ${'foo'} ${'bar'}`);\nexpectType<Result<{}>>(await $`unicorns ${1}`);\nexpectType<Result<{}>>(await $`unicorns ${stringArray}`);\nexpectType<Result<{}>>(await $`unicorns ${[1, 2]}`);\nexpectType<Result<{}>>(await $`unicorns ${false.toString()}`);\nexpectError(await $`unicorns ${false}`);\n\nexpectType<Result<{}>>(await $`unicorns ${await $`echo foo`}`);\nexpectType<Result<{}>>(await $`unicorns ${await $({reject: false})`echo foo`}`);\nexpectError(await $`unicorns ${$`echo foo`}`);\nexpectType<Result<{}>>(await $`unicorns ${[await $`echo foo`, 'bar']}`);\nexpectError(await $`unicorns ${[$`echo foo`, 'bar']}`);\n"
  },
  {
    "path": "test-d/methods/template.test-d.ts",
    "content": "import {expectAssignable, expectNotAssignable} from 'tsd';\nimport {execa, type TemplateExpression} from '../../index.js';\n\nconst stringArray = ['foo', 'bar'] as const;\nconst numberArray = [1, 2] as const;\n\nexpectAssignable<TemplateExpression>('unicorns');\nexpectAssignable<TemplateExpression>(1);\nexpectAssignable<TemplateExpression>(stringArray);\nexpectAssignable<TemplateExpression>(numberArray);\nexpectAssignable<TemplateExpression>(false.toString());\nexpectNotAssignable<TemplateExpression>(false);\n\nexpectAssignable<TemplateExpression>(await execa`echo foo`);\nexpectAssignable<TemplateExpression>(await execa({reject: false})`echo foo`);\nexpectNotAssignable<TemplateExpression>(execa`echo foo`);\nexpectAssignable<TemplateExpression>([await execa`echo foo`, 'bar']);\nexpectNotAssignable<TemplateExpression>([execa`echo foo`, 'bar']);\n"
  },
  {
    "path": "test-d/pipe.test-d.ts",
    "content": "import {createWriteStream} from 'node:fs';\nimport {expectType, expectNotType, expectError} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\t$,\n\ttype Result,\n} from '../index.js';\n\nconst fileUrl = new URL('file:///test');\nconst stringArray = ['foo', 'bar'] as const;\nconst pipeOptions = {from: 'stderr', to: 'fd3', all: true} as const;\n\nconst subprocess = execa('unicorns', {all: true});\nconst bufferSubprocess = execa('unicorns', {encoding: 'buffer', all: true});\nconst scriptSubprocess = $`unicorns`;\n\nconst bufferResult = await bufferSubprocess;\ntype BufferExecaReturnValue = typeof bufferResult;\ntype EmptyExecaReturnValue = Result<{}>;\ntype ShortcutExecaReturnValue = Result<typeof pipeOptions>;\n\nexpectNotType<BufferExecaReturnValue>(await subprocess.pipe(subprocess));\nexpectNotType<BufferExecaReturnValue>(await scriptSubprocess.pipe(subprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe(bufferSubprocess, pipeOptions));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe(bufferSubprocess, pipeOptions));\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe`stdin`);\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe(pipeOptions)`stdin`);\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe(pipeOptions)`stdin`);\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe('stdin'));\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe('stdin', pipeOptions));\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe('stdin', pipeOptions));\n\nexpectType<BufferExecaReturnValue>(await subprocess.pipe(subprocess).pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe(subprocess).pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe(subprocess, pipeOptions).pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe(subprocess, pipeOptions).pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe(subprocess).pipe(bufferSubprocess, pipeOptions));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe(subprocess).pipe(bufferSubprocess, pipeOptions));\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe(subprocess).pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe(subprocess).pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe(subprocess, pipeOptions).pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe(subprocess, pipeOptions).pipe`stdin`);\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe(subprocess).pipe(pipeOptions)`stdin`);\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe(subprocess).pipe(pipeOptions)`stdin`);\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe(subprocess).pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe(subprocess).pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe(subprocess, pipeOptions).pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe(subprocess, pipeOptions).pipe('stdin'));\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe(subprocess).pipe('stdin', pipeOptions));\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe(subprocess).pipe('stdin', pipeOptions));\n\nexpectType<BufferExecaReturnValue>(await subprocess.pipe`stdin`.pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe`stdin`.pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe(pipeOptions)`stdin`.pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe(pipeOptions)`stdin`.pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe`stdin`.pipe(bufferSubprocess, pipeOptions));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe`stdin`.pipe(bufferSubprocess, pipeOptions));\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe`stdin`.pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe`stdin`.pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe(pipeOptions)`stdin`.pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe(pipeOptions)`stdin`.pipe`stdin`);\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe`stdin`.pipe(pipeOptions)`stdin`);\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe`stdin`.pipe(pipeOptions)`stdin`);\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe`stdin`.pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe`stdin`.pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe(pipeOptions)`stdin`.pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe(pipeOptions)`stdin`.pipe('stdin'));\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe`stdin`.pipe('stdin', pipeOptions));\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe`stdin`.pipe('stdin', pipeOptions));\n\nexpectType<BufferExecaReturnValue>(await subprocess.pipe('pipe').pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe('pipe').pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe('pipe', pipeOptions).pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe('pipe', pipeOptions).pipe(bufferSubprocess));\nexpectType<BufferExecaReturnValue>(await subprocess.pipe('pipe').pipe(bufferSubprocess, pipeOptions));\nexpectType<BufferExecaReturnValue>(await scriptSubprocess.pipe('pipe').pipe(bufferSubprocess, pipeOptions));\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe('pipe').pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe('pipe').pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe('pipe', pipeOptions).pipe`stdin`);\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe('pipe', pipeOptions).pipe`stdin`);\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe('pipe').pipe(pipeOptions)`stdin`);\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe('pipe').pipe(pipeOptions)`stdin`);\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe('pipe').pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe('pipe').pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe('pipe', pipeOptions).pipe('stdin'));\nexpectType<EmptyExecaReturnValue>(await scriptSubprocess.pipe('pipe', pipeOptions).pipe('stdin'));\nexpectType<ShortcutExecaReturnValue>(await subprocess.pipe('pipe').pipe('stdin', pipeOptions));\nexpectType<ShortcutExecaReturnValue>(await scriptSubprocess.pipe('pipe').pipe('stdin', pipeOptions));\n\nawait subprocess.pipe(bufferSubprocess, {});\nawait scriptSubprocess.pipe(bufferSubprocess, {});\nawait subprocess.pipe({})`stdin`;\nawait scriptSubprocess.pipe({})`stdin`;\nawait subprocess.pipe('stdin', {});\nawait scriptSubprocess.pipe('stdin', {});\n\nexpectError(subprocess.pipe(bufferSubprocess).stdout);\nexpectError(scriptSubprocess.pipe(bufferSubprocess).stdout);\nexpectError(subprocess.pipe`stdin`.stdout);\nexpectError(scriptSubprocess.pipe`stdin`.stdout);\nexpectError(subprocess.pipe('stdin').stdout);\nexpectError(scriptSubprocess.pipe('stdin').stdout);\n\nexpectError(await subprocess.pipe({})({}));\nexpectError(await scriptSubprocess.pipe({})({}));\nexpectError(await subprocess.pipe({})(subprocess));\nexpectError(await scriptSubprocess.pipe({})(subprocess));\nexpectError(await subprocess.pipe({})('stdin'));\nexpectError(await scriptSubprocess.pipe({})('stdin'));\n\nexpectError(subprocess.pipe(createWriteStream('output.txt')));\nexpectError(scriptSubprocess.pipe(createWriteStream('output.txt')));\nexpectError(subprocess.pipe(false));\nexpectError(scriptSubprocess.pipe(false));\n\nexpectError(subprocess.pipe(bufferSubprocess, 'stdout'));\nexpectError(scriptSubprocess.pipe(bufferSubprocess, 'stdout'));\nexpectError(subprocess.pipe('stdout')`stdin`);\nexpectError(scriptSubprocess.pipe('stdout')`stdin`);\n\nawait subprocess.pipe(bufferSubprocess, {from: 'stdout'});\nawait scriptSubprocess.pipe(bufferSubprocess, {from: 'stdout'});\nawait subprocess.pipe({from: 'stdout'})`stdin`;\nawait scriptSubprocess.pipe({from: 'stdout'})`stdin`;\nawait subprocess.pipe('stdin', {from: 'stdout'});\nawait scriptSubprocess.pipe('stdin', {from: 'stdout'});\n\nawait subprocess.pipe(bufferSubprocess, {from: 'stderr'});\nawait scriptSubprocess.pipe(bufferSubprocess, {from: 'stderr'});\nawait subprocess.pipe({from: 'stderr'})`stdin`;\nawait scriptSubprocess.pipe({from: 'stderr'})`stdin`;\nawait subprocess.pipe('stdin', {from: 'stderr'});\nawait scriptSubprocess.pipe('stdin', {from: 'stderr'});\n\nawait subprocess.pipe(bufferSubprocess, {from: 'all'});\nawait scriptSubprocess.pipe(bufferSubprocess, {from: 'all'});\nawait subprocess.pipe({from: 'all'})`stdin`;\nawait scriptSubprocess.pipe({from: 'all'})`stdin`;\nawait subprocess.pipe('stdin', {from: 'all'});\nawait scriptSubprocess.pipe('stdin', {from: 'all'});\n\nawait subprocess.pipe(bufferSubprocess, {from: 'fd3'});\nawait scriptSubprocess.pipe(bufferSubprocess, {from: 'fd3'});\nawait subprocess.pipe({from: 'fd3'})`stdin`;\nawait scriptSubprocess.pipe({from: 'fd3'})`stdin`;\nawait subprocess.pipe('stdin', {from: 'fd3'});\nawait scriptSubprocess.pipe('stdin', {from: 'fd3'});\n\nexpectError(subprocess.pipe(bufferSubprocess, {from: 'stdin'}));\nexpectError(scriptSubprocess.pipe(bufferSubprocess, {from: 'stdin'}));\nexpectError(subprocess.pipe({from: 'stdin'})`stdin`);\nexpectError(scriptSubprocess.pipe({from: 'stdin'})`stdin`);\nexpectError(subprocess.pipe('stdin', {from: 'stdin'}));\nexpectError(scriptSubprocess.pipe('stdin', {from: 'stdin'}));\n\nawait subprocess.pipe(bufferSubprocess, {to: 'stdin'});\nawait scriptSubprocess.pipe(bufferSubprocess, {to: 'stdin'});\nawait subprocess.pipe({to: 'stdin'})`stdin`;\nawait scriptSubprocess.pipe({to: 'stdin'})`stdin`;\nawait subprocess.pipe('stdin', {to: 'stdin'});\nawait scriptSubprocess.pipe('stdin', {to: 'stdin'});\n\nawait subprocess.pipe(bufferSubprocess, {to: 'fd3'});\nawait scriptSubprocess.pipe(bufferSubprocess, {to: 'fd3'});\nawait subprocess.pipe({to: 'fd3'})`stdin`;\nawait scriptSubprocess.pipe({to: 'fd3'})`stdin`;\nawait subprocess.pipe('stdin', {to: 'fd3'});\nawait scriptSubprocess.pipe('stdin', {to: 'fd3'});\n\nexpectError(subprocess.pipe(bufferSubprocess, {to: 'stdout'}));\nexpectError(scriptSubprocess.pipe(bufferSubprocess, {to: 'stdout'}));\nexpectError(subprocess.pipe({to: 'stdout'})`stdin`);\nexpectError(scriptSubprocess.pipe({to: 'stdout'})`stdin`);\nexpectError(subprocess.pipe('stdin', {to: 'stdout'}));\nexpectError(scriptSubprocess.pipe('stdin', {to: 'stdout'}));\n\nawait subprocess.pipe(bufferSubprocess, {unpipeSignal: new AbortController().signal});\nawait scriptSubprocess.pipe(bufferSubprocess, {unpipeSignal: new AbortController().signal});\nawait subprocess.pipe({unpipeSignal: new AbortController().signal})`stdin`;\nawait scriptSubprocess.pipe({unpipeSignal: new AbortController().signal})`stdin`;\nawait subprocess.pipe('stdin', {unpipeSignal: new AbortController().signal});\nawait scriptSubprocess.pipe('stdin', {unpipeSignal: new AbortController().signal});\nexpectError(await subprocess.pipe(bufferSubprocess, {unpipeSignal: true}));\nexpectError(await scriptSubprocess.pipe(bufferSubprocess, {unpipeSignal: true}));\nexpectError(await subprocess.pipe({unpipeSignal: true})`stdin`);\nexpectError(await scriptSubprocess.pipe({unpipeSignal: true})`stdin`);\nexpectError(await subprocess.pipe('stdin', {unpipeSignal: true}));\nexpectError(await scriptSubprocess.pipe('stdin', {unpipeSignal: true}));\n\nexpectType<EmptyExecaReturnValue>(await subprocess.pipe('stdin'));\nawait subprocess.pipe('stdin');\nawait subprocess.pipe(fileUrl);\nawait subprocess.pipe('stdin', []);\nawait subprocess.pipe('stdin', stringArray);\nawait subprocess.pipe('stdin', stringArray, {});\nawait subprocess.pipe('stdin', stringArray, {from: 'stderr', to: 'stdin', all: true});\nawait subprocess.pipe('stdin', {from: 'stderr'});\nawait subprocess.pipe('stdin', {to: 'stdin'});\nawait subprocess.pipe('stdin', {all: true});\n\nexpectError(await subprocess.pipe(stringArray));\nexpectError(await subprocess.pipe('stdin', 'foo'));\nexpectError(await subprocess.pipe('stdin', [false]));\nexpectError(await subprocess.pipe('stdin', [], false));\nexpectError(await subprocess.pipe('stdin', {other: true}));\nexpectError(await subprocess.pipe('stdin', [], {other: true}));\nexpectError(await subprocess.pipe('stdin', {from: 'fd'}));\nexpectError(await subprocess.pipe('stdin', [], {from: 'fd'}));\nexpectError(await subprocess.pipe('stdin', {from: 'fdNotANumber'}));\nexpectError(await subprocess.pipe('stdin', [], {from: 'fdNotANumber'}));\nexpectError(await subprocess.pipe('stdin', {from: 'other'}));\nexpectError(await subprocess.pipe('stdin', [], {from: 'other'}));\nexpectError(await subprocess.pipe('stdin', {to: 'fd'}));\nexpectError(await subprocess.pipe('stdin', [], {to: 'fd'}));\nexpectError(await subprocess.pipe('stdin', {to: 'fdNotANumber'}));\nexpectError(await subprocess.pipe('stdin', [], {to: 'fdNotANumber'}));\nexpectError(await subprocess.pipe('stdin', {to: 'other'}));\nexpectError(await subprocess.pipe('stdin', [], {to: 'other'}));\n\nconst pipeResult = await subprocess.pipe`stdin`;\nexpectType<string>(pipeResult.stdout);\nconst ignorePipeResult = await subprocess.pipe({stdout: 'ignore'})`stdin`;\nexpectType<undefined>(ignorePipeResult.stdout);\n\nconst scriptPipeResult = await scriptSubprocess.pipe`stdin`;\nexpectType<string>(scriptPipeResult.stdout);\nconst ignoreScriptPipeResult = await scriptSubprocess.pipe({stdout: 'ignore'})`stdin`;\nexpectType<undefined>(ignoreScriptPipeResult.stdout);\n\nconst shortcutPipeResult = await subprocess.pipe('stdin');\nexpectType<string>(shortcutPipeResult.stdout);\nconst ignoreShortcutPipeResult = await subprocess.pipe('stdin', {stdout: 'ignore'});\nexpectType<undefined>(ignoreShortcutPipeResult.stdout);\n\nconst scriptShortcutPipeResult = await scriptSubprocess.pipe('stdin');\nexpectType<string>(scriptShortcutPipeResult.stdout);\nconst ignoreShortcutScriptPipeResult = await scriptSubprocess.pipe('stdin', {stdout: 'ignore'});\nexpectType<undefined>(ignoreShortcutScriptPipeResult.stdout);\n\nconst unicornsResult = execaSync('unicorns');\nexpectError(unicornsResult.pipe);\n"
  },
  {
    "path": "test-d/return/ignore-option.test-d.ts",
    "content": "import {type Readable, type Writable} from 'node:stream';\nimport {expectType, expectError} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n} from '../../index.js';\n\nconst ignoreAnySubprocess = execa('unicorns', {\n\tstdin: 'ignore',\n\tstdout: 'ignore',\n\tstderr: 'ignore',\n\tall: true,\n});\nexpectType<null>(ignoreAnySubprocess.stdin);\nexpectType<null>(ignoreAnySubprocess.stdio[0]);\nexpectType<null>(ignoreAnySubprocess.stdout);\nexpectType<null>(ignoreAnySubprocess.stdio[1]);\nexpectType<null>(ignoreAnySubprocess.stderr);\nexpectType<null>(ignoreAnySubprocess.stdio[2]);\nexpectType<undefined>(ignoreAnySubprocess.all);\nexpectError(ignoreAnySubprocess.stdio[3].destroy());\n\nconst ignoreAnyResult = await ignoreAnySubprocess;\nexpectType<undefined>(ignoreAnyResult.stdout);\nexpectType<undefined>(ignoreAnyResult.stdio[1]);\nexpectType<undefined>(ignoreAnyResult.stderr);\nexpectType<undefined>(ignoreAnyResult.stdio[2]);\nexpectType<undefined>(ignoreAnyResult.all);\n\nconst ignoreAllSubprocess = execa('unicorns', {stdio: 'ignore', all: true});\nexpectType<null>(ignoreAllSubprocess.stdin);\nexpectType<null>(ignoreAllSubprocess.stdio[0]);\nexpectType<null>(ignoreAllSubprocess.stdout);\nexpectType<null>(ignoreAllSubprocess.stdio[1]);\nexpectType<null>(ignoreAllSubprocess.stderr);\nexpectType<null>(ignoreAllSubprocess.stdio[2]);\nexpectType<undefined>(ignoreAllSubprocess.all);\nexpectError(ignoreAllSubprocess.stdio[3].destroy());\n\nconst ignoreAllResult = await ignoreAllSubprocess;\nexpectType<undefined>(ignoreAllResult.stdout);\nexpectType<undefined>(ignoreAllResult.stdio[1]);\nexpectType<undefined>(ignoreAllResult.stderr);\nexpectType<undefined>(ignoreAllResult.stdio[2]);\nexpectType<undefined>(ignoreAllResult.all);\n\nconst ignoreStdioArraySubprocess = execa('unicorns', {stdio: ['ignore', 'ignore', 'pipe', 'pipe'], all: true});\nexpectType<null>(ignoreStdioArraySubprocess.stdin);\nexpectType<null>(ignoreStdioArraySubprocess.stdio[0]);\nexpectType<null>(ignoreStdioArraySubprocess.stdout);\nexpectType<null>(ignoreStdioArraySubprocess.stdio[1]);\nexpectType<Readable>(ignoreStdioArraySubprocess.stderr);\nexpectType<Readable>(ignoreStdioArraySubprocess.stdio[2]);\nexpectType<Readable>(ignoreStdioArraySubprocess.all);\nexpectType<Readable>(ignoreStdioArraySubprocess.stdio[3]);\nconst ignoreStdioArrayResult = await ignoreStdioArraySubprocess;\nexpectType<undefined>(ignoreStdioArrayResult.stdout);\nexpectType<undefined>(ignoreStdioArrayResult.stdio[1]);\nexpectType<string>(ignoreStdioArrayResult.stderr);\nexpectType<string>(ignoreStdioArrayResult.stdio[2]);\nexpectType<string>(ignoreStdioArrayResult.all);\n\nconst ignoreStdioArrayReadSubprocess = execa('unicorns', {stdio: ['ignore', 'ignore', 'pipe', new Uint8Array()], all: true});\nexpectType<Writable>(ignoreStdioArrayReadSubprocess.stdio[3]);\n\nconst ignoreStdinSubprocess = execa('unicorns', {stdin: 'ignore'});\nexpectType<null>(ignoreStdinSubprocess.stdin);\n\nconst ignoreStdoutSubprocess = execa('unicorns', {stdout: 'ignore', all: true});\nexpectType<Writable>(ignoreStdoutSubprocess.stdin);\nexpectType<Writable>(ignoreStdoutSubprocess.stdio[0]);\nexpectType<null>(ignoreStdoutSubprocess.stdout);\nexpectType<null>(ignoreStdoutSubprocess.stdio[1]);\nexpectType<Readable>(ignoreStdoutSubprocess.stderr);\nexpectType<Readable>(ignoreStdoutSubprocess.stdio[2]);\nexpectType<Readable>(ignoreStdoutSubprocess.all);\nexpectError(ignoreStdoutSubprocess.stdio[3].destroy());\n\nconst ignoreStdoutResult = await ignoreStdoutSubprocess;\nexpectType<undefined>(ignoreStdoutResult.stdout);\nexpectType<string>(ignoreStdoutResult.stderr);\nexpectType<string>(ignoreStdoutResult.all);\n\nconst ignoreStderrSubprocess = execa('unicorns', {stderr: 'ignore', all: true});\nexpectType<Writable>(ignoreStderrSubprocess.stdin);\nexpectType<Writable>(ignoreStderrSubprocess.stdio[0]);\nexpectType<Readable>(ignoreStderrSubprocess.stdout);\nexpectType<Readable>(ignoreStderrSubprocess.stdio[1]);\nexpectType<null>(ignoreStderrSubprocess.stderr);\nexpectType<null>(ignoreStderrSubprocess.stdio[2]);\nexpectType<Readable>(ignoreStderrSubprocess.all);\nexpectError(ignoreStderrSubprocess.stdio[3].destroy());\n\nconst ignoreStderrResult = await ignoreStderrSubprocess;\nexpectType<string>(ignoreStderrResult.stdout);\nexpectType<undefined>(ignoreStderrResult.stderr);\nexpectType<string>(ignoreStderrResult.all);\n\nconst ignoreStdioSubprocess = execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ignore'], all: true});\nexpectType<Writable>(ignoreStdioSubprocess.stdin);\nexpectType<Writable>(ignoreStdioSubprocess.stdio[0]);\nexpectType<Readable>(ignoreStdioSubprocess.stdout);\nexpectType<Readable>(ignoreStdioSubprocess.stdio[1]);\nexpectType<Readable>(ignoreStdioSubprocess.stderr);\nexpectType<Readable>(ignoreStdioSubprocess.stdio[2]);\nexpectType<Readable>(ignoreStdioSubprocess.all);\nexpectType<null>(ignoreStdioSubprocess.stdio[3]);\n\nconst ignoreStdioResult = await ignoreStdioSubprocess;\nexpectType<string>(ignoreStdioResult.stdout);\nexpectType<string>(ignoreStdioResult.stderr);\nexpectType<string>(ignoreStdioResult.all);\n\nconst ignoreStdoutResultSync = execaSync('unicorns', {stdout: 'ignore', all: true});\nexpectType<undefined>(ignoreStdoutResultSync.stdout);\nexpectType<undefined>(ignoreStdoutResultSync.stdio[1]);\nexpectType<string>(ignoreStdoutResultSync.stderr);\nexpectType<string>(ignoreStdoutResultSync.stdio[2]);\nexpectType<string>(ignoreStdoutResultSync.all);\n\nconst ignoreStderrResultSync = execaSync('unicorns', {stderr: 'ignore', all: true});\nexpectType<string>(ignoreStderrResultSync.stdout);\nexpectType<undefined>(ignoreStderrResultSync.stderr);\nexpectType<string>(ignoreStderrResultSync.all);\n\nconst ignoreFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ignore']});\nexpectType<undefined>(ignoreFd3Result.stdio[3]);\n\nconst ignoreStdoutError = new Error('.') as ExecaError<{stdout: 'ignore'; all: true}>;\nexpectType<undefined>(ignoreStdoutError.stdout);\nexpectType<undefined>(ignoreStdoutError.stdio[1]);\nexpectType<string>(ignoreStdoutError.stderr);\nexpectType<string>(ignoreStdoutError.stdio[2]);\nexpectType<string>(ignoreStdoutError.all);\n\nconst ignoreStderrError = new Error('.') as ExecaError<{stderr: 'ignore'; all: true}>;\nexpectType<string>(ignoreStderrError.stdout);\nexpectType<undefined>(ignoreStderrError.stderr);\nexpectType<string>(ignoreStderrError.all);\n\nconst ignoreStdoutErrorSync = new Error('.') as ExecaSyncError<{stdout: 'ignore'; all: true}>;\nexpectType<undefined>(ignoreStdoutErrorSync.stdout);\nexpectType<undefined>(ignoreStdoutErrorSync.stdio[1]);\nexpectType<string>(ignoreStdoutErrorSync.stderr);\nexpectType<string>(ignoreStdoutErrorSync.stdio[2]);\nexpectType<string>(ignoreStdoutErrorSync.all);\n\nconst ignoreStderrErrorSync = new Error('.') as ExecaSyncError<{stderr: 'ignore'; all: true}>;\nexpectType<string>(ignoreStderrErrorSync.stdout);\nexpectType<undefined>(ignoreStderrErrorSync.stderr);\nexpectType<string>(ignoreStderrErrorSync.all);\n"
  },
  {
    "path": "test-d/return/ignore-other.test-d.ts",
    "content": "import * as process from 'node:process';\nimport {expectType} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n} from '../../index.js';\n\nconst inheritStdoutResult = await execa('unicorns', {stdout: 'inherit', all: true});\nexpectType<undefined>(inheritStdoutResult.stdout);\nexpectType<string>(inheritStdoutResult.stderr);\nexpectType<string>(inheritStdoutResult.all);\n\nconst inheritStderrResult = await execa('unicorns', {stderr: 'inherit', all: true});\nexpectType<string>(inheritStderrResult.stdout);\nexpectType<undefined>(inheritStderrResult.stderr);\nexpectType<string>(inheritStderrResult.all);\n\nconst inheritArrayStdoutResult = await execa('unicorns', {stdout: ['inherit'] as ['inherit'], all: true});\nexpectType<undefined>(inheritArrayStdoutResult.stdout);\nexpectType<string>(inheritArrayStdoutResult.stderr);\nexpectType<string>(inheritArrayStdoutResult.all);\n\nconst inheritArrayStderrResult = await execa('unicorns', {stderr: ['inherit'] as ['inherit'], all: true});\nexpectType<string>(inheritArrayStderrResult.stdout);\nexpectType<undefined>(inheritArrayStderrResult.stderr);\nexpectType<string>(inheritArrayStderrResult.all);\n\nconst inheritStdoutResultSync = execaSync('unicorns', {stdout: 'inherit', all: true});\nexpectType<undefined>(inheritStdoutResultSync.stdout);\nexpectType<string>(inheritStdoutResultSync.stderr);\nexpectType<string>(inheritStdoutResultSync.all);\n\nconst inheritStderrResultSync = execaSync('unicorns', {stderr: 'inherit', all: true});\nexpectType<string>(inheritStderrResultSync.stdout);\nexpectType<undefined>(inheritStderrResultSync.stderr);\nexpectType<string>(inheritStderrResultSync.all);\n\nconst inheritStdoutError = new Error('.') as ExecaError<{stdout: 'inherit'; all: true}>;\nexpectType<undefined>(inheritStdoutError.stdout);\nexpectType<string>(inheritStdoutError.stderr);\nexpectType<string>(inheritStdoutError.all);\n\nconst inheritStderrError = new Error('.') as ExecaError<{stderr: 'inherit'; all: true}>;\nexpectType<string>(inheritStderrError.stdout);\nexpectType<undefined>(inheritStderrError.stderr);\nexpectType<string>(inheritStderrError.all);\n\nconst inheritStdoutErrorSync = new Error('.') as ExecaSyncError<{stdout: 'inherit'; all: true}>;\nexpectType<undefined>(inheritStdoutErrorSync.stdout);\nexpectType<string>(inheritStdoutErrorSync.stderr);\nexpectType<string>(inheritStdoutErrorSync.all);\n\nconst inheritStderrErrorSync = new Error('.') as ExecaSyncError<{stderr: 'inherit'; all: true}>;\nexpectType<string>(inheritStderrErrorSync.stdout);\nexpectType<undefined>(inheritStderrErrorSync.stderr);\nexpectType<string>(inheritStderrErrorSync.all);\n\nconst ipcStdoutResult = await execa('unicorns', {stdout: 'ipc', all: true});\nexpectType<undefined>(ipcStdoutResult.stdout);\nexpectType<string>(ipcStdoutResult.stderr);\nexpectType<string>(ipcStdoutResult.all);\n\nconst ipcStderrResult = await execa('unicorns', {stderr: 'ipc', all: true});\nexpectType<string>(ipcStderrResult.stdout);\nexpectType<undefined>(ipcStderrResult.stderr);\nexpectType<string>(ipcStderrResult.all);\n\nconst ipcStdoutError = new Error('.') as ExecaError<{stdout: 'ipc'; all: true}>;\nexpectType<undefined>(ipcStdoutError.stdout);\nexpectType<string>(ipcStdoutError.stderr);\nexpectType<string>(ipcStdoutError.all);\n\nconst ipcStderrError = new Error('.') as ExecaError<{stderr: 'ipc'; all: true}>;\nexpectType<string>(ipcStderrError.stdout);\nexpectType<undefined>(ipcStderrError.stderr);\nexpectType<string>(ipcStderrError.all);\n\nconst streamStdoutResult = await execa('unicorns', {stdout: process.stdout, all: true});\nexpectType<undefined>(streamStdoutResult.stdout);\nexpectType<string>(streamStdoutResult.stderr);\nexpectType<string>(streamStdoutResult.all);\n\nconst streamArrayStdoutResult = await execa('unicorns', {stdout: [process.stdout] as [typeof process.stdout], all: true});\nexpectType<undefined>(streamArrayStdoutResult.stdout);\nexpectType<string>(streamArrayStdoutResult.stderr);\nexpectType<string>(streamArrayStdoutResult.all);\n\nconst streamStderrResult = await execa('unicorns', {stderr: process.stdout, all: true});\nexpectType<string>(streamStderrResult.stdout);\nexpectType<undefined>(streamStderrResult.stderr);\nexpectType<string>(streamStderrResult.all);\n\nconst streamArrayStderrResult = await execa('unicorns', {stderr: [process.stdout] as [typeof process.stdout], all: true});\nexpectType<string>(streamArrayStderrResult.stdout);\nexpectType<undefined>(streamArrayStderrResult.stderr);\nexpectType<string>(streamArrayStderrResult.all);\n\nconst streamStdoutError = new Error('.') as ExecaError<{stdout: typeof process.stdout; all: true}>;\nexpectType<undefined>(streamStdoutError.stdout);\nexpectType<string>(streamStdoutError.stderr);\nexpectType<string>(streamStdoutError.all);\n\nconst streamStderrError = new Error('.') as ExecaError<{stderr: typeof process.stdout; all: true}>;\nexpectType<string>(streamStderrError.stdout);\nexpectType<undefined>(streamStderrError.stderr);\nexpectType<string>(streamStderrError.all);\n\nconst numberStdoutResult = await execa('unicorns', {stdout: 1, all: true});\nexpectType<undefined>(numberStdoutResult.stdout);\nexpectType<string>(numberStdoutResult.stderr);\nexpectType<string>(numberStdoutResult.all);\n\nconst numberStderrResult = await execa('unicorns', {stderr: 1, all: true});\nexpectType<string>(numberStderrResult.stdout);\nexpectType<undefined>(numberStderrResult.stderr);\nexpectType<string>(numberStderrResult.all);\n\nconst numberArrayStdoutResult = await execa('unicorns', {stdout: [1] as [1], all: true});\nexpectType<undefined>(numberArrayStdoutResult.stdout);\nexpectType<string>(numberArrayStdoutResult.stderr);\nexpectType<string>(numberArrayStdoutResult.all);\n\nconst numberArrayStderrResult = await execa('unicorns', {stderr: [1] as [1], all: true});\nexpectType<string>(numberArrayStderrResult.stdout);\nexpectType<undefined>(numberArrayStderrResult.stderr);\nexpectType<string>(numberArrayStderrResult.all);\n\nconst numberStdoutResultSync = execaSync('unicorns', {stdout: 1, all: true});\nexpectType<undefined>(numberStdoutResultSync.stdout);\nexpectType<string>(numberStdoutResultSync.stderr);\nexpectType<string>(numberStdoutResultSync.all);\n\nconst numberStderrResultSync = execaSync('unicorns', {stderr: 1, all: true});\nexpectType<string>(numberStderrResultSync.stdout);\nexpectType<undefined>(numberStderrResultSync.stderr);\nexpectType<string>(numberStderrResultSync.all);\n\nconst numberStdoutError = new Error('.') as ExecaError<{stdout: 1; all: true}>;\nexpectType<undefined>(numberStdoutError.stdout);\nexpectType<string>(numberStdoutError.stderr);\nexpectType<string>(numberStdoutError.all);\n\nconst numberStderrError = new Error('.') as ExecaError<{stderr: 1; all: true}>;\nexpectType<string>(numberStderrError.stdout);\nexpectType<undefined>(numberStderrError.stderr);\nexpectType<string>(numberStderrError.all);\n\nconst numberStdoutErrorSync = new Error('.') as ExecaSyncError<{stdout: 1; all: true}>;\nexpectType<undefined>(numberStdoutErrorSync.stdout);\nexpectType<string>(numberStdoutErrorSync.stderr);\nexpectType<string>(numberStdoutErrorSync.all);\n\nconst numberStderrErrorSync = new Error('.') as ExecaSyncError<{stderr: 1; all: true}>;\nexpectType<string>(numberStderrErrorSync.stdout);\nexpectType<undefined>(numberStderrErrorSync.stderr);\nexpectType<string>(numberStderrErrorSync.all);\n"
  },
  {
    "path": "test-d/return/lines-main.test-d.ts",
    "content": "import {expectType} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n} from '../../index.js';\n\nconst linesResult = await execa('unicorns', {lines: true, all: true});\nexpectType<string[]>(linesResult.stdout);\nexpectType<string[]>(linesResult.stdio[1]);\nexpectType<string[]>(linesResult.stderr);\nexpectType<string[]>(linesResult.stdio[2]);\nexpectType<string[]>(linesResult.all);\n\nconst linesBufferResult = await execa('unicorns', {lines: true, encoding: 'buffer', all: true});\nexpectType<Uint8Array>(linesBufferResult.stdout);\nexpectType<Uint8Array>(linesBufferResult.stdio[1]);\nexpectType<Uint8Array>(linesBufferResult.stderr);\nexpectType<Uint8Array>(linesBufferResult.stdio[2]);\nexpectType<Uint8Array>(linesBufferResult.all);\n\nconst linesHexResult = await execa('unicorns', {lines: true, encoding: 'hex', all: true});\nexpectType<string>(linesHexResult.stdout);\nexpectType<string>(linesHexResult.stdio[1]);\nexpectType<string>(linesHexResult.stderr);\nexpectType<string>(linesHexResult.stdio[2]);\nexpectType<string>(linesHexResult.all);\n\nconst linesFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], lines: true});\nexpectType<string[]>(linesFd3Result.stdio[3]);\n\nconst linesBufferFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], lines: true, encoding: 'buffer'});\nexpectType<Uint8Array>(linesBufferFd3Result.stdio[3]);\n\nconst execaLinesError = new Error('.') as ExecaError<{lines: true; all: true}>;\nexpectType<string[]>(execaLinesError.stdout);\nexpectType<string[]>(execaLinesError.stdio[1]);\nexpectType<string[]>(execaLinesError.stderr);\nexpectType<string[]>(execaLinesError.stdio[2]);\nexpectType<string[]>(execaLinesError.all);\n\nconst execaLinesBufferError = new Error('.') as ExecaError<{lines: true; encoding: 'buffer'; all: true}>;\nexpectType<Uint8Array>(execaLinesBufferError.stdout);\nexpectType<Uint8Array>(execaLinesBufferError.stdio[1]);\nexpectType<Uint8Array>(execaLinesBufferError.stderr);\nexpectType<Uint8Array>(execaLinesBufferError.stdio[2]);\nexpectType<Uint8Array>(execaLinesBufferError.all);\n\nconst linesResultSync = execaSync('unicorns', {lines: true, all: true});\nexpectType<string[]>(linesResultSync.stdout);\nexpectType<string[]>(linesResultSync.stderr);\nexpectType<string[]>(linesResultSync.all);\n\nconst linesBufferResultSync = execaSync('unicorns', {lines: true, encoding: 'buffer', all: true});\nexpectType<Uint8Array>(linesBufferResultSync.stdout);\nexpectType<Uint8Array>(linesBufferResultSync.stderr);\nexpectType<Uint8Array>(linesBufferResultSync.all);\n\nconst linesHexResultSync = execaSync('unicorns', {lines: true, encoding: 'hex', all: true});\nexpectType<string>(linesHexResultSync.stdout);\nexpectType<string>(linesHexResultSync.stderr);\nexpectType<string>(linesHexResultSync.all);\n\nconst execaLinesErrorSync = new Error('.') as ExecaSyncError<{lines: true; all: true}>;\nexpectType<string[]>(execaLinesErrorSync.stdout);\nexpectType<string[]>(execaLinesErrorSync.stderr);\nexpectType<string[]>(execaLinesErrorSync.all);\n\nconst execaLinesBufferErrorSync = new Error('.') as ExecaSyncError<{lines: true; encoding: 'buffer'; all: true}>;\nexpectType<Uint8Array>(execaLinesBufferErrorSync.stdout);\nexpectType<Uint8Array>(execaLinesBufferErrorSync.stderr);\nexpectType<Uint8Array>(execaLinesBufferErrorSync.all);\n"
  },
  {
    "path": "test-d/return/lines-specific.test-d.ts",
    "content": "import {expectType} from 'tsd';\nimport {execa, execaSync} from '../../index.js';\n\nconst linesStdoutResult = await execa('unicorns', {all: true, lines: {stdout: true}});\nexpectType<string[]>(linesStdoutResult.stdout);\nexpectType<string[]>(linesStdoutResult.stdio[1]);\nexpectType<string>(linesStdoutResult.stderr);\nexpectType<string>(linesStdoutResult.stdio[2]);\nexpectType<string[]>(linesStdoutResult.all);\n\nconst linesStderrResult = await execa('unicorns', {all: true, lines: {stderr: true}});\nexpectType<string>(linesStderrResult.stdout);\nexpectType<string>(linesStderrResult.stdio[1]);\nexpectType<string[]>(linesStderrResult.stderr);\nexpectType<string[]>(linesStderrResult.stdio[2]);\nexpectType<string[]>(linesStderrResult.all);\n\nconst linesFd1Result = await execa('unicorns', {all: true, lines: {fd1: true}});\nexpectType<string[]>(linesFd1Result.stdout);\nexpectType<string[]>(linesFd1Result.stdio[1]);\nexpectType<string>(linesFd1Result.stderr);\nexpectType<string>(linesFd1Result.stdio[2]);\nexpectType<string[]>(linesFd1Result.all);\n\nconst linesFd2Result = await execa('unicorns', {all: true, lines: {fd2: true}});\nexpectType<string>(linesFd2Result.stdout);\nexpectType<string>(linesFd2Result.stdio[1]);\nexpectType<string[]>(linesFd2Result.stderr);\nexpectType<string[]>(linesFd2Result.stdio[2]);\nexpectType<string[]>(linesFd2Result.all);\n\nconst linesAllResult = await execa('unicorns', {all: true, lines: {all: true}});\nexpectType<string[]>(linesAllResult.stdout);\nexpectType<string[]>(linesAllResult.stdio[1]);\nexpectType<string[]>(linesAllResult.stderr);\nexpectType<string[]>(linesAllResult.stdio[2]);\nexpectType<string[]>(linesAllResult.all);\n\nconst linesFd3Result = await execa('unicorns', {all: true, lines: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe']});\nexpectType<string>(linesFd3Result.stdout);\nexpectType<string>(linesFd3Result.stdio[1]);\nexpectType<string>(linesFd3Result.stderr);\nexpectType<string>(linesFd3Result.stdio[2]);\nexpectType<string>(linesFd3Result.all);\nexpectType<string[]>(linesFd3Result.stdio[3]);\nexpectType<string>(linesFd3Result.stdio[4]);\n\nconst linesStdoutResultSync = execaSync('unicorns', {all: true, lines: {stdout: true}});\nexpectType<string[]>(linesStdoutResultSync.stdout);\nexpectType<string[]>(linesStdoutResultSync.stdio[1]);\nexpectType<string>(linesStdoutResultSync.stderr);\nexpectType<string>(linesStdoutResultSync.stdio[2]);\nexpectType<string[]>(linesStdoutResultSync.all);\n\nconst linesStderrResultSync = execaSync('unicorns', {all: true, lines: {stderr: true}});\nexpectType<string>(linesStderrResultSync.stdout);\nexpectType<string>(linesStderrResultSync.stdio[1]);\nexpectType<string[]>(linesStderrResultSync.stderr);\nexpectType<string[]>(linesStderrResultSync.stdio[2]);\nexpectType<string[]>(linesStderrResultSync.all);\n\nconst linesFd1ResultSync = execaSync('unicorns', {all: true, lines: {fd1: true}});\nexpectType<string[]>(linesFd1ResultSync.stdout);\nexpectType<string[]>(linesFd1ResultSync.stdio[1]);\nexpectType<string>(linesFd1ResultSync.stderr);\nexpectType<string>(linesFd1ResultSync.stdio[2]);\nexpectType<string[]>(linesFd1ResultSync.all);\n\nconst linesFd2ResultSync = execaSync('unicorns', {all: true, lines: {fd2: true}});\nexpectType<string>(linesFd2ResultSync.stdout);\nexpectType<string>(linesFd2ResultSync.stdio[1]);\nexpectType<string[]>(linesFd2ResultSync.stderr);\nexpectType<string[]>(linesFd2ResultSync.stdio[2]);\nexpectType<string[]>(linesFd2ResultSync.all);\n\nconst linesAllResultSync = execaSync('unicorns', {all: true, lines: {all: true}});\nexpectType<string[]>(linesAllResultSync.stdout);\nexpectType<string[]>(linesAllResultSync.stdio[1]);\nexpectType<string[]>(linesAllResultSync.stderr);\nexpectType<string[]>(linesAllResultSync.stdio[2]);\nexpectType<string[]>(linesAllResultSync.all);\n\nconst linesFd3ResultSync = execaSync('unicorns', {all: true, lines: {fd3: true}, stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe']});\nexpectType<string>(linesFd3ResultSync.stdout);\nexpectType<string>(linesFd3ResultSync.stdio[1]);\nexpectType<string>(linesFd3ResultSync.stderr);\nexpectType<string>(linesFd3ResultSync.stdio[2]);\nexpectType<string>(linesFd3ResultSync.all);\nexpectType<string[]>(linesFd3ResultSync.stdio[3]);\nexpectType<string>(linesFd3ResultSync.stdio[4]);\n"
  },
  {
    "path": "test-d/return/no-buffer-main.test-d.ts",
    "content": "import type {Readable, Writable} from 'node:stream';\nimport {expectType, expectError} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n} from '../../index.js';\n\nconst noBufferSubprocess = execa('unicorns', {buffer: false, all: true});\nexpectType<Writable>(noBufferSubprocess.stdin);\nexpectType<Writable>(noBufferSubprocess.stdio[0]);\nexpectType<Readable>(noBufferSubprocess.stdout);\nexpectType<Readable>(noBufferSubprocess.stdio[1]);\nexpectType<Readable>(noBufferSubprocess.stderr);\nexpectType<Readable>(noBufferSubprocess.stdio[2]);\nexpectType<Readable>(noBufferSubprocess.all);\nexpectError(noBufferSubprocess.stdio[3].destroy());\n\nconst noBufferResult = await noBufferSubprocess;\nexpectType<undefined>(noBufferResult.stdout);\nexpectType<undefined>(noBufferResult.stdio[1]);\nexpectType<undefined>(noBufferResult.stderr);\nexpectType<undefined>(noBufferResult.stdio[2]);\nexpectType<undefined>(noBufferResult.all);\n\nconst noBufferResultSync = execaSync('unicorns', {buffer: false, all: true});\nexpectType<undefined>(noBufferResultSync.stdout);\nexpectType<undefined>(noBufferResultSync.stderr);\nexpectType<undefined>(noBufferResultSync.all);\n\nconst noBuffer3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], buffer: false});\nexpectType<undefined>(noBuffer3Result.stdio[3]);\n\nconst noBufferError = new Error('.') as ExecaError<{buffer: false; all: true}>;\nexpectType<undefined>(noBufferError.stdout);\nexpectType<undefined>(noBufferError.stdio[1]);\nexpectType<undefined>(noBufferError.stderr);\nexpectType<undefined>(noBufferError.stdio[2]);\nexpectType<undefined>(noBufferError.all);\n\nconst noBufferErrorSync = new Error('.') as ExecaSyncError<{buffer: false; all: true}>;\nexpectType<undefined>(noBufferErrorSync.stdout);\nexpectType<undefined>(noBufferErrorSync.stderr);\nexpectType<undefined>(noBufferErrorSync.all);\n"
  },
  {
    "path": "test-d/return/no-buffer-specific.test-d.ts",
    "content": "import {expectType} from 'tsd';\nimport {execa, execaSync} from '../../index.js';\n\nconst noBufferStdoutResult = await execa('unicorns', {all: true, buffer: {stdout: false}});\nexpectType<undefined>(noBufferStdoutResult.stdout);\nexpectType<undefined>(noBufferStdoutResult.stdio[1]);\nexpectType<string>(noBufferStdoutResult.stderr);\nexpectType<string>(noBufferStdoutResult.stdio[2]);\nexpectType<string>(noBufferStdoutResult.all);\n\nconst noBufferStderrResult = await execa('unicorns', {all: true, buffer: {stderr: false}});\nexpectType<string>(noBufferStderrResult.stdout);\nexpectType<string>(noBufferStderrResult.stdio[1]);\nexpectType<undefined>(noBufferStderrResult.stderr);\nexpectType<undefined>(noBufferStderrResult.stdio[2]);\nexpectType<string>(noBufferStderrResult.all);\n\nconst noBufferFd1Result = await execa('unicorns', {all: true, buffer: {fd1: false}});\nexpectType<undefined>(noBufferFd1Result.stdout);\nexpectType<undefined>(noBufferFd1Result.stdio[1]);\nexpectType<string>(noBufferFd1Result.stderr);\nexpectType<string>(noBufferFd1Result.stdio[2]);\nexpectType<string>(noBufferFd1Result.all);\n\nconst noBufferFd2Result = await execa('unicorns', {all: true, buffer: {fd2: false}});\nexpectType<string>(noBufferFd2Result.stdout);\nexpectType<string>(noBufferFd2Result.stdio[1]);\nexpectType<undefined>(noBufferFd2Result.stderr);\nexpectType<undefined>(noBufferFd2Result.stdio[2]);\nexpectType<string>(noBufferFd2Result.all);\n\nconst noBufferAllResult = await execa('unicorns', {all: true, buffer: {all: false}});\nexpectType<undefined>(noBufferAllResult.stdout);\nexpectType<undefined>(noBufferAllResult.stdio[1]);\nexpectType<undefined>(noBufferAllResult.stderr);\nexpectType<undefined>(noBufferAllResult.stdio[2]);\nexpectType<undefined>(noBufferAllResult.all);\n\nconst noBufferFd3Result = await execa('unicorns', {all: true, buffer: {fd3: false}, stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe']});\nexpectType<string>(noBufferFd3Result.stdout);\nexpectType<string>(noBufferFd3Result.stdio[1]);\nexpectType<string>(noBufferFd3Result.stderr);\nexpectType<string>(noBufferFd3Result.stdio[2]);\nexpectType<string>(noBufferFd3Result.all);\nexpectType<undefined>(noBufferFd3Result.stdio[3]);\nexpectType<string>(noBufferFd3Result.stdio[4]);\n\nconst noBufferStdoutResultSync = execaSync('unicorns', {all: true, buffer: {stdout: false}});\nexpectType<undefined>(noBufferStdoutResultSync.stdout);\nexpectType<undefined>(noBufferStdoutResultSync.stdio[1]);\nexpectType<string>(noBufferStdoutResultSync.stderr);\nexpectType<string>(noBufferStdoutResultSync.stdio[2]);\nexpectType<string>(noBufferStdoutResultSync.all);\n\nconst noBufferStderrResultSync = execaSync('unicorns', {all: true, buffer: {stderr: false}});\nexpectType<string>(noBufferStderrResultSync.stdout);\nexpectType<string>(noBufferStderrResultSync.stdio[1]);\nexpectType<undefined>(noBufferStderrResultSync.stderr);\nexpectType<undefined>(noBufferStderrResultSync.stdio[2]);\nexpectType<string>(noBufferStderrResultSync.all);\n\nconst noBufferFd1ResultSync = execaSync('unicorns', {all: true, buffer: {fd1: false}});\nexpectType<undefined>(noBufferFd1ResultSync.stdout);\nexpectType<undefined>(noBufferFd1ResultSync.stdio[1]);\nexpectType<string>(noBufferFd1ResultSync.stderr);\nexpectType<string>(noBufferFd1ResultSync.stdio[2]);\nexpectType<string>(noBufferFd1ResultSync.all);\n\nconst noBufferFd2ResultSync = execaSync('unicorns', {all: true, buffer: {fd2: false}});\nexpectType<string>(noBufferFd2ResultSync.stdout);\nexpectType<string>(noBufferFd2ResultSync.stdio[1]);\nexpectType<undefined>(noBufferFd2ResultSync.stderr);\nexpectType<undefined>(noBufferFd2ResultSync.stdio[2]);\nexpectType<string>(noBufferFd2ResultSync.all);\n\nconst noBufferAllResultSync = execaSync('unicorns', {all: true, buffer: {all: false}});\nexpectType<undefined>(noBufferAllResultSync.stdout);\nexpectType<undefined>(noBufferAllResultSync.stdio[1]);\nexpectType<undefined>(noBufferAllResultSync.stderr);\nexpectType<undefined>(noBufferAllResultSync.stdio[2]);\nexpectType<undefined>(noBufferAllResultSync.all);\n\nconst noBufferFd3ResultSync = execaSync('unicorns', {all: true, buffer: {fd3: false}, stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe']});\nexpectType<string>(noBufferFd3ResultSync.stdout);\nexpectType<string>(noBufferFd3ResultSync.stdio[1]);\nexpectType<string>(noBufferFd3ResultSync.stderr);\nexpectType<string>(noBufferFd3ResultSync.stdio[2]);\nexpectType<string>(noBufferFd3ResultSync.all);\nexpectType<undefined>(noBufferFd3ResultSync.stdio[3]);\nexpectType<string>(noBufferFd3ResultSync.stdio[4]);\n"
  },
  {
    "path": "test-d/return/result-all.test-d.ts",
    "content": "import {expectType} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n} from '../../index.js';\n\nconst allResult = await execa('unicorns', {all: true});\nexpectType<string>(allResult.all);\n\nconst noAllResult = await execa('unicorns');\nexpectType<undefined>(noAllResult.all);\n\nconst allResultSync = execaSync('unicorns', {all: true});\nexpectType<string>(allResultSync.all);\n\nconst noAllResultSync = execaSync('unicorns');\nexpectType<undefined>(noAllResultSync.all);\n\nconst allError = new Error('.') as ExecaError<{all: true}>;\nexpectType<string>(allError.all);\n\nconst noAllError = new Error('.') as ExecaError<{}>;\nexpectType<undefined>(noAllError.all);\n\nconst allErrorSync = new Error('.') as ExecaError<{all: true}>;\nexpectType<string>(allErrorSync.all);\n\nconst noAllErrorSync = new Error('.') as ExecaSyncError<{}>;\nexpectType<undefined>(noAllErrorSync.all);\n"
  },
  {
    "path": "test-d/return/result-ipc.ts",
    "content": "import {expectAssignable, expectType} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype Result,\n\ttype SyncResult,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n\ttype Message,\n\ttype Options,\n} from '../../index.js';\n\nconst ipcResult = await execa('unicorns', {ipc: true});\nexpectType<Array<Message<'advanced'>>>(ipcResult.ipcOutput);\n\nconst ipcFdResult = await execa('unicorns', {ipc: true, buffer: {stdout: false}});\nexpectType<Array<Message<'advanced'>>>(ipcFdResult.ipcOutput);\n\nconst advancedResult = await execa('unicorns', {ipc: true, serialization: 'advanced'});\nexpectType<Array<Message<'advanced'>>>(advancedResult.ipcOutput);\n\nconst jsonResult = await execa('unicorns', {ipc: true, serialization: 'json'});\nexpectType<Array<Message<'json'>>>(jsonResult.ipcOutput);\n\nconst inputResult = await execa('unicorns', {ipcInput: ''});\nexpectType<Array<Message<'advanced'>>>(inputResult.ipcOutput);\n\nconst genericInputResult = await execa('unicorns', {ipcInput: '' as Message});\nexpectType<Array<Message<'advanced'>>>(genericInputResult.ipcOutput);\n\nconst gracefulResult = await execa('unicorns', {gracefulCancel: true, cancelSignal: AbortSignal.abort()});\nexpectType<Array<Message<'advanced'>>>(gracefulResult.ipcOutput);\n\nconst genericResult = await execa('unicorns', {} as Options);\nexpectType<Message[] | []>(genericResult.ipcOutput);\n\nconst genericIpc = await execa('unicorns', {ipc: true as boolean});\nexpectType<Array<Message<'advanced'>> | []>(genericIpc.ipcOutput);\n\nconst maybeInputResult = await execa('unicorns', {ipcInput: '' as '' | undefined});\nexpectType<Array<Message<'advanced'>> | []>(maybeInputResult.ipcOutput);\n\nconst maybeGracefulResult = await execa('unicorns', {gracefulCancel: true as boolean | undefined, cancelSignal: AbortSignal.abort()});\nexpectType<Array<Message<'advanced'>> | []>(maybeGracefulResult.ipcOutput);\n\nconst falseIpcResult = await execa('unicorns', {ipc: false});\nexpectType<[]>(falseIpcResult.ipcOutput);\n\nconst noIpcResult = await execa('unicorns');\nexpectType<[]>(noIpcResult.ipcOutput);\n\nconst emptyIpcResult = await execa('unicorns', {});\nexpectType<[]>(emptyIpcResult.ipcOutput);\n\nconst undefinedInputResult = await execa('unicorns', {ipcInput: undefined});\nexpectType<[]>(undefinedInputResult.ipcOutput);\n\nconst inputNoIpcResult = await execa('unicorns', {ipc: false, ipcInput: ''});\nexpectType<[]>(inputNoIpcResult.ipcOutput);\n\nconst undefinedGracefulResult = await execa('unicorns', {gracefulCancel: undefined});\nexpectType<[]>(undefinedGracefulResult.ipcOutput);\n\nconst falseGracefulResult = await execa('unicorns', {gracefulCancel: false});\nexpectType<[]>(falseGracefulResult.ipcOutput);\n\nconst gracefulNoIpcResult = await execa('unicorns', {ipc: false, gracefulCancel: true, cancelSignal: AbortSignal.abort()});\nexpectType<[]>(gracefulNoIpcResult.ipcOutput);\n\nconst noBufferResult = await execa('unicorns', {ipc: true, buffer: false});\nexpectType<[]>(noBufferResult.ipcOutput);\n\nconst noBufferFdResult = await execa('unicorns', {ipc: true, buffer: {ipc: false}});\nexpectType<[]>(noBufferFdResult.ipcOutput);\n\nconst syncResult = execaSync('unicorns');\nexpectType<[]>(syncResult.ipcOutput);\n\nexpectType<Message[] | []>({} as Result['ipcOutput']);\nexpectAssignable<Message[]>({} as Result['ipcOutput']);\nexpectType<[]>({} as unknown as SyncResult['ipcOutput']);\n\nconst ipcError = new Error('.') as ExecaError<{ipc: true}>;\nexpectType<Array<Message<'advanced'>>>(ipcError.ipcOutput);\n\nconst ipcFalseError = new Error('.') as ExecaError<{ipc: false}>;\nexpectType<[]>(ipcFalseError.ipcOutput);\n\nconst asyncError = new Error('.') as ExecaError;\nexpectType<Message[] | []>(asyncError.ipcOutput);\nexpectAssignable<Message[]>(asyncError.ipcOutput);\n\nconst syncError = new Error('.') as ExecaSyncError;\nexpectType<[]>(syncError.ipcOutput);\n"
  },
  {
    "path": "test-d/return/result-main.test-d.ts",
    "content": "import type {SignalConstants} from 'node:os';\nimport {expectType, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\tExecaError,\n\tExecaSyncError,\n\ttype Result,\n\ttype SyncResult,\n} from '../../index.js';\n\ntype AnyChunk = string | Uint8Array | string[] | unknown[] | undefined;\nexpectType<AnyChunk>({} as Result['stdout']);\nexpectType<AnyChunk>({} as Result['stderr']);\nexpectType<AnyChunk>({} as Result['all']);\nexpectAssignable<[undefined, AnyChunk, AnyChunk, ...AnyChunk[]]>({} as Result['stdio']);\nexpectType<AnyChunk>({} as SyncResult['stdout']);\nexpectType<AnyChunk>({} as SyncResult['stderr']);\nexpectType<AnyChunk>({} as SyncResult['all']);\nexpectAssignable<[undefined, AnyChunk, AnyChunk, ...AnyChunk[]]>({} as SyncResult['stdio']);\n\nconst unicornsResult = await execa('unicorns', {all: true});\nexpectAssignable<Result>(unicornsResult);\nexpectType<string>(unicornsResult.command);\nexpectType<string>(unicornsResult.escapedCommand);\nexpectType<number | undefined>(unicornsResult.exitCode);\nexpectType<boolean>(unicornsResult.failed);\nexpectType<boolean>(unicornsResult.timedOut);\nexpectType<boolean>(unicornsResult.isCanceled);\nexpectType<boolean>(unicornsResult.isGracefullyCanceled);\nexpectType<boolean>(unicornsResult.isTerminated);\nexpectType<boolean>(unicornsResult.isMaxBuffer);\nexpectType<boolean>(unicornsResult.isForcefullyTerminated);\nexpectType<keyof SignalConstants | undefined>(unicornsResult.signal);\nexpectType<string | undefined>(unicornsResult.signalDescription);\nexpectType<string>(unicornsResult.cwd);\nexpectType<number>(unicornsResult.durationMs);\nexpectType<Result[]>(unicornsResult.pipedFrom);\n\nconst unicornsResultSync = execaSync('unicorns', {all: true});\nexpectAssignable<SyncResult>(unicornsResultSync);\nexpectType<string>(unicornsResultSync.command);\nexpectType<string>(unicornsResultSync.escapedCommand);\nexpectType<number | undefined>(unicornsResultSync.exitCode);\nexpectType<boolean>(unicornsResultSync.failed);\nexpectType<boolean>(unicornsResultSync.timedOut);\nexpectType<boolean>(unicornsResultSync.isCanceled);\nexpectType<boolean>(unicornsResultSync.isGracefullyCanceled);\nexpectType<boolean>(unicornsResultSync.isTerminated);\nexpectType<boolean>(unicornsResultSync.isMaxBuffer);\nexpectType<boolean>(unicornsResultSync.isForcefullyTerminated);\nexpectType<keyof SignalConstants | undefined>(unicornsResultSync.signal);\nexpectType<string | undefined>(unicornsResultSync.signalDescription);\nexpectType<string>(unicornsResultSync.cwd);\nexpectType<number>(unicornsResultSync.durationMs);\nexpectType<[]>(unicornsResultSync.pipedFrom);\n\nconst error = new Error('.');\nif (error instanceof ExecaError) {\n\texpectType<ExecaError<any>>(error);\n\texpectType<'ExecaError'>(error.name);\n\texpectType<string>(error.message);\n\texpectType<number | undefined>(error.exitCode);\n\texpectType<boolean>(error.failed);\n\texpectType<boolean>(error.timedOut);\n\texpectType<boolean>(error.isCanceled);\n\texpectType<boolean>(error.isGracefullyCanceled);\n\texpectType<boolean>(error.isTerminated);\n\texpectType<boolean>(error.isMaxBuffer);\n\texpectType<boolean>(error.isForcefullyTerminated);\n\texpectType<keyof SignalConstants | undefined>(error.signal);\n\texpectType<string | undefined>(error.signalDescription);\n\texpectType<string>(error.cwd);\n\texpectType<number>(error.durationMs);\n\texpectType<string>(error.shortMessage);\n\texpectType<string>(error.originalMessage);\n\texpectType<string | undefined>(error.code);\n\texpectType<unknown>(error.cause);\n\texpectType<Result[]>(error.pipedFrom);\n}\n\nconst errorSync = new Error('.');\nif (errorSync instanceof ExecaSyncError) {\n\texpectType<ExecaSyncError<any>>(errorSync);\n\texpectType<'ExecaSyncError'>(errorSync.name);\n\texpectType<string>(errorSync.message);\n\texpectType<number | undefined>(errorSync.exitCode);\n\texpectType<boolean>(errorSync.failed);\n\texpectType<boolean>(errorSync.timedOut);\n\texpectType<boolean>(errorSync.isCanceled);\n\texpectType<boolean>(errorSync.isGracefullyCanceled);\n\texpectType<boolean>(errorSync.isTerminated);\n\texpectType<boolean>(errorSync.isMaxBuffer);\n\texpectType<boolean>(errorSync.isForcefullyTerminated);\n\texpectType<keyof SignalConstants | undefined>(errorSync.signal);\n\texpectType<string | undefined>(errorSync.signalDescription);\n\texpectType<string>(errorSync.cwd);\n\texpectType<number>(errorSync.durationMs);\n\texpectType<string>(errorSync.shortMessage);\n\texpectType<string>(errorSync.originalMessage);\n\texpectType<string | undefined>(errorSync.code);\n\texpectType<unknown>(errorSync.cause);\n\texpectType<[]>(errorSync.pipedFrom);\n}\n"
  },
  {
    "path": "test-d/return/result-reject.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {\n\ttype Result,\n\ttype SyncResult,\n\texeca,\n\texecaSync,\n} from '../../index.js';\n\nconst rejectsResult = await execa('unicorns');\nexpectAssignable<Result>(rejectsResult);\nexpectError(rejectsResult.stack?.toString());\nexpectError(rejectsResult.message?.toString());\nexpectError(rejectsResult.shortMessage?.toString());\nexpectError(rejectsResult.originalMessage?.toString());\nexpectError(rejectsResult.code?.toString());\nexpectError(rejectsResult.cause?.valueOf());\n\nconst noRejectsResult = await execa('unicorns', {reject: false});\nexpectAssignable<Result>(noRejectsResult);\nexpectType<string | undefined>(noRejectsResult.stack);\nexpectType<string | undefined>(noRejectsResult.message);\nexpectType<string | undefined>(noRejectsResult.shortMessage);\nexpectType<string | undefined>(noRejectsResult.originalMessage);\nexpectType<string | undefined>(noRejectsResult.code);\nexpectType<unknown>(noRejectsResult.cause);\n\nconst rejectsSyncResult = execaSync('unicorns');\nexpectAssignable<SyncResult>(rejectsSyncResult);\nexpectError(rejectsSyncResult.stack?.toString());\nexpectError(rejectsSyncResult.message?.toString());\nexpectError(rejectsSyncResult.shortMessage?.toString());\nexpectError(rejectsSyncResult.originalMessage?.toString());\nexpectError(rejectsSyncResult.code?.toString());\nexpectError(rejectsSyncResult.cause?.valueOf());\n\nconst noRejectsSyncResult = execaSync('unicorns', {reject: false});\nexpectAssignable<SyncResult>(noRejectsSyncResult);\nexpectType<string | undefined>(noRejectsSyncResult.stack);\nexpectType<string | undefined>(noRejectsSyncResult.message);\nexpectType<string | undefined>(noRejectsSyncResult.shortMessage);\nexpectType<string | undefined>(noRejectsSyncResult.originalMessage);\n"
  },
  {
    "path": "test-d/return/result-stdio.test-d.ts",
    "content": "import {Readable, Writable} from 'node:stream';\nimport {expectType} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype ExecaError,\n\ttype ExecaSyncError,\n} from '../../index.js';\n\nconst unicornsResult = await execa('unicorns', {all: true});\nexpectType<undefined>(unicornsResult.stdio[0]);\nexpectType<string>(unicornsResult.stdout);\nexpectType<string>(unicornsResult.stdio[1]);\nexpectType<string>(unicornsResult.stderr);\nexpectType<string>(unicornsResult.stdio[2]);\nexpectType<string>(unicornsResult.all);\nexpectType<string | undefined>(unicornsResult.stdio[3 as number]);\n\nconst bufferResult = await execa('unicorns', {encoding: 'buffer', all: true});\nexpectType<Uint8Array>(bufferResult.stdout);\nexpectType<Uint8Array>(bufferResult.stdio[1]);\nexpectType<Uint8Array>(bufferResult.stderr);\nexpectType<Uint8Array>(bufferResult.stdio[2]);\nexpectType<Uint8Array>(bufferResult.all);\n\nconst hexResult = await execa('unicorns', {encoding: 'hex', all: true});\nexpectType<string>(hexResult.stdout);\nexpectType<string>(hexResult.stdio[1]);\nexpectType<string>(hexResult.stderr);\nexpectType<string>(hexResult.stdio[2]);\nexpectType<string>(hexResult.all);\n\nconst unicornsResultSync = execaSync('unicorns', {all: true});\nexpectType<undefined>(unicornsResultSync.stdio[0]);\nexpectType<string>(unicornsResultSync.stdout);\nexpectType<string>(unicornsResultSync.stdio[1]);\nexpectType<string>(unicornsResultSync.stderr);\nexpectType<string>(unicornsResultSync.stdio[2]);\nexpectType<string>(unicornsResultSync.all);\n\nconst bufferResultSync = execaSync('unicorns', {encoding: 'buffer', all: true});\nexpectType<undefined>(bufferResultSync.stdio[0]);\nexpectType<Uint8Array>(bufferResultSync.stdout);\nexpectType<Uint8Array>(bufferResultSync.stdio[1]);\nexpectType<Uint8Array>(bufferResultSync.stderr);\nexpectType<Uint8Array>(bufferResultSync.stdio[2]);\nexpectType<Uint8Array>(bufferResultSync.all);\n\nconst execaStringError = new Error('.') as ExecaError<{all: true}>;\nexpectType<undefined>(execaStringError.stdio[0]);\nexpectType<string>(execaStringError.stdout);\nexpectType<string>(execaStringError.stdio[1]);\nexpectType<string>(execaStringError.stderr);\nexpectType<string>(execaStringError.stdio[2]);\nexpectType<string>(execaStringError.all);\n\nconst execaBufferError = new Error('.') as ExecaError<{encoding: 'buffer'; all: true}>;\nexpectType<undefined>(execaBufferError.stdio[0]);\nexpectType<Uint8Array>(execaBufferError.stdout);\nexpectType<Uint8Array>(execaBufferError.stdio[1]);\nexpectType<Uint8Array>(execaBufferError.stderr);\nexpectType<Uint8Array>(execaBufferError.stdio[2]);\nexpectType<Uint8Array>(execaBufferError.all);\n\nconst execaStringErrorSync = new Error('.') as ExecaSyncError<{all: true}>;\nexpectType<undefined>(execaStringErrorSync.stdio[0]);\nexpectType<string>(execaStringErrorSync.stdout);\nexpectType<string>(execaStringErrorSync.stdio[1]);\nexpectType<string>(execaStringErrorSync.stderr);\nexpectType<string>(execaStringErrorSync.stdio[2]);\nexpectType<string>(execaStringErrorSync.all);\n\nconst execaBufferErrorSync = new Error('.') as ExecaSyncError<{encoding: 'buffer'; all: true}>;\nexpectType<undefined>(execaBufferErrorSync.stdio[0]);\nexpectType<Uint8Array>(execaBufferErrorSync.stdout);\nexpectType<Uint8Array>(execaBufferErrorSync.stdio[1]);\nexpectType<Uint8Array>(execaBufferErrorSync.stderr);\nexpectType<Uint8Array>(execaBufferErrorSync.stdio[2]);\nexpectType<Uint8Array>(execaBufferErrorSync.all);\n\nconst multipleStdoutResult = await execa('unicorns', {stdout: ['inherit', 'pipe'] as ['inherit', 'pipe'], all: true});\nexpectType<string>(multipleStdoutResult.stdout);\nexpectType<string>(multipleStdoutResult.stdio[1]);\nexpectType<string>(multipleStdoutResult.stderr);\nexpectType<string>(multipleStdoutResult.stdio[2]);\nexpectType<string>(multipleStdoutResult.all);\n\nconst undefinedStdoutResult = await execa('unicorns', {stdout: undefined, all: true});\nexpectType<string>(undefinedStdoutResult.stdout);\nexpectType<string>(undefinedStdoutResult.stderr);\nexpectType<string>(undefinedStdoutResult.all);\n\nconst undefinedArrayStdoutResult = await execa('unicorns', {stdout: [undefined] as const, all: true});\nexpectType<string>(undefinedArrayStdoutResult.stdout);\nexpectType<string>(undefinedArrayStdoutResult.stderr);\nexpectType<string>(undefinedArrayStdoutResult.all);\n\nconst undefinedStderrResult = await execa('unicorns', {stderr: undefined, all: true});\nexpectType<string>(undefinedStderrResult.stdout);\nexpectType<string>(undefinedStderrResult.stderr);\nexpectType<string>(undefinedStderrResult.all);\n\nconst undefinedArrayStderrResult = await execa('unicorns', {stderr: [undefined] as const, all: true});\nexpectType<string>(undefinedArrayStderrResult.stdout);\nexpectType<string>(undefinedArrayStderrResult.stderr);\nexpectType<string>(undefinedArrayStderrResult.all);\n\nconst fd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe']});\nexpectType<string>(fd3Result.stdio[3]);\n\nconst inputFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['pipe', new Readable()]]});\nexpectType<undefined>(inputFd3Result.stdio[3]);\n\nconst outputFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['pipe', new Writable()]]});\nexpectType<string>(outputFd3Result.stdio[3]);\n\nconst bufferFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe'], encoding: 'buffer'});\nexpectType<Uint8Array>(bufferFd3Result.stdio[3]);\n\nconst undefinedFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', undefined]});\nexpectType<undefined>(undefinedFd3Result.stdio[3]);\n\nconst undefinedArrayFd3Result = await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [undefined] as const]});\nexpectType<undefined>(undefinedArrayFd3Result.stdio[3]);\n"
  },
  {
    "path": "test-d/stdio/array.test-d.ts",
    "content": "import {expectError} from 'tsd';\nimport {execa, execaSync} from '../../index.js';\n\nexpectError(await execa('unicorns', {stdio: []}));\nexpectError(execaSync('unicorns', {stdio: []}));\nexpectError(await execa('unicorns', {stdio: ['pipe']}));\nexpectError(execaSync('unicorns', {stdio: ['pipe']}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe']}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe']}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe']});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'pipe']});\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'unknown']}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe', 'unknown']}));\n"
  },
  {
    "path": "test-d/stdio/direction.test-d.ts",
    "content": "import {Readable, Writable} from 'node:stream';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../index.js';\n\nawait execa('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']});\nexecaSync('unicorns', {stdio: [new Readable(), 'pipe', 'pipe']});\nawait execa('unicorns', {stdio: [[new Readable()], ['pipe'], ['pipe']]});\nexpectError(execaSync('unicorns', {stdio: [[new Readable()], ['pipe'], ['pipe']]}));\nawait execa('unicorns', {stdio: ['pipe', new Writable(), 'pipe']});\nexecaSync('unicorns', {stdio: ['pipe', new Writable(), 'pipe']});\nawait execa('unicorns', {stdio: [['pipe'], [new Writable()], ['pipe']]});\nexpectError(execaSync('unicorns', {stdio: [['pipe'], [new Writable()], ['pipe']]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', new Writable()]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', new Writable()]});\nawait execa('unicorns', {stdio: [['pipe'], ['pipe'], [new Writable()]]});\nexpectError(execaSync('unicorns', {stdio: [['pipe'], ['pipe'], [new Writable()]]}));\n\nexpectError(await execa('unicorns', {stdio: [new Writable(), 'pipe', 'pipe']}));\nexpectError(execaSync('unicorns', {stdio: [new Writable(), 'pipe', 'pipe']}));\nexpectError(await execa('unicorns', {stdio: [[new Writable()], ['pipe'], ['pipe']]}));\nexpectError(execaSync('unicorns', {stdio: [[new Writable()], ['pipe'], ['pipe']]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', new Readable(), 'pipe']}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', new Readable(), 'pipe']}));\nexpectError(await execa('unicorns', {stdio: [['pipe'], [new Readable()], ['pipe']]}));\nexpectError(execaSync('unicorns', {stdio: [['pipe'], [new Readable()], ['pipe']]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', new Readable()]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', new Readable()]}));\nexpectError(await execa('unicorns', {stdio: [['pipe'], ['pipe'], [new Readable()]]}));\nexpectError(execaSync('unicorns', {stdio: [['pipe'], ['pipe'], [new Readable()]]}));\n\nexpectAssignable<StdinOption | StdoutStderrOption>([new Uint8Array(), new Uint8Array()]);\nexpectAssignable<StdinSyncOption | StdoutStderrSyncOption>([new Uint8Array(), new Uint8Array()]);\nexpectNotAssignable<StdinOption | StdoutStderrOption>([new Writable(), new Uint8Array()]);\nexpectNotAssignable<StdinSyncOption | StdoutStderrSyncOption>([new Writable(), new Uint8Array()]);\n"
  },
  {
    "path": "test-d/stdio/option/array-binary.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst binaryArray = [new Uint8Array(), new Uint8Array()] as const;\n\nawait execa('unicorns', {stdin: [binaryArray]});\nexecaSync('unicorns', {stdin: [binaryArray]});\n\nexpectError(await execa('unicorns', {stdout: [binaryArray]}));\nexpectError(execaSync('unicorns', {stdout: [binaryArray]}));\n\nexpectError(await execa('unicorns', {stderr: [binaryArray]}));\nexpectError(execaSync('unicorns', {stderr: [binaryArray]}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryArray]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryArray]]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[binaryArray]]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[binaryArray]]]}));\n\nexpectAssignable<StdinOption>([binaryArray]);\nexpectAssignable<StdinSyncOption>([binaryArray]);\n\nexpectNotAssignable<StdoutStderrOption>([binaryArray]);\nexpectNotAssignable<StdoutStderrSyncOption>([binaryArray]);\n"
  },
  {
    "path": "test-d/stdio/option/array-object.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst objectArray = [{}, {}] as const;\n\nawait execa('unicorns', {stdin: [objectArray]});\nexecaSync('unicorns', {stdin: [objectArray]});\n\nexpectError(await execa('unicorns', {stdout: [objectArray]}));\nexpectError(execaSync('unicorns', {stdout: [objectArray]}));\n\nexpectError(await execa('unicorns', {stderr: [objectArray]}));\nexpectError(execaSync('unicorns', {stderr: [objectArray]}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectArray]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectArray]]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[objectArray]]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[objectArray]]]}));\n\nexpectAssignable<StdinOption>([objectArray]);\nexpectAssignable<StdinSyncOption>([objectArray]);\n\nexpectNotAssignable<StdoutStderrOption>([objectArray]);\nexpectNotAssignable<StdoutStderrSyncOption>([objectArray]);\n"
  },
  {
    "path": "test-d/stdio/option/array-string.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst stringArray = ['foo', 'bar'] as const;\n\nawait execa('unicorns', {stdin: [stringArray]});\nexecaSync('unicorns', {stdin: [stringArray]});\n\nexpectError(await execa('unicorns', {stdout: [stringArray]}));\nexpectError(execaSync('unicorns', {stdout: [stringArray]}));\n\nexpectError(await execa('unicorns', {stderr: [stringArray]}));\nexpectError(execaSync('unicorns', {stderr: [stringArray]}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringArray]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringArray]]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[stringArray]]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [[stringArray]]]}));\n\nexpectAssignable<StdinOption>([stringArray]);\nexpectAssignable<StdinSyncOption>([stringArray]);\n\nexpectNotAssignable<StdoutStderrOption>([stringArray]);\nexpectNotAssignable<StdoutStderrSyncOption>([stringArray]);\n"
  },
  {
    "path": "test-d/stdio/option/duplex-invalid.test-d.ts",
    "content": "import {Duplex} from 'node:stream';\nimport {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst duplexWithInvalidObjectMode = {\n\ttransform: new Duplex(),\n\tobjectMode: 'true',\n} as const;\n\nexpectError(await execa('unicorns', {stdin: duplexWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdin: duplexWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stdin: [duplexWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdin: [duplexWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stdout: duplexWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdout: duplexWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stdout: [duplexWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdout: [duplexWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stderr: duplexWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stderr: duplexWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stderr: [duplexWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stderr: [duplexWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stdio: duplexWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdio: duplexWithInvalidObjectMode}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplexWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplexWithInvalidObjectMode]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplexWithInvalidObjectMode]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplexWithInvalidObjectMode]]}));\n\nexpectNotAssignable<StdinOption>(duplexWithInvalidObjectMode);\nexpectNotAssignable<StdinSyncOption>(duplexWithInvalidObjectMode);\nexpectNotAssignable<StdinOption>([duplexWithInvalidObjectMode]);\nexpectNotAssignable<StdinSyncOption>([duplexWithInvalidObjectMode]);\n\nexpectNotAssignable<StdoutStderrOption>(duplexWithInvalidObjectMode);\nexpectNotAssignable<StdoutStderrSyncOption>(duplexWithInvalidObjectMode);\nexpectNotAssignable<StdoutStderrOption>([duplexWithInvalidObjectMode]);\nexpectNotAssignable<StdoutStderrSyncOption>([duplexWithInvalidObjectMode]);\n"
  },
  {
    "path": "test-d/stdio/option/duplex-object.test-d.ts",
    "content": "import {Duplex} from 'node:stream';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst duplexObjectProperty = {\n\ttransform: new Duplex(),\n\tobjectMode: true as const,\n} as const;\n\nawait execa('unicorns', {stdin: duplexObjectProperty});\nexpectError(execaSync('unicorns', {stdin: duplexObjectProperty}));\nawait execa('unicorns', {stdin: [duplexObjectProperty]});\nexpectError(execaSync('unicorns', {stdin: [duplexObjectProperty]}));\n\nawait execa('unicorns', {stdout: duplexObjectProperty});\nexpectError(execaSync('unicorns', {stdout: duplexObjectProperty}));\nawait execa('unicorns', {stdout: [duplexObjectProperty]});\nexpectError(execaSync('unicorns', {stdout: [duplexObjectProperty]}));\n\nawait execa('unicorns', {stderr: duplexObjectProperty});\nexpectError(execaSync('unicorns', {stderr: duplexObjectProperty}));\nawait execa('unicorns', {stderr: [duplexObjectProperty]});\nexpectError(execaSync('unicorns', {stderr: [duplexObjectProperty]}));\n\nexpectError(await execa('unicorns', {stdio: duplexObjectProperty}));\nexpectError(execaSync('unicorns', {stdio: duplexObjectProperty}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplexObjectProperty]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplexObjectProperty]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplexObjectProperty]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplexObjectProperty]]}));\n\nexpectAssignable<StdinOption>(duplexObjectProperty);\nexpectNotAssignable<StdinSyncOption>(duplexObjectProperty);\nexpectAssignable<StdinOption>([duplexObjectProperty]);\nexpectNotAssignable<StdinSyncOption>([duplexObjectProperty]);\n\nexpectAssignable<StdoutStderrOption>(duplexObjectProperty);\nexpectNotAssignable<StdoutStderrSyncOption>(duplexObjectProperty);\nexpectAssignable<StdoutStderrOption>([duplexObjectProperty]);\nexpectNotAssignable<StdoutStderrSyncOption>([duplexObjectProperty]);\n"
  },
  {
    "path": "test-d/stdio/option/duplex-transform.test-d.ts",
    "content": "import {Transform} from 'node:stream';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst duplexTransform = {transform: new Transform()} as const;\n\nawait execa('unicorns', {stdin: duplexTransform});\nexpectError(execaSync('unicorns', {stdin: duplexTransform}));\nawait execa('unicorns', {stdin: [duplexTransform]});\nexpectError(execaSync('unicorns', {stdin: [duplexTransform]}));\n\nawait execa('unicorns', {stdout: duplexTransform});\nexpectError(execaSync('unicorns', {stdout: duplexTransform}));\nawait execa('unicorns', {stdout: [duplexTransform]});\nexpectError(execaSync('unicorns', {stdout: [duplexTransform]}));\n\nawait execa('unicorns', {stderr: duplexTransform});\nexpectError(execaSync('unicorns', {stderr: duplexTransform}));\nawait execa('unicorns', {stderr: [duplexTransform]});\nexpectError(execaSync('unicorns', {stderr: [duplexTransform]}));\n\nexpectError(await execa('unicorns', {stdio: duplexTransform}));\nexpectError(execaSync('unicorns', {stdio: duplexTransform}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplexTransform]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplexTransform]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplexTransform]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplexTransform]]}));\n\nexpectAssignable<StdinOption>(duplexTransform);\nexpectNotAssignable<StdinSyncOption>(duplexTransform);\nexpectAssignable<StdinOption>([duplexTransform]);\nexpectNotAssignable<StdinSyncOption>([duplexTransform]);\n\nexpectAssignable<StdoutStderrOption>(duplexTransform);\nexpectNotAssignable<StdoutStderrSyncOption>(duplexTransform);\nexpectAssignable<StdoutStderrOption>([duplexTransform]);\nexpectNotAssignable<StdoutStderrSyncOption>([duplexTransform]);\n"
  },
  {
    "path": "test-d/stdio/option/duplex.test-d.ts",
    "content": "import {Duplex} from 'node:stream';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst duplex = {transform: new Duplex()} as const;\n\nawait execa('unicorns', {stdin: duplex});\nexpectError(execaSync('unicorns', {stdin: duplex}));\nawait execa('unicorns', {stdin: [duplex]});\nexpectError(execaSync('unicorns', {stdin: [duplex]}));\n\nawait execa('unicorns', {stdout: duplex});\nexpectError(execaSync('unicorns', {stdout: duplex}));\nawait execa('unicorns', {stdout: [duplex]});\nexpectError(execaSync('unicorns', {stdout: [duplex]}));\n\nawait execa('unicorns', {stderr: duplex});\nexpectError(execaSync('unicorns', {stderr: duplex}));\nawait execa('unicorns', {stderr: [duplex]});\nexpectError(execaSync('unicorns', {stderr: [duplex]}));\n\nexpectError(await execa('unicorns', {stdio: duplex}));\nexpectError(execaSync('unicorns', {stdio: duplex}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplex]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', duplex]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplex]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [duplex]]}));\n\nexpectAssignable<StdinOption>(duplex);\nexpectNotAssignable<StdinSyncOption>(duplex);\nexpectAssignable<StdinOption>([duplex]);\nexpectNotAssignable<StdinSyncOption>([duplex]);\n\nexpectAssignable<StdoutStderrOption>(duplex);\nexpectNotAssignable<StdoutStderrSyncOption>(duplex);\nexpectAssignable<StdoutStderrOption>([duplex]);\nexpectNotAssignable<StdoutStderrSyncOption>([duplex]);\n"
  },
  {
    "path": "test-d/stdio/option/fd-integer-0.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 0});\nexecaSync('unicorns', {stdin: 0});\nawait execa('unicorns', {stdin: [0]});\nexecaSync('unicorns', {stdin: [0]});\n\nexpectError(await execa('unicorns', {stdout: 0}));\nexpectError(execaSync('unicorns', {stdout: 0}));\nexpectError(await execa('unicorns', {stdout: [0]}));\nexpectError(execaSync('unicorns', {stdout: [0]}));\n\nexpectError(await execa('unicorns', {stderr: 0}));\nexpectError(execaSync('unicorns', {stderr: 0}));\nexpectError(await execa('unicorns', {stderr: [0]}));\nexpectError(execaSync('unicorns', {stderr: [0]}));\n\nexpectError(await execa('unicorns', {stdio: 0}));\nexpectError(execaSync('unicorns', {stdio: 0}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 0]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 0]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [0]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [0]]});\n\nexpectAssignable<StdinOption>(0);\nexpectAssignable<StdinSyncOption>(0);\nexpectAssignable<StdinOption>([0]);\nexpectAssignable<StdinSyncOption>([0]);\n\nexpectNotAssignable<StdinOption>(0.5);\nexpectNotAssignable<StdinSyncOption>(-1);\nexpectNotAssignable<StdinOption>(Number.POSITIVE_INFINITY);\nexpectNotAssignable<StdinSyncOption>(Number.NaN);\n\nexpectNotAssignable<StdoutStderrOption>(0);\nexpectNotAssignable<StdoutStderrSyncOption>(0);\nexpectNotAssignable<StdoutStderrOption>([0]);\nexpectNotAssignable<StdoutStderrSyncOption>([0]);\n\nexpectNotAssignable<StdoutStderrOption>(0.5);\nexpectNotAssignable<StdoutStderrSyncOption>(-1);\nexpectNotAssignable<StdoutStderrOption>(Number.POSITIVE_INFINITY);\nexpectNotAssignable<StdoutStderrSyncOption>(Number.NaN);\n"
  },
  {
    "path": "test-d/stdio/option/fd-integer-1.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: 1}));\nexpectError(execaSync('unicorns', {stdin: 1}));\nexpectError(await execa('unicorns', {stdin: [1]}));\nexpectError(execaSync('unicorns', {stdin: [1]}));\n\nawait execa('unicorns', {stdout: 1});\nexecaSync('unicorns', {stdout: 1});\nawait execa('unicorns', {stdout: [1]});\nexecaSync('unicorns', {stdout: [1]});\n\nawait execa('unicorns', {stderr: 1});\nexecaSync('unicorns', {stderr: 1});\nawait execa('unicorns', {stderr: [1]});\nexecaSync('unicorns', {stderr: [1]});\n\nexpectError(await execa('unicorns', {stdio: 1}));\nexpectError(execaSync('unicorns', {stdio: 1}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 1]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 1]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [1]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [1]]});\n\nexpectNotAssignable<StdinOption>(1);\nexpectNotAssignable<StdinSyncOption>(1);\nexpectNotAssignable<StdinOption>([1]);\nexpectNotAssignable<StdinSyncOption>([1]);\n\nexpectAssignable<StdoutStderrOption>(1);\nexpectAssignable<StdoutStderrSyncOption>(1);\nexpectAssignable<StdoutStderrOption>([1]);\nexpectAssignable<StdoutStderrSyncOption>([1]);\n"
  },
  {
    "path": "test-d/stdio/option/fd-integer-2.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: 2}));\nexpectError(execaSync('unicorns', {stdin: 2}));\nexpectError(await execa('unicorns', {stdin: [2]}));\nexpectError(execaSync('unicorns', {stdin: [2]}));\n\nawait execa('unicorns', {stdout: 2});\nexecaSync('unicorns', {stdout: 2});\nawait execa('unicorns', {stdout: [2]});\nexecaSync('unicorns', {stdout: [2]});\n\nawait execa('unicorns', {stderr: 2});\nexecaSync('unicorns', {stderr: 2});\nawait execa('unicorns', {stderr: [2]});\nexecaSync('unicorns', {stderr: [2]});\n\nexpectError(await execa('unicorns', {stdio: 2}));\nexpectError(execaSync('unicorns', {stdio: 2}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 2]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 2]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [2]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [2]]});\n\nexpectNotAssignable<StdinOption>(2);\nexpectNotAssignable<StdinSyncOption>(2);\nexpectNotAssignable<StdinOption>([2]);\nexpectNotAssignable<StdinSyncOption>([2]);\n\nexpectAssignable<StdoutStderrOption>(2);\nexpectAssignable<StdoutStderrSyncOption>(2);\nexpectAssignable<StdoutStderrOption>([2]);\nexpectAssignable<StdoutStderrSyncOption>([2]);\n"
  },
  {
    "path": "test-d/stdio/option/fd-integer-3.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 3});\nexecaSync('unicorns', {stdin: 3});\nexpectError(await execa('unicorns', {stdin: [3]}));\nexecaSync('unicorns', {stdin: [3]});\n\nawait execa('unicorns', {stdout: 3});\nexecaSync('unicorns', {stdout: 3});\nexpectError(await execa('unicorns', {stdout: [3]}));\nexecaSync('unicorns', {stdout: [3]});\n\nawait execa('unicorns', {stderr: 3});\nexecaSync('unicorns', {stderr: 3});\nexpectError(await execa('unicorns', {stderr: [3]}));\nexecaSync('unicorns', {stderr: [3]});\n\nexpectError(await execa('unicorns', {stdio: 3}));\nexpectError(execaSync('unicorns', {stdio: 3}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 3]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 3]});\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [3]]}));\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [3]]});\n\nexpectAssignable<StdinOption>(3);\nexpectAssignable<StdinSyncOption>(3);\nexpectNotAssignable<StdinOption>([3]);\nexpectAssignable<StdinSyncOption>([3]);\n\nexpectAssignable<StdoutStderrOption>(3);\nexpectAssignable<StdoutStderrSyncOption>(3);\nexpectNotAssignable<StdoutStderrOption>([3]);\nexpectAssignable<StdoutStderrSyncOption>([3]);\n"
  },
  {
    "path": "test-d/stdio/option/file-append-invalid.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst invalidFileAppend = {file: './test', append: 'true'} as const;\n\nexpectError(await execa('unicorns', {stdin: invalidFileAppend}));\nexpectError(execaSync('unicorns', {stdin: invalidFileAppend}));\nexpectError(await execa('unicorns', {stdin: [invalidFileAppend]}));\nexpectError(execaSync('unicorns', {stdin: [invalidFileAppend]}));\n\nexpectError(await execa('unicorns', {stdout: invalidFileAppend}));\nexpectError(execaSync('unicorns', {stdout: invalidFileAppend}));\nexpectError(await execa('unicorns', {stdout: [invalidFileAppend]}));\nexpectError(execaSync('unicorns', {stdout: [invalidFileAppend]}));\n\nexpectError(await execa('unicorns', {stderr: invalidFileAppend}));\nexpectError(execaSync('unicorns', {stderr: invalidFileAppend}));\nexpectError(await execa('unicorns', {stderr: [invalidFileAppend]}));\nexpectError(execaSync('unicorns', {stderr: [invalidFileAppend]}));\n\nexpectError(await execa('unicorns', {stdio: invalidFileAppend}));\nexpectError(execaSync('unicorns', {stdio: invalidFileAppend}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidFileAppend]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidFileAppend]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidFileAppend]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidFileAppend]]}));\n\nexpectNotAssignable<StdinOption>(invalidFileAppend);\nexpectNotAssignable<StdinSyncOption>(invalidFileAppend);\nexpectNotAssignable<StdinOption>([invalidFileAppend]);\nexpectNotAssignable<StdinSyncOption>([invalidFileAppend]);\n\nexpectNotAssignable<StdoutStderrOption>(invalidFileAppend);\nexpectNotAssignable<StdoutStderrSyncOption>(invalidFileAppend);\nexpectNotAssignable<StdoutStderrOption>([invalidFileAppend]);\nexpectNotAssignable<StdoutStderrSyncOption>([invalidFileAppend]);\n"
  },
  {
    "path": "test-d/stdio/option/file-append.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst fileAppend = {file: './test', append: true} as const;\n\nawait execa('unicorns', {stdin: fileAppend});\nexecaSync('unicorns', {stdin: fileAppend});\nawait execa('unicorns', {stdin: [fileAppend]});\nexecaSync('unicorns', {stdin: [fileAppend]});\n\nawait execa('unicorns', {stdout: fileAppend});\nexecaSync('unicorns', {stdout: fileAppend});\nawait execa('unicorns', {stdout: [fileAppend]});\nexecaSync('unicorns', {stdout: [fileAppend]});\n\nawait execa('unicorns', {stderr: fileAppend});\nexecaSync('unicorns', {stderr: fileAppend});\nawait execa('unicorns', {stderr: [fileAppend]});\nexecaSync('unicorns', {stderr: [fileAppend]});\n\nexpectError(await execa('unicorns', {stdio: fileAppend}));\nexpectError(execaSync('unicorns', {stdio: fileAppend}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', fileAppend]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', fileAppend]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [fileAppend]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [fileAppend]]});\n\nexpectAssignable<StdinOption>(fileAppend);\nexpectAssignable<StdinSyncOption>(fileAppend);\nexpectAssignable<StdinOption>([fileAppend]);\nexpectAssignable<StdinSyncOption>([fileAppend]);\n\nexpectAssignable<StdoutStderrOption>(fileAppend);\nexpectAssignable<StdoutStderrSyncOption>(fileAppend);\nexpectAssignable<StdoutStderrOption>([fileAppend]);\nexpectAssignable<StdoutStderrSyncOption>([fileAppend]);\n"
  },
  {
    "path": "test-d/stdio/option/file-object-invalid.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst invalidFileObject = {file: new URL('file:///test')} as const;\n\nexpectError(await execa('unicorns', {stdin: invalidFileObject}));\nexpectError(execaSync('unicorns', {stdin: invalidFileObject}));\nexpectError(await execa('unicorns', {stdin: [invalidFileObject]}));\nexpectError(execaSync('unicorns', {stdin: [invalidFileObject]}));\n\nexpectError(await execa('unicorns', {stdout: invalidFileObject}));\nexpectError(execaSync('unicorns', {stdout: invalidFileObject}));\nexpectError(await execa('unicorns', {stdout: [invalidFileObject]}));\nexpectError(execaSync('unicorns', {stdout: [invalidFileObject]}));\n\nexpectError(await execa('unicorns', {stderr: invalidFileObject}));\nexpectError(execaSync('unicorns', {stderr: invalidFileObject}));\nexpectError(await execa('unicorns', {stderr: [invalidFileObject]}));\nexpectError(execaSync('unicorns', {stderr: [invalidFileObject]}));\n\nexpectError(await execa('unicorns', {stdio: invalidFileObject}));\nexpectError(execaSync('unicorns', {stdio: invalidFileObject}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidFileObject]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidFileObject]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidFileObject]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidFileObject]]}));\n\nexpectNotAssignable<StdinOption>(invalidFileObject);\nexpectNotAssignable<StdinSyncOption>(invalidFileObject);\nexpectNotAssignable<StdinOption>([invalidFileObject]);\nexpectNotAssignable<StdinSyncOption>([invalidFileObject]);\n\nexpectNotAssignable<StdoutStderrOption>(invalidFileObject);\nexpectNotAssignable<StdoutStderrSyncOption>(invalidFileObject);\nexpectNotAssignable<StdoutStderrOption>([invalidFileObject]);\nexpectNotAssignable<StdoutStderrSyncOption>([invalidFileObject]);\n"
  },
  {
    "path": "test-d/stdio/option/file-object.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst fileObject = {file: './test'} as const;\n\nawait execa('unicorns', {stdin: fileObject});\nexecaSync('unicorns', {stdin: fileObject});\nawait execa('unicorns', {stdin: [fileObject]});\nexecaSync('unicorns', {stdin: [fileObject]});\n\nawait execa('unicorns', {stdout: fileObject});\nexecaSync('unicorns', {stdout: fileObject});\nawait execa('unicorns', {stdout: [fileObject]});\nexecaSync('unicorns', {stdout: [fileObject]});\n\nawait execa('unicorns', {stderr: fileObject});\nexecaSync('unicorns', {stderr: fileObject});\nawait execa('unicorns', {stderr: [fileObject]});\nexecaSync('unicorns', {stderr: [fileObject]});\n\nexpectError(await execa('unicorns', {stdio: fileObject}));\nexpectError(execaSync('unicorns', {stdio: fileObject}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', fileObject]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', fileObject]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [fileObject]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [fileObject]]});\n\nexpectAssignable<StdinOption>(fileObject);\nexpectAssignable<StdinSyncOption>(fileObject);\nexpectAssignable<StdinOption>([fileObject]);\nexpectAssignable<StdinSyncOption>([fileObject]);\n\nexpectAssignable<StdoutStderrOption>(fileObject);\nexpectAssignable<StdoutStderrSyncOption>(fileObject);\nexpectAssignable<StdoutStderrOption>([fileObject]);\nexpectAssignable<StdoutStderrSyncOption>([fileObject]);\n"
  },
  {
    "path": "test-d/stdio/option/file-url.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst fileUrl = new URL('file:///test');\n\nawait execa('unicorns', {stdin: fileUrl});\nexecaSync('unicorns', {stdin: fileUrl});\nawait execa('unicorns', {stdin: [fileUrl]});\nexecaSync('unicorns', {stdin: [fileUrl]});\n\nawait execa('unicorns', {stdout: fileUrl});\nexecaSync('unicorns', {stdout: fileUrl});\nawait execa('unicorns', {stdout: [fileUrl]});\nexecaSync('unicorns', {stdout: [fileUrl]});\n\nawait execa('unicorns', {stderr: fileUrl});\nexecaSync('unicorns', {stderr: fileUrl});\nawait execa('unicorns', {stderr: [fileUrl]});\nexecaSync('unicorns', {stderr: [fileUrl]});\n\nexpectError(await execa('unicorns', {stdio: fileUrl}));\nexpectError(execaSync('unicorns', {stdio: fileUrl}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', fileUrl]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', fileUrl]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [fileUrl]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [fileUrl]]});\n\nexpectAssignable<StdinOption>(fileUrl);\nexpectAssignable<StdinSyncOption>(fileUrl);\nexpectAssignable<StdinOption>([fileUrl]);\nexpectAssignable<StdinSyncOption>([fileUrl]);\n\nexpectAssignable<StdoutStderrOption>(fileUrl);\nexpectAssignable<StdoutStderrSyncOption>(fileUrl);\nexpectAssignable<StdoutStderrOption>([fileUrl]);\nexpectAssignable<StdoutStderrSyncOption>([fileUrl]);\n"
  },
  {
    "path": "test-d/stdio/option/final-async-full.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst asyncFinalFull = {\n\tasync * transform(line: unknown) {\n\t\tyield '';\n\t},\n\tasync * final() {\n\t\tyield '';\n\t},\n} as const;\n\nawait execa('unicorns', {stdin: asyncFinalFull});\nexpectError(execaSync('unicorns', {stdin: asyncFinalFull}));\nawait execa('unicorns', {stdin: [asyncFinalFull]});\nexpectError(execaSync('unicorns', {stdin: [asyncFinalFull]}));\n\nawait execa('unicorns', {stdout: asyncFinalFull});\nexpectError(execaSync('unicorns', {stdout: asyncFinalFull}));\nawait execa('unicorns', {stdout: [asyncFinalFull]});\nexpectError(execaSync('unicorns', {stdout: [asyncFinalFull]}));\n\nawait execa('unicorns', {stderr: asyncFinalFull});\nexpectError(execaSync('unicorns', {stderr: asyncFinalFull}));\nawait execa('unicorns', {stderr: [asyncFinalFull]});\nexpectError(execaSync('unicorns', {stderr: [asyncFinalFull]}));\n\nexpectError(await execa('unicorns', {stdio: asyncFinalFull}));\nexpectError(execaSync('unicorns', {stdio: asyncFinalFull}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncFinalFull]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncFinalFull]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncFinalFull]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncFinalFull]]}));\n\nexpectAssignable<StdinOption>(asyncFinalFull);\nexpectNotAssignable<StdinSyncOption>(asyncFinalFull);\nexpectAssignable<StdinOption>([asyncFinalFull]);\nexpectNotAssignable<StdinSyncOption>([asyncFinalFull]);\n\nexpectAssignable<StdoutStderrOption>(asyncFinalFull);\nexpectNotAssignable<StdoutStderrSyncOption>(asyncFinalFull);\nexpectAssignable<StdoutStderrOption>([asyncFinalFull]);\nexpectNotAssignable<StdoutStderrSyncOption>([asyncFinalFull]);\n"
  },
  {
    "path": "test-d/stdio/option/final-invalid-full.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst invalidReturnFinalFull = {\n\t* transform(line: string) {\n\t\tyield line;\n\t},\n\t* final() {\n\t\tyield {} as unknown;\n\t\treturn false;\n\t},\n} as const;\n\nexpectError(await execa('unicorns', {stdin: invalidReturnFinalFull}));\nexpectError(execaSync('unicorns', {stdin: invalidReturnFinalFull}));\nexpectError(await execa('unicorns', {stdin: [invalidReturnFinalFull]}));\nexpectError(execaSync('unicorns', {stdin: [invalidReturnFinalFull]}));\n\nexpectError(await execa('unicorns', {stdout: invalidReturnFinalFull}));\nexpectError(execaSync('unicorns', {stdout: invalidReturnFinalFull}));\nexpectError(await execa('unicorns', {stdout: [invalidReturnFinalFull]}));\nexpectError(execaSync('unicorns', {stdout: [invalidReturnFinalFull]}));\n\nexpectError(await execa('unicorns', {stderr: invalidReturnFinalFull}));\nexpectError(execaSync('unicorns', {stderr: invalidReturnFinalFull}));\nexpectError(await execa('unicorns', {stderr: [invalidReturnFinalFull]}));\nexpectError(execaSync('unicorns', {stderr: [invalidReturnFinalFull]}));\n\nexpectError(await execa('unicorns', {stdio: invalidReturnFinalFull}));\nexpectError(execaSync('unicorns', {stdio: invalidReturnFinalFull}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidReturnFinalFull]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidReturnFinalFull]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidReturnFinalFull]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidReturnFinalFull]]}));\n\nexpectNotAssignable<StdinOption>(invalidReturnFinalFull);\nexpectNotAssignable<StdinSyncOption>(invalidReturnFinalFull);\nexpectNotAssignable<StdinOption>([invalidReturnFinalFull]);\nexpectNotAssignable<StdinSyncOption>([invalidReturnFinalFull]);\n\nexpectNotAssignable<StdoutStderrOption>(invalidReturnFinalFull);\nexpectNotAssignable<StdoutStderrSyncOption>(invalidReturnFinalFull);\nexpectNotAssignable<StdoutStderrOption>([invalidReturnFinalFull]);\nexpectNotAssignable<StdoutStderrSyncOption>([invalidReturnFinalFull]);\n"
  },
  {
    "path": "test-d/stdio/option/final-object-full.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst objectFinalFull = {\n\t* transform(line: unknown) {\n\t\tyield JSON.parse(line as string) as object;\n\t},\n\t* final() {\n\t\tyield {};\n\t},\n\tobjectMode: true,\n} as const;\n\nawait execa('unicorns', {stdin: objectFinalFull});\nexecaSync('unicorns', {stdin: objectFinalFull});\nawait execa('unicorns', {stdin: [objectFinalFull]});\nexecaSync('unicorns', {stdin: [objectFinalFull]});\n\nawait execa('unicorns', {stdout: objectFinalFull});\nexecaSync('unicorns', {stdout: objectFinalFull});\nawait execa('unicorns', {stdout: [objectFinalFull]});\nexecaSync('unicorns', {stdout: [objectFinalFull]});\n\nawait execa('unicorns', {stderr: objectFinalFull});\nexecaSync('unicorns', {stderr: objectFinalFull});\nawait execa('unicorns', {stderr: [objectFinalFull]});\nexecaSync('unicorns', {stderr: [objectFinalFull]});\n\nexpectError(await execa('unicorns', {stdio: objectFinalFull}));\nexpectError(execaSync('unicorns', {stdio: objectFinalFull}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectFinalFull]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectFinalFull]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectFinalFull]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectFinalFull]]});\n\nexpectAssignable<StdinOption>(objectFinalFull);\nexpectAssignable<StdinSyncOption>(objectFinalFull);\nexpectAssignable<StdinOption>([objectFinalFull]);\nexpectAssignable<StdinSyncOption>([objectFinalFull]);\n\nexpectAssignable<StdoutStderrOption>(objectFinalFull);\nexpectAssignable<StdoutStderrSyncOption>(objectFinalFull);\nexpectAssignable<StdoutStderrOption>([objectFinalFull]);\nexpectAssignable<StdoutStderrSyncOption>([objectFinalFull]);\n"
  },
  {
    "path": "test-d/stdio/option/final-unknown-full.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst unknownFinalFull = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\t* final() {\n\t\tyield {} as unknown;\n\t},\n\tobjectMode: true,\n} as const;\n\nawait execa('unicorns', {stdin: unknownFinalFull});\nexecaSync('unicorns', {stdin: unknownFinalFull});\nawait execa('unicorns', {stdin: [unknownFinalFull]});\nexecaSync('unicorns', {stdin: [unknownFinalFull]});\n\nawait execa('unicorns', {stdout: unknownFinalFull});\nexecaSync('unicorns', {stdout: unknownFinalFull});\nawait execa('unicorns', {stdout: [unknownFinalFull]});\nexecaSync('unicorns', {stdout: [unknownFinalFull]});\n\nawait execa('unicorns', {stderr: unknownFinalFull});\nexecaSync('unicorns', {stderr: unknownFinalFull});\nawait execa('unicorns', {stderr: [unknownFinalFull]});\nexecaSync('unicorns', {stderr: [unknownFinalFull]});\n\nexpectError(await execa('unicorns', {stdio: unknownFinalFull}));\nexpectError(execaSync('unicorns', {stdio: unknownFinalFull}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownFinalFull]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownFinalFull]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownFinalFull]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownFinalFull]]});\n\nexpectAssignable<StdinOption>(unknownFinalFull);\nexpectAssignable<StdinSyncOption>(unknownFinalFull);\nexpectAssignable<StdinOption>([unknownFinalFull]);\nexpectAssignable<StdinSyncOption>([unknownFinalFull]);\n\nexpectAssignable<StdoutStderrOption>(unknownFinalFull);\nexpectAssignable<StdoutStderrSyncOption>(unknownFinalFull);\nexpectAssignable<StdoutStderrOption>([unknownFinalFull]);\nexpectAssignable<StdoutStderrSyncOption>([unknownFinalFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-async-full.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst asyncGeneratorFull = {\n\tasync * transform(line: unknown) {\n\t\tyield '';\n\t},\n} as const;\n\nawait execa('unicorns', {stdin: asyncGeneratorFull});\nexpectError(execaSync('unicorns', {stdin: asyncGeneratorFull}));\nawait execa('unicorns', {stdin: [asyncGeneratorFull]});\nexpectError(execaSync('unicorns', {stdin: [asyncGeneratorFull]}));\n\nawait execa('unicorns', {stdout: asyncGeneratorFull});\nexpectError(execaSync('unicorns', {stdout: asyncGeneratorFull}));\nawait execa('unicorns', {stdout: [asyncGeneratorFull]});\nexpectError(execaSync('unicorns', {stdout: [asyncGeneratorFull]}));\n\nawait execa('unicorns', {stderr: asyncGeneratorFull});\nexpectError(execaSync('unicorns', {stderr: asyncGeneratorFull}));\nawait execa('unicorns', {stderr: [asyncGeneratorFull]});\nexpectError(execaSync('unicorns', {stderr: [asyncGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdio: asyncGeneratorFull}));\nexpectError(execaSync('unicorns', {stdio: asyncGeneratorFull}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncGeneratorFull]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncGeneratorFull]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncGeneratorFull]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncGeneratorFull]]}));\n\nexpectAssignable<StdinOption>(asyncGeneratorFull);\nexpectNotAssignable<StdinSyncOption>(asyncGeneratorFull);\nexpectAssignable<StdinOption>([asyncGeneratorFull]);\nexpectNotAssignable<StdinSyncOption>([asyncGeneratorFull]);\n\nexpectAssignable<StdoutStderrOption>(asyncGeneratorFull);\nexpectNotAssignable<StdoutStderrSyncOption>(asyncGeneratorFull);\nexpectAssignable<StdoutStderrOption>([asyncGeneratorFull]);\nexpectNotAssignable<StdoutStderrSyncOption>([asyncGeneratorFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-async.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst asyncGenerator = async function * (line: unknown) {\n\tyield '';\n};\n\nawait execa('unicorns', {stdin: asyncGenerator});\nexpectError(execaSync('unicorns', {stdin: asyncGenerator}));\nawait execa('unicorns', {stdin: [asyncGenerator]});\nexpectError(execaSync('unicorns', {stdin: [asyncGenerator]}));\n\nawait execa('unicorns', {stdout: asyncGenerator});\nexpectError(execaSync('unicorns', {stdout: asyncGenerator}));\nawait execa('unicorns', {stdout: [asyncGenerator]});\nexpectError(execaSync('unicorns', {stdout: [asyncGenerator]}));\n\nawait execa('unicorns', {stderr: asyncGenerator});\nexpectError(execaSync('unicorns', {stderr: asyncGenerator}));\nawait execa('unicorns', {stderr: [asyncGenerator]});\nexpectError(execaSync('unicorns', {stderr: [asyncGenerator]}));\n\nexpectError(await execa('unicorns', {stdio: asyncGenerator}));\nexpectError(execaSync('unicorns', {stdio: asyncGenerator}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncGenerator]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncGenerator]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncGenerator]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncGenerator]]}));\n\nexpectAssignable<StdinOption>(asyncGenerator);\nexpectNotAssignable<StdinSyncOption>(asyncGenerator);\nexpectAssignable<StdinOption>([asyncGenerator]);\nexpectNotAssignable<StdinSyncOption>([asyncGenerator]);\n\nexpectAssignable<StdoutStderrOption>(asyncGenerator);\nexpectNotAssignable<StdoutStderrSyncOption>(asyncGenerator);\nexpectAssignable<StdoutStderrOption>([asyncGenerator]);\nexpectNotAssignable<StdoutStderrSyncOption>([asyncGenerator]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-binary-invalid.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst transformWithInvalidBinary = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tbinary: 'true',\n} as const;\n\nexpectError(await execa('unicorns', {stdin: transformWithInvalidBinary}));\nexpectError(execaSync('unicorns', {stdin: transformWithInvalidBinary}));\nexpectError(await execa('unicorns', {stdin: [transformWithInvalidBinary]}));\nexpectError(execaSync('unicorns', {stdin: [transformWithInvalidBinary]}));\n\nexpectError(await execa('unicorns', {stdout: transformWithInvalidBinary}));\nexpectError(execaSync('unicorns', {stdout: transformWithInvalidBinary}));\nexpectError(await execa('unicorns', {stdout: [transformWithInvalidBinary]}));\nexpectError(execaSync('unicorns', {stdout: [transformWithInvalidBinary]}));\n\nexpectError(await execa('unicorns', {stderr: transformWithInvalidBinary}));\nexpectError(execaSync('unicorns', {stderr: transformWithInvalidBinary}));\nexpectError(await execa('unicorns', {stderr: [transformWithInvalidBinary]}));\nexpectError(execaSync('unicorns', {stderr: [transformWithInvalidBinary]}));\n\nexpectError(await execa('unicorns', {stdio: transformWithInvalidBinary}));\nexpectError(execaSync('unicorns', {stdio: transformWithInvalidBinary}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithInvalidBinary]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithInvalidBinary]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithInvalidBinary]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithInvalidBinary]]}));\n\nexpectNotAssignable<StdinOption>(transformWithInvalidBinary);\nexpectNotAssignable<StdinSyncOption>(transformWithInvalidBinary);\nexpectNotAssignable<StdinOption>([transformWithInvalidBinary]);\nexpectNotAssignable<StdinSyncOption>([transformWithInvalidBinary]);\n\nexpectNotAssignable<StdoutStderrOption>(transformWithInvalidBinary);\nexpectNotAssignable<StdoutStderrSyncOption>(transformWithInvalidBinary);\nexpectNotAssignable<StdoutStderrOption>([transformWithInvalidBinary]);\nexpectNotAssignable<StdoutStderrSyncOption>([transformWithInvalidBinary]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-binary.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst transformWithBinary = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tbinary: true,\n} as const;\n\nawait execa('unicorns', {stdin: transformWithBinary});\nexecaSync('unicorns', {stdin: transformWithBinary});\nawait execa('unicorns', {stdin: [transformWithBinary]});\nexecaSync('unicorns', {stdin: [transformWithBinary]});\n\nawait execa('unicorns', {stdout: transformWithBinary});\nexecaSync('unicorns', {stdout: transformWithBinary});\nawait execa('unicorns', {stdout: [transformWithBinary]});\nexecaSync('unicorns', {stdout: [transformWithBinary]});\n\nawait execa('unicorns', {stderr: transformWithBinary});\nexecaSync('unicorns', {stderr: transformWithBinary});\nawait execa('unicorns', {stderr: [transformWithBinary]});\nexecaSync('unicorns', {stderr: [transformWithBinary]});\n\nexpectError(await execa('unicorns', {stdio: transformWithBinary}));\nexpectError(execaSync('unicorns', {stdio: transformWithBinary}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithBinary]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithBinary]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithBinary]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithBinary]]});\n\nexpectAssignable<StdinOption>(transformWithBinary);\nexpectAssignable<StdinSyncOption>(transformWithBinary);\nexpectAssignable<StdinOption>([transformWithBinary]);\nexpectAssignable<StdinSyncOption>([transformWithBinary]);\n\nexpectAssignable<StdoutStderrOption>(transformWithBinary);\nexpectAssignable<StdoutStderrSyncOption>(transformWithBinary);\nexpectAssignable<StdoutStderrOption>([transformWithBinary]);\nexpectAssignable<StdoutStderrSyncOption>([transformWithBinary]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-boolean-full.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst booleanGeneratorFull = {\n\t* transform(line: boolean) {\n\t\tyield line;\n\t},\n} as const;\n\nexpectError(await execa('unicorns', {stdin: booleanGeneratorFull}));\nexpectError(execaSync('unicorns', {stdin: booleanGeneratorFull}));\nexpectError(await execa('unicorns', {stdin: [booleanGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdin: [booleanGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdout: booleanGeneratorFull}));\nexpectError(execaSync('unicorns', {stdout: booleanGeneratorFull}));\nexpectError(await execa('unicorns', {stdout: [booleanGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdout: [booleanGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stderr: booleanGeneratorFull}));\nexpectError(execaSync('unicorns', {stderr: booleanGeneratorFull}));\nexpectError(await execa('unicorns', {stderr: [booleanGeneratorFull]}));\nexpectError(execaSync('unicorns', {stderr: [booleanGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdio: booleanGeneratorFull}));\nexpectError(execaSync('unicorns', {stdio: booleanGeneratorFull}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', booleanGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', booleanGeneratorFull]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [booleanGeneratorFull]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [booleanGeneratorFull]]}));\n\nexpectNotAssignable<StdinOption>(booleanGeneratorFull);\nexpectNotAssignable<StdinSyncOption>(booleanGeneratorFull);\nexpectNotAssignable<StdinOption>([booleanGeneratorFull]);\nexpectNotAssignable<StdinSyncOption>([booleanGeneratorFull]);\n\nexpectNotAssignable<StdoutStderrOption>(booleanGeneratorFull);\nexpectNotAssignable<StdoutStderrSyncOption>(booleanGeneratorFull);\nexpectNotAssignable<StdoutStderrOption>([booleanGeneratorFull]);\nexpectNotAssignable<StdoutStderrSyncOption>([booleanGeneratorFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-boolean.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst booleanGenerator = function * (line: boolean) {\n\tyield line;\n};\n\nexpectError(await execa('unicorns', {stdin: booleanGenerator}));\nexpectError(execaSync('unicorns', {stdin: booleanGenerator}));\nexpectError(await execa('unicorns', {stdin: [booleanGenerator]}));\nexpectError(execaSync('unicorns', {stdin: [booleanGenerator]}));\n\nexpectError(await execa('unicorns', {stdout: booleanGenerator}));\nexpectError(execaSync('unicorns', {stdout: booleanGenerator}));\nexpectError(await execa('unicorns', {stdout: [booleanGenerator]}));\nexpectError(execaSync('unicorns', {stdout: [booleanGenerator]}));\n\nexpectError(await execa('unicorns', {stderr: booleanGenerator}));\nexpectError(execaSync('unicorns', {stderr: booleanGenerator}));\nexpectError(await execa('unicorns', {stderr: [booleanGenerator]}));\nexpectError(execaSync('unicorns', {stderr: [booleanGenerator]}));\n\nexpectError(await execa('unicorns', {stdio: booleanGenerator}));\nexpectError(execaSync('unicorns', {stdio: booleanGenerator}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', booleanGenerator]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', booleanGenerator]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [booleanGenerator]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [booleanGenerator]]}));\n\nexpectNotAssignable<StdinOption>(booleanGenerator);\nexpectNotAssignable<StdinSyncOption>(booleanGenerator);\nexpectNotAssignable<StdinOption>([booleanGenerator]);\nexpectNotAssignable<StdinSyncOption>([booleanGenerator]);\n\nexpectNotAssignable<StdoutStderrOption>(booleanGenerator);\nexpectNotAssignable<StdoutStderrSyncOption>(booleanGenerator);\nexpectNotAssignable<StdoutStderrOption>([booleanGenerator]);\nexpectNotAssignable<StdoutStderrSyncOption>([booleanGenerator]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-empty.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: {}}));\nexpectError(execaSync('unicorns', {stdin: {}}));\nexpectError(await execa('unicorns', {stdin: [{}]}));\nexpectError(execaSync('unicorns', {stdin: [{}]}));\n\nexpectError(await execa('unicorns', {stdout: {}}));\nexpectError(execaSync('unicorns', {stdout: {}}));\nexpectError(await execa('unicorns', {stdout: [{}]}));\nexpectError(execaSync('unicorns', {stdout: [{}]}));\n\nexpectError(await execa('unicorns', {stderr: {}}));\nexpectError(execaSync('unicorns', {stderr: {}}));\nexpectError(await execa('unicorns', {stderr: [{}]}));\nexpectError(execaSync('unicorns', {stderr: [{}]}));\n\nexpectError(await execa('unicorns', {stdio: {}}));\nexpectError(execaSync('unicorns', {stdio: {}}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {}]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', {}]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [{}]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [{}]]}));\n\nexpectNotAssignable<StdinOption>({});\nexpectNotAssignable<StdinSyncOption>({});\nexpectNotAssignable<StdinOption>([{}]);\nexpectNotAssignable<StdinSyncOption>([{}]);\n\nexpectNotAssignable<StdoutStderrOption>({});\nexpectNotAssignable<StdoutStderrSyncOption>({});\nexpectNotAssignable<StdoutStderrOption>([{}]);\nexpectNotAssignable<StdoutStderrSyncOption>([{}]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-invalid-full.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst invalidReturnGeneratorFull = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t\treturn false;\n\t},\n} as const;\n\nexpectError(await execa('unicorns', {stdin: invalidReturnGeneratorFull}));\nexpectError(execaSync('unicorns', {stdin: invalidReturnGeneratorFull}));\nexpectError(await execa('unicorns', {stdin: [invalidReturnGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdin: [invalidReturnGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdout: invalidReturnGeneratorFull}));\nexpectError(execaSync('unicorns', {stdout: invalidReturnGeneratorFull}));\nexpectError(await execa('unicorns', {stdout: [invalidReturnGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdout: [invalidReturnGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stderr: invalidReturnGeneratorFull}));\nexpectError(execaSync('unicorns', {stderr: invalidReturnGeneratorFull}));\nexpectError(await execa('unicorns', {stderr: [invalidReturnGeneratorFull]}));\nexpectError(execaSync('unicorns', {stderr: [invalidReturnGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdio: invalidReturnGeneratorFull}));\nexpectError(execaSync('unicorns', {stdio: invalidReturnGeneratorFull}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidReturnGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidReturnGeneratorFull]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidReturnGeneratorFull]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidReturnGeneratorFull]]}));\n\nexpectNotAssignable<StdinOption>(invalidReturnGeneratorFull);\nexpectNotAssignable<StdinSyncOption>(invalidReturnGeneratorFull);\nexpectNotAssignable<StdinOption>([invalidReturnGeneratorFull]);\nexpectNotAssignable<StdinSyncOption>([invalidReturnGeneratorFull]);\n\nexpectNotAssignable<StdoutStderrOption>(invalidReturnGeneratorFull);\nexpectNotAssignable<StdoutStderrSyncOption>(invalidReturnGeneratorFull);\nexpectNotAssignable<StdoutStderrOption>([invalidReturnGeneratorFull]);\nexpectNotAssignable<StdoutStderrSyncOption>([invalidReturnGeneratorFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-invalid.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst invalidReturnGenerator = function * (line: unknown) {\n\tyield line;\n\treturn false;\n};\n\nexpectError(await execa('unicorns', {stdin: invalidReturnGenerator}));\nexpectError(execaSync('unicorns', {stdin: invalidReturnGenerator}));\nexpectError(await execa('unicorns', {stdin: [invalidReturnGenerator]}));\nexpectError(execaSync('unicorns', {stdin: [invalidReturnGenerator]}));\n\nexpectError(await execa('unicorns', {stdout: invalidReturnGenerator}));\nexpectError(execaSync('unicorns', {stdout: invalidReturnGenerator}));\nexpectError(await execa('unicorns', {stdout: [invalidReturnGenerator]}));\nexpectError(execaSync('unicorns', {stdout: [invalidReturnGenerator]}));\n\nexpectError(await execa('unicorns', {stderr: invalidReturnGenerator}));\nexpectError(execaSync('unicorns', {stderr: invalidReturnGenerator}));\nexpectError(await execa('unicorns', {stderr: [invalidReturnGenerator]}));\nexpectError(execaSync('unicorns', {stderr: [invalidReturnGenerator]}));\n\nexpectError(await execa('unicorns', {stdio: invalidReturnGenerator}));\nexpectError(execaSync('unicorns', {stdio: invalidReturnGenerator}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidReturnGenerator]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', invalidReturnGenerator]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidReturnGenerator]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [invalidReturnGenerator]]}));\n\nexpectNotAssignable<StdinOption>(invalidReturnGenerator);\nexpectNotAssignable<StdinSyncOption>(invalidReturnGenerator);\nexpectNotAssignable<StdinOption>([invalidReturnGenerator]);\nexpectNotAssignable<StdinSyncOption>([invalidReturnGenerator]);\n\nexpectNotAssignable<StdoutStderrOption>(invalidReturnGenerator);\nexpectNotAssignable<StdoutStderrSyncOption>(invalidReturnGenerator);\nexpectNotAssignable<StdoutStderrOption>([invalidReturnGenerator]);\nexpectNotAssignable<StdoutStderrSyncOption>([invalidReturnGenerator]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-object-full.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst objectGeneratorFull = {\n\t* transform(line: unknown) {\n\t\tyield JSON.parse(line as string) as object;\n\t},\n\tobjectMode: true,\n} as const;\n\nawait execa('unicorns', {stdin: objectGeneratorFull});\nexecaSync('unicorns', {stdin: objectGeneratorFull});\nawait execa('unicorns', {stdin: [objectGeneratorFull]});\nexecaSync('unicorns', {stdin: [objectGeneratorFull]});\n\nawait execa('unicorns', {stdout: objectGeneratorFull});\nexecaSync('unicorns', {stdout: objectGeneratorFull});\nawait execa('unicorns', {stdout: [objectGeneratorFull]});\nexecaSync('unicorns', {stdout: [objectGeneratorFull]});\n\nawait execa('unicorns', {stderr: objectGeneratorFull});\nexecaSync('unicorns', {stderr: objectGeneratorFull});\nawait execa('unicorns', {stderr: [objectGeneratorFull]});\nexecaSync('unicorns', {stderr: [objectGeneratorFull]});\n\nexpectError(await execa('unicorns', {stdio: objectGeneratorFull}));\nexpectError(execaSync('unicorns', {stdio: objectGeneratorFull}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGeneratorFull]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGeneratorFull]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGeneratorFull]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGeneratorFull]]});\n\nexpectAssignable<StdinOption>(objectGeneratorFull);\nexpectAssignable<StdinSyncOption>(objectGeneratorFull);\nexpectAssignable<StdinOption>([objectGeneratorFull]);\nexpectAssignable<StdinSyncOption>([objectGeneratorFull]);\n\nexpectAssignable<StdoutStderrOption>(objectGeneratorFull);\nexpectAssignable<StdoutStderrSyncOption>(objectGeneratorFull);\nexpectAssignable<StdoutStderrOption>([objectGeneratorFull]);\nexpectAssignable<StdoutStderrSyncOption>([objectGeneratorFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-object-mode-invalid.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst transformWithInvalidObjectMode = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tobjectMode: 'true',\n} as const;\n\nexpectError(await execa('unicorns', {stdin: transformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdin: transformWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stdin: [transformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdin: [transformWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stdout: transformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdout: transformWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stdout: [transformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdout: [transformWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stderr: transformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stderr: transformWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stderr: [transformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stderr: [transformWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stdio: transformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdio: transformWithInvalidObjectMode}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithInvalidObjectMode]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithInvalidObjectMode]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithInvalidObjectMode]]}));\n\nexpectNotAssignable<StdinOption>(transformWithInvalidObjectMode);\nexpectNotAssignable<StdinSyncOption>(transformWithInvalidObjectMode);\nexpectNotAssignable<StdinOption>([transformWithInvalidObjectMode]);\nexpectNotAssignable<StdinSyncOption>([transformWithInvalidObjectMode]);\n\nexpectNotAssignable<StdoutStderrOption>(transformWithInvalidObjectMode);\nexpectNotAssignable<StdoutStderrSyncOption>(transformWithInvalidObjectMode);\nexpectNotAssignable<StdoutStderrOption>([transformWithInvalidObjectMode]);\nexpectNotAssignable<StdoutStderrSyncOption>([transformWithInvalidObjectMode]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-object-mode.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst transformWithObjectMode = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tobjectMode: true,\n} as const;\n\nawait execa('unicorns', {stdin: transformWithObjectMode});\nexecaSync('unicorns', {stdin: transformWithObjectMode});\nawait execa('unicorns', {stdin: [transformWithObjectMode]});\nexecaSync('unicorns', {stdin: [transformWithObjectMode]});\n\nawait execa('unicorns', {stdout: transformWithObjectMode});\nexecaSync('unicorns', {stdout: transformWithObjectMode});\nawait execa('unicorns', {stdout: [transformWithObjectMode]});\nexecaSync('unicorns', {stdout: [transformWithObjectMode]});\n\nawait execa('unicorns', {stderr: transformWithObjectMode});\nexecaSync('unicorns', {stderr: transformWithObjectMode});\nawait execa('unicorns', {stderr: [transformWithObjectMode]});\nexecaSync('unicorns', {stderr: [transformWithObjectMode]});\n\nexpectError(await execa('unicorns', {stdio: transformWithObjectMode}));\nexpectError(execaSync('unicorns', {stdio: transformWithObjectMode}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithObjectMode]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithObjectMode]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithObjectMode]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithObjectMode]]});\n\nexpectAssignable<StdinOption>(transformWithObjectMode);\nexpectAssignable<StdinSyncOption>(transformWithObjectMode);\nexpectAssignable<StdinOption>([transformWithObjectMode]);\nexpectAssignable<StdinSyncOption>([transformWithObjectMode]);\n\nexpectAssignable<StdoutStderrOption>(transformWithObjectMode);\nexpectAssignable<StdoutStderrSyncOption>(transformWithObjectMode);\nexpectAssignable<StdoutStderrOption>([transformWithObjectMode]);\nexpectAssignable<StdoutStderrSyncOption>([transformWithObjectMode]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-object.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst objectGenerator = function * (line: unknown) {\n\tyield JSON.parse(line as string) as object;\n};\n\nawait execa('unicorns', {stdin: objectGenerator});\nexecaSync('unicorns', {stdin: objectGenerator});\nawait execa('unicorns', {stdin: [objectGenerator]});\nexecaSync('unicorns', {stdin: [objectGenerator]});\n\nawait execa('unicorns', {stdout: objectGenerator});\nexecaSync('unicorns', {stdout: objectGenerator});\nawait execa('unicorns', {stdout: [objectGenerator]});\nexecaSync('unicorns', {stdout: [objectGenerator]});\n\nawait execa('unicorns', {stderr: objectGenerator});\nexecaSync('unicorns', {stderr: objectGenerator});\nawait execa('unicorns', {stderr: [objectGenerator]});\nexecaSync('unicorns', {stderr: [objectGenerator]});\n\nexpectError(await execa('unicorns', {stdio: objectGenerator}));\nexpectError(execaSync('unicorns', {stdio: objectGenerator}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectGenerator]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectGenerator]]});\n\nexpectAssignable<StdinOption>(objectGenerator);\nexpectAssignable<StdinSyncOption>(objectGenerator);\nexpectAssignable<StdinOption>([objectGenerator]);\nexpectAssignable<StdinSyncOption>([objectGenerator]);\n\nexpectAssignable<StdoutStderrOption>(objectGenerator);\nexpectAssignable<StdoutStderrSyncOption>(objectGenerator);\nexpectAssignable<StdoutStderrOption>([objectGenerator]);\nexpectAssignable<StdoutStderrSyncOption>([objectGenerator]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-only-binary.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst binaryOnly = {binary: true} as const;\n\nexpectError(await execa('unicorns', {stdin: binaryOnly}));\nexpectError(execaSync('unicorns', {stdin: binaryOnly}));\nexpectError(await execa('unicorns', {stdin: [binaryOnly]}));\nexpectError(execaSync('unicorns', {stdin: [binaryOnly]}));\n\nexpectError(await execa('unicorns', {stdout: binaryOnly}));\nexpectError(execaSync('unicorns', {stdout: binaryOnly}));\nexpectError(await execa('unicorns', {stdout: [binaryOnly]}));\nexpectError(execaSync('unicorns', {stdout: [binaryOnly]}));\n\nexpectError(await execa('unicorns', {stderr: binaryOnly}));\nexpectError(execaSync('unicorns', {stderr: binaryOnly}));\nexpectError(await execa('unicorns', {stderr: [binaryOnly]}));\nexpectError(execaSync('unicorns', {stderr: [binaryOnly]}));\n\nexpectError(await execa('unicorns', {stdio: binaryOnly}));\nexpectError(execaSync('unicorns', {stdio: binaryOnly}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', binaryOnly]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', binaryOnly]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryOnly]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryOnly]]}));\n\nexpectNotAssignable<StdinOption>(binaryOnly);\nexpectNotAssignable<StdinSyncOption>(binaryOnly);\nexpectNotAssignable<StdinOption>([binaryOnly]);\nexpectNotAssignable<StdinSyncOption>([binaryOnly]);\n\nexpectNotAssignable<StdoutStderrOption>(binaryOnly);\nexpectNotAssignable<StdoutStderrSyncOption>(binaryOnly);\nexpectNotAssignable<StdoutStderrOption>([binaryOnly]);\nexpectNotAssignable<StdoutStderrSyncOption>([binaryOnly]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-only-final.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst finalOnly = {\n\t* final() {\n\t\tyield {} as unknown;\n\t},\n} as const;\n\nexpectError(await execa('unicorns', {stdin: finalOnly}));\nexpectError(execaSync('unicorns', {stdin: finalOnly}));\nexpectError(await execa('unicorns', {stdin: [finalOnly]}));\nexpectError(execaSync('unicorns', {stdin: [finalOnly]}));\n\nexpectError(await execa('unicorns', {stdout: finalOnly}));\nexpectError(execaSync('unicorns', {stdout: finalOnly}));\nexpectError(await execa('unicorns', {stdout: [finalOnly]}));\nexpectError(execaSync('unicorns', {stdout: [finalOnly]}));\n\nexpectError(await execa('unicorns', {stderr: finalOnly}));\nexpectError(execaSync('unicorns', {stderr: finalOnly}));\nexpectError(await execa('unicorns', {stderr: [finalOnly]}));\nexpectError(execaSync('unicorns', {stderr: [finalOnly]}));\n\nexpectError(await execa('unicorns', {stdio: finalOnly}));\nexpectError(execaSync('unicorns', {stdio: finalOnly}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', finalOnly]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', finalOnly]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [finalOnly]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [finalOnly]]}));\n\nexpectNotAssignable<StdinOption>(finalOnly);\nexpectNotAssignable<StdinSyncOption>(finalOnly);\nexpectNotAssignable<StdinOption>([finalOnly]);\nexpectNotAssignable<StdinSyncOption>([finalOnly]);\n\nexpectNotAssignable<StdoutStderrOption>(finalOnly);\nexpectNotAssignable<StdoutStderrSyncOption>(finalOnly);\nexpectNotAssignable<StdoutStderrOption>([finalOnly]);\nexpectNotAssignable<StdoutStderrSyncOption>([finalOnly]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-only-object-mode.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst objectModeOnly = {objectMode: true} as const;\n\nexpectError(await execa('unicorns', {stdin: objectModeOnly}));\nexpectError(execaSync('unicorns', {stdin: objectModeOnly}));\nexpectError(await execa('unicorns', {stdin: [objectModeOnly]}));\nexpectError(execaSync('unicorns', {stdin: [objectModeOnly]}));\n\nexpectError(await execa('unicorns', {stdout: objectModeOnly}));\nexpectError(execaSync('unicorns', {stdout: objectModeOnly}));\nexpectError(await execa('unicorns', {stdout: [objectModeOnly]}));\nexpectError(execaSync('unicorns', {stdout: [objectModeOnly]}));\n\nexpectError(await execa('unicorns', {stderr: objectModeOnly}));\nexpectError(execaSync('unicorns', {stderr: objectModeOnly}));\nexpectError(await execa('unicorns', {stderr: [objectModeOnly]}));\nexpectError(execaSync('unicorns', {stderr: [objectModeOnly]}));\n\nexpectError(await execa('unicorns', {stdio: objectModeOnly}));\nexpectError(execaSync('unicorns', {stdio: objectModeOnly}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectModeOnly]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectModeOnly]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectModeOnly]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectModeOnly]]}));\n\nexpectNotAssignable<StdinOption>(objectModeOnly);\nexpectNotAssignable<StdinSyncOption>(objectModeOnly);\nexpectNotAssignable<StdinOption>([objectModeOnly]);\nexpectNotAssignable<StdinSyncOption>([objectModeOnly]);\n\nexpectNotAssignable<StdoutStderrOption>(objectModeOnly);\nexpectNotAssignable<StdoutStderrSyncOption>(objectModeOnly);\nexpectNotAssignable<StdoutStderrOption>([objectModeOnly]);\nexpectNotAssignable<StdoutStderrSyncOption>([objectModeOnly]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-only-preserve.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst preserveNewlinesOnly = {preserveNewlines: true} as const;\n\nexpectError(await execa('unicorns', {stdin: preserveNewlinesOnly}));\nexpectError(execaSync('unicorns', {stdin: preserveNewlinesOnly}));\nexpectError(await execa('unicorns', {stdin: [preserveNewlinesOnly]}));\nexpectError(execaSync('unicorns', {stdin: [preserveNewlinesOnly]}));\n\nexpectError(await execa('unicorns', {stdout: preserveNewlinesOnly}));\nexpectError(execaSync('unicorns', {stdout: preserveNewlinesOnly}));\nexpectError(await execa('unicorns', {stdout: [preserveNewlinesOnly]}));\nexpectError(execaSync('unicorns', {stdout: [preserveNewlinesOnly]}));\n\nexpectError(await execa('unicorns', {stderr: preserveNewlinesOnly}));\nexpectError(execaSync('unicorns', {stderr: preserveNewlinesOnly}));\nexpectError(await execa('unicorns', {stderr: [preserveNewlinesOnly]}));\nexpectError(execaSync('unicorns', {stderr: [preserveNewlinesOnly]}));\n\nexpectError(await execa('unicorns', {stdio: preserveNewlinesOnly}));\nexpectError(execaSync('unicorns', {stdio: preserveNewlinesOnly}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', preserveNewlinesOnly]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', preserveNewlinesOnly]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [preserveNewlinesOnly]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [preserveNewlinesOnly]]}));\n\nexpectNotAssignable<StdinOption>(preserveNewlinesOnly);\nexpectNotAssignable<StdinSyncOption>(preserveNewlinesOnly);\nexpectNotAssignable<StdinOption>([preserveNewlinesOnly]);\nexpectNotAssignable<StdinSyncOption>([preserveNewlinesOnly]);\n\nexpectNotAssignable<StdoutStderrOption>(preserveNewlinesOnly);\nexpectNotAssignable<StdoutStderrSyncOption>(preserveNewlinesOnly);\nexpectNotAssignable<StdoutStderrOption>([preserveNewlinesOnly]);\nexpectNotAssignable<StdoutStderrSyncOption>([preserveNewlinesOnly]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-preserve-invalid.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst transformWithInvalidPreserveNewlines = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tpreserveNewlines: 'true',\n} as const;\n\nexpectError(await execa('unicorns', {stdin: transformWithInvalidPreserveNewlines}));\nexpectError(execaSync('unicorns', {stdin: transformWithInvalidPreserveNewlines}));\nexpectError(await execa('unicorns', {stdin: [transformWithInvalidPreserveNewlines]}));\nexpectError(execaSync('unicorns', {stdin: [transformWithInvalidPreserveNewlines]}));\n\nexpectError(await execa('unicorns', {stdout: transformWithInvalidPreserveNewlines}));\nexpectError(execaSync('unicorns', {stdout: transformWithInvalidPreserveNewlines}));\nexpectError(await execa('unicorns', {stdout: [transformWithInvalidPreserveNewlines]}));\nexpectError(execaSync('unicorns', {stdout: [transformWithInvalidPreserveNewlines]}));\n\nexpectError(await execa('unicorns', {stderr: transformWithInvalidPreserveNewlines}));\nexpectError(execaSync('unicorns', {stderr: transformWithInvalidPreserveNewlines}));\nexpectError(await execa('unicorns', {stderr: [transformWithInvalidPreserveNewlines]}));\nexpectError(execaSync('unicorns', {stderr: [transformWithInvalidPreserveNewlines]}));\n\nexpectError(await execa('unicorns', {stdio: transformWithInvalidPreserveNewlines}));\nexpectError(execaSync('unicorns', {stdio: transformWithInvalidPreserveNewlines}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithInvalidPreserveNewlines]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithInvalidPreserveNewlines]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithInvalidPreserveNewlines]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithInvalidPreserveNewlines]]}));\n\nexpectNotAssignable<StdinOption>(transformWithInvalidPreserveNewlines);\nexpectNotAssignable<StdinSyncOption>(transformWithInvalidPreserveNewlines);\nexpectNotAssignable<StdinOption>([transformWithInvalidPreserveNewlines]);\nexpectNotAssignable<StdinSyncOption>([transformWithInvalidPreserveNewlines]);\n\nexpectNotAssignable<StdoutStderrOption>(transformWithInvalidPreserveNewlines);\nexpectNotAssignable<StdoutStderrSyncOption>(transformWithInvalidPreserveNewlines);\nexpectNotAssignable<StdoutStderrOption>([transformWithInvalidPreserveNewlines]);\nexpectNotAssignable<StdoutStderrSyncOption>([transformWithInvalidPreserveNewlines]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-preserve.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst transformWithPreserveNewlines = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tpreserveNewlines: true,\n} as const;\n\nawait execa('unicorns', {stdin: transformWithPreserveNewlines});\nexecaSync('unicorns', {stdin: transformWithPreserveNewlines});\nawait execa('unicorns', {stdin: [transformWithPreserveNewlines]});\nexecaSync('unicorns', {stdin: [transformWithPreserveNewlines]});\n\nawait execa('unicorns', {stdout: transformWithPreserveNewlines});\nexecaSync('unicorns', {stdout: transformWithPreserveNewlines});\nawait execa('unicorns', {stdout: [transformWithPreserveNewlines]});\nexecaSync('unicorns', {stdout: [transformWithPreserveNewlines]});\n\nawait execa('unicorns', {stderr: transformWithPreserveNewlines});\nexecaSync('unicorns', {stderr: transformWithPreserveNewlines});\nawait execa('unicorns', {stderr: [transformWithPreserveNewlines]});\nexecaSync('unicorns', {stderr: [transformWithPreserveNewlines]});\n\nexpectError(await execa('unicorns', {stdio: transformWithPreserveNewlines}));\nexpectError(execaSync('unicorns', {stdio: transformWithPreserveNewlines}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', transformWithPreserveNewlines]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [transformWithPreserveNewlines]]});\n\nexpectAssignable<StdinOption>(transformWithPreserveNewlines);\nexpectAssignable<StdinSyncOption>(transformWithPreserveNewlines);\nexpectAssignable<StdinOption>([transformWithPreserveNewlines]);\nexpectAssignable<StdinSyncOption>([transformWithPreserveNewlines]);\n\nexpectAssignable<StdoutStderrOption>(transformWithPreserveNewlines);\nexpectAssignable<StdoutStderrSyncOption>(transformWithPreserveNewlines);\nexpectAssignable<StdoutStderrOption>([transformWithPreserveNewlines]);\nexpectAssignable<StdoutStderrSyncOption>([transformWithPreserveNewlines]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-string-full.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst stringGeneratorFull = {\n\t* transform(line: string) {\n\t\tyield line;\n\t},\n} as const;\n\nexpectError(await execa('unicorns', {stdin: stringGeneratorFull}));\nexpectError(execaSync('unicorns', {stdin: stringGeneratorFull}));\nexpectError(await execa('unicorns', {stdin: [stringGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdin: [stringGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdout: stringGeneratorFull}));\nexpectError(execaSync('unicorns', {stdout: stringGeneratorFull}));\nexpectError(await execa('unicorns', {stdout: [stringGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdout: [stringGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stderr: stringGeneratorFull}));\nexpectError(execaSync('unicorns', {stderr: stringGeneratorFull}));\nexpectError(await execa('unicorns', {stderr: [stringGeneratorFull]}));\nexpectError(execaSync('unicorns', {stderr: [stringGeneratorFull]}));\n\nexpectError(await execa('unicorns', {stdio: stringGeneratorFull}));\nexpectError(execaSync('unicorns', {stdio: stringGeneratorFull}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringGeneratorFull]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringGeneratorFull]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringGeneratorFull]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringGeneratorFull]]}));\n\nexpectNotAssignable<StdinOption>(stringGeneratorFull);\nexpectNotAssignable<StdinSyncOption>(stringGeneratorFull);\nexpectNotAssignable<StdinOption>([stringGeneratorFull]);\nexpectNotAssignable<StdinSyncOption>([stringGeneratorFull]);\n\nexpectNotAssignable<StdoutStderrOption>(stringGeneratorFull);\nexpectNotAssignable<StdoutStderrSyncOption>(stringGeneratorFull);\nexpectNotAssignable<StdoutStderrOption>([stringGeneratorFull]);\nexpectNotAssignable<StdoutStderrSyncOption>([stringGeneratorFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-string.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst stringGenerator = function * (line: string) {\n\tyield line;\n};\n\nexpectError(await execa('unicorns', {stdin: stringGenerator}));\nexpectError(execaSync('unicorns', {stdin: stringGenerator}));\nexpectError(await execa('unicorns', {stdin: [stringGenerator]}));\nexpectError(execaSync('unicorns', {stdin: [stringGenerator]}));\n\nexpectError(await execa('unicorns', {stdout: stringGenerator}));\nexpectError(execaSync('unicorns', {stdout: stringGenerator}));\nexpectError(await execa('unicorns', {stdout: [stringGenerator]}));\nexpectError(execaSync('unicorns', {stdout: [stringGenerator]}));\n\nexpectError(await execa('unicorns', {stderr: stringGenerator}));\nexpectError(execaSync('unicorns', {stderr: stringGenerator}));\nexpectError(await execa('unicorns', {stderr: [stringGenerator]}));\nexpectError(execaSync('unicorns', {stderr: [stringGenerator]}));\n\nexpectError(await execa('unicorns', {stdio: stringGenerator}));\nexpectError(execaSync('unicorns', {stdio: stringGenerator}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringGenerator]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringGenerator]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringGenerator]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringGenerator]]}));\n\nexpectNotAssignable<StdinOption>(stringGenerator);\nexpectNotAssignable<StdinSyncOption>(stringGenerator);\nexpectNotAssignable<StdinOption>([stringGenerator]);\nexpectNotAssignable<StdinSyncOption>([stringGenerator]);\n\nexpectNotAssignable<StdoutStderrOption>(stringGenerator);\nexpectNotAssignable<StdoutStderrSyncOption>(stringGenerator);\nexpectNotAssignable<StdoutStderrOption>([stringGenerator]);\nexpectNotAssignable<StdoutStderrSyncOption>([stringGenerator]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-unknown-full.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst unknownGeneratorFull = {\n\t* transform(line: unknown) {\n\t\tyield line;\n\t},\n\tobjectMode: true,\n} as const;\n\nawait execa('unicorns', {stdin: unknownGeneratorFull});\nexecaSync('unicorns', {stdin: unknownGeneratorFull});\nawait execa('unicorns', {stdin: [unknownGeneratorFull]});\nexecaSync('unicorns', {stdin: [unknownGeneratorFull]});\n\nawait execa('unicorns', {stdout: unknownGeneratorFull});\nexecaSync('unicorns', {stdout: unknownGeneratorFull});\nawait execa('unicorns', {stdout: [unknownGeneratorFull]});\nexecaSync('unicorns', {stdout: [unknownGeneratorFull]});\n\nawait execa('unicorns', {stderr: unknownGeneratorFull});\nexecaSync('unicorns', {stderr: unknownGeneratorFull});\nawait execa('unicorns', {stderr: [unknownGeneratorFull]});\nexecaSync('unicorns', {stderr: [unknownGeneratorFull]});\n\nexpectError(await execa('unicorns', {stdio: unknownGeneratorFull}));\nexpectError(execaSync('unicorns', {stdio: unknownGeneratorFull}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGeneratorFull]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGeneratorFull]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGeneratorFull]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGeneratorFull]]});\n\nexpectAssignable<StdinOption>(unknownGeneratorFull);\nexpectAssignable<StdinSyncOption>(unknownGeneratorFull);\nexpectAssignable<StdinOption>([unknownGeneratorFull]);\nexpectAssignable<StdinSyncOption>([unknownGeneratorFull]);\n\nexpectAssignable<StdoutStderrOption>(unknownGeneratorFull);\nexpectAssignable<StdoutStderrSyncOption>(unknownGeneratorFull);\nexpectAssignable<StdoutStderrOption>([unknownGeneratorFull]);\nexpectAssignable<StdoutStderrSyncOption>([unknownGeneratorFull]);\n"
  },
  {
    "path": "test-d/stdio/option/generator-unknown.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst unknownGenerator = function * (line: unknown) {\n\tyield line;\n};\n\nawait execa('unicorns', {stdin: unknownGenerator});\nexecaSync('unicorns', {stdin: unknownGenerator});\nawait execa('unicorns', {stdin: [unknownGenerator]});\nexecaSync('unicorns', {stdin: [unknownGenerator]});\n\nawait execa('unicorns', {stdout: unknownGenerator});\nexecaSync('unicorns', {stdout: unknownGenerator});\nawait execa('unicorns', {stdout: [unknownGenerator]});\nexecaSync('unicorns', {stdout: [unknownGenerator]});\n\nawait execa('unicorns', {stderr: unknownGenerator});\nexecaSync('unicorns', {stderr: unknownGenerator});\nawait execa('unicorns', {stderr: [unknownGenerator]});\nexecaSync('unicorns', {stderr: [unknownGenerator]});\n\nexpectError(await execa('unicorns', {stdio: unknownGenerator}));\nexpectError(execaSync('unicorns', {stdio: unknownGenerator}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGenerator]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', unknownGenerator]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGenerator]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [unknownGenerator]]});\n\nexpectAssignable<StdinOption>(unknownGenerator);\nexpectAssignable<StdinSyncOption>(unknownGenerator);\nexpectAssignable<StdinOption>([unknownGenerator]);\nexpectAssignable<StdinSyncOption>([unknownGenerator]);\n\nexpectAssignable<StdoutStderrOption>(unknownGenerator);\nexpectAssignable<StdoutStderrSyncOption>(unknownGenerator);\nexpectAssignable<StdoutStderrOption>([unknownGenerator]);\nexpectAssignable<StdoutStderrSyncOption>([unknownGenerator]);\n"
  },
  {
    "path": "test-d/stdio/option/ignore.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 'ignore'});\nexecaSync('unicorns', {stdin: 'ignore'});\nexpectError(await execa('unicorns', {stdin: ['ignore']}));\nexpectError(execaSync('unicorns', {stdin: ['ignore']}));\n\nawait execa('unicorns', {stdout: 'ignore'});\nexecaSync('unicorns', {stdout: 'ignore'});\nexpectError(await execa('unicorns', {stdout: ['ignore']}));\nexpectError(execaSync('unicorns', {stdout: ['ignore']}));\n\nawait execa('unicorns', {stderr: 'ignore'});\nexecaSync('unicorns', {stderr: 'ignore'});\nexpectError(await execa('unicorns', {stderr: ['ignore']}));\nexpectError(execaSync('unicorns', {stderr: ['ignore']}));\n\nawait execa('unicorns', {stdio: 'ignore'});\nexecaSync('unicorns', {stdio: 'ignore'});\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ignore']});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ignore']});\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['ignore']]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['ignore']]}));\n\nexpectAssignable<StdinOption>('ignore');\nexpectAssignable<StdinSyncOption>('ignore');\nexpectNotAssignable<StdinOption>(['ignore']);\nexpectNotAssignable<StdinSyncOption>(['ignore']);\n\nexpectAssignable<StdoutStderrOption>('ignore');\nexpectAssignable<StdoutStderrSyncOption>('ignore');\nexpectNotAssignable<StdoutStderrOption>(['ignore']);\nexpectNotAssignable<StdoutStderrSyncOption>(['ignore']);\n"
  },
  {
    "path": "test-d/stdio/option/inherit.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 'inherit'});\nexecaSync('unicorns', {stdin: 'inherit'});\nawait execa('unicorns', {stdin: ['inherit']});\nexecaSync('unicorns', {stdin: ['inherit']});\n\nawait execa('unicorns', {stdout: 'inherit'});\nexecaSync('unicorns', {stdout: 'inherit'});\nawait execa('unicorns', {stdout: ['inherit']});\nexecaSync('unicorns', {stdout: ['inherit']});\n\nawait execa('unicorns', {stderr: 'inherit'});\nexecaSync('unicorns', {stderr: 'inherit'});\nawait execa('unicorns', {stderr: ['inherit']});\nexecaSync('unicorns', {stderr: ['inherit']});\n\nawait execa('unicorns', {stdio: 'inherit'});\nexecaSync('unicorns', {stdio: 'inherit'});\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'inherit']});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'inherit']});\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['inherit']]}));\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['inherit']]});\n\nexpectAssignable<StdinOption>('inherit');\nexpectAssignable<StdinSyncOption>('inherit');\nexpectAssignable<StdinOption>(['inherit']);\nexpectAssignable<StdinSyncOption>(['inherit']);\n\nexpectAssignable<StdoutStderrOption>('inherit');\nexpectAssignable<StdoutStderrSyncOption>('inherit');\nexpectAssignable<StdoutStderrOption>(['inherit']);\nexpectAssignable<StdoutStderrSyncOption>(['inherit']);\n"
  },
  {
    "path": "test-d/stdio/option/ipc.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 'ipc'});\nexpectError(execaSync('unicorns', {stdin: 'ipc'}));\nexpectError(await execa('unicorns', {stdin: ['ipc']}));\nexpectError(execaSync('unicorns', {stdin: ['ipc']}));\n\nawait execa('unicorns', {stdout: 'ipc'});\nexpectError(execaSync('unicorns', {stdout: 'ipc'}));\nexpectError(await execa('unicorns', {stdout: ['ipc']}));\nexpectError(execaSync('unicorns', {stdout: ['ipc']}));\n\nawait execa('unicorns', {stderr: 'ipc'});\nexpectError(execaSync('unicorns', {stderr: 'ipc'}));\nexpectError(await execa('unicorns', {stderr: ['ipc']}));\nexpectError(execaSync('unicorns', {stderr: ['ipc']}));\n\nexpectError(await execa('unicorns', {stdio: 'ipc'}));\nexpectError(execaSync('unicorns', {stdio: 'ipc'}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ipc']});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'ipc']}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['ipc']]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['ipc']]}));\n\nexpectAssignable<StdinOption>('ipc');\nexpectNotAssignable<StdinSyncOption>('ipc');\nexpectNotAssignable<StdinOption>(['ipc']);\nexpectNotAssignable<StdinSyncOption>(['ipc']);\n\nexpectAssignable<StdoutStderrOption>('ipc');\nexpectNotAssignable<StdoutStderrSyncOption>('ipc');\nexpectNotAssignable<StdoutStderrOption>(['ipc']);\nexpectNotAssignable<StdoutStderrSyncOption>(['ipc']);\n"
  },
  {
    "path": "test-d/stdio/option/iterable-async-binary.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst asyncBinaryIterableFunction = async function * () {\n\tyield new Uint8Array(0);\n};\n\nconst asyncBinaryIterable = asyncBinaryIterableFunction();\n\nawait execa('unicorns', {stdin: asyncBinaryIterable});\nexpectError(execaSync('unicorns', {stdin: asyncBinaryIterable}));\nawait execa('unicorns', {stdin: [asyncBinaryIterable]});\nexpectError(execaSync('unicorns', {stdin: [asyncBinaryIterable]}));\n\nexpectError(await execa('unicorns', {stdout: asyncBinaryIterable}));\nexpectError(execaSync('unicorns', {stdout: asyncBinaryIterable}));\nexpectError(await execa('unicorns', {stdout: [asyncBinaryIterable]}));\nexpectError(execaSync('unicorns', {stdout: [asyncBinaryIterable]}));\n\nexpectError(await execa('unicorns', {stderr: asyncBinaryIterable}));\nexpectError(execaSync('unicorns', {stderr: asyncBinaryIterable}));\nexpectError(await execa('unicorns', {stderr: [asyncBinaryIterable]}));\nexpectError(execaSync('unicorns', {stderr: [asyncBinaryIterable]}));\n\nexpectError(await execa('unicorns', {stdio: asyncBinaryIterable}));\nexpectError(execaSync('unicorns', {stdio: asyncBinaryIterable}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncBinaryIterable]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncBinaryIterable]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncBinaryIterable]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncBinaryIterable]]}));\n\nexpectAssignable<StdinOption>(asyncBinaryIterable);\nexpectNotAssignable<StdinSyncOption>(asyncBinaryIterable);\nexpectAssignable<StdinOption>([asyncBinaryIterable]);\nexpectNotAssignable<StdinSyncOption>([asyncBinaryIterable]);\n\nexpectNotAssignable<StdoutStderrOption>(asyncBinaryIterable);\nexpectNotAssignable<StdoutStderrSyncOption>(asyncBinaryIterable);\nexpectNotAssignable<StdoutStderrOption>([asyncBinaryIterable]);\nexpectNotAssignable<StdoutStderrSyncOption>([asyncBinaryIterable]);\n"
  },
  {
    "path": "test-d/stdio/option/iterable-async-object.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst asyncObjectIterableFunction = async function * () {\n\tyield {};\n};\n\nconst asyncObjectIterable = asyncObjectIterableFunction();\n\nawait execa('unicorns', {stdin: asyncObjectIterable});\nexpectError(execaSync('unicorns', {stdin: asyncObjectIterable}));\nawait execa('unicorns', {stdin: [asyncObjectIterable]});\nexpectError(execaSync('unicorns', {stdin: [asyncObjectIterable]}));\n\nexpectError(await execa('unicorns', {stdout: asyncObjectIterable}));\nexpectError(execaSync('unicorns', {stdout: asyncObjectIterable}));\nexpectError(await execa('unicorns', {stdout: [asyncObjectIterable]}));\nexpectError(execaSync('unicorns', {stdout: [asyncObjectIterable]}));\n\nexpectError(await execa('unicorns', {stderr: asyncObjectIterable}));\nexpectError(execaSync('unicorns', {stderr: asyncObjectIterable}));\nexpectError(await execa('unicorns', {stderr: [asyncObjectIterable]}));\nexpectError(execaSync('unicorns', {stderr: [asyncObjectIterable]}));\n\nexpectError(await execa('unicorns', {stdio: asyncObjectIterable}));\nexpectError(execaSync('unicorns', {stdio: asyncObjectIterable}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncObjectIterable]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncObjectIterable]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncObjectIterable]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncObjectIterable]]}));\n\nexpectAssignable<StdinOption>(asyncObjectIterable);\nexpectNotAssignable<StdinSyncOption>(asyncObjectIterable);\nexpectAssignable<StdinOption>([asyncObjectIterable]);\nexpectNotAssignable<StdinSyncOption>([asyncObjectIterable]);\n\nexpectNotAssignable<StdoutStderrOption>(asyncObjectIterable);\nexpectNotAssignable<StdoutStderrSyncOption>(asyncObjectIterable);\nexpectNotAssignable<StdoutStderrOption>([asyncObjectIterable]);\nexpectNotAssignable<StdoutStderrSyncOption>([asyncObjectIterable]);\n"
  },
  {
    "path": "test-d/stdio/option/iterable-async-string.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst asyncStringIterableFunction = async function * () {\n\tyield '';\n};\n\nconst asyncStringIterable = asyncStringIterableFunction();\n\nawait execa('unicorns', {stdin: asyncStringIterable});\nexpectError(execaSync('unicorns', {stdin: asyncStringIterable}));\nawait execa('unicorns', {stdin: [asyncStringIterable]});\nexpectError(execaSync('unicorns', {stdin: [asyncStringIterable]}));\n\nexpectError(await execa('unicorns', {stdout: asyncStringIterable}));\nexpectError(execaSync('unicorns', {stdout: asyncStringIterable}));\nexpectError(await execa('unicorns', {stdout: [asyncStringIterable]}));\nexpectError(execaSync('unicorns', {stdout: [asyncStringIterable]}));\n\nexpectError(await execa('unicorns', {stderr: asyncStringIterable}));\nexpectError(execaSync('unicorns', {stderr: asyncStringIterable}));\nexpectError(await execa('unicorns', {stderr: [asyncStringIterable]}));\nexpectError(execaSync('unicorns', {stderr: [asyncStringIterable]}));\n\nexpectError(await execa('unicorns', {stdio: asyncStringIterable}));\nexpectError(execaSync('unicorns', {stdio: asyncStringIterable}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncStringIterable]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', asyncStringIterable]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncStringIterable]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [asyncStringIterable]]}));\n\nexpectAssignable<StdinOption>(asyncStringIterable);\nexpectNotAssignable<StdinSyncOption>(asyncStringIterable);\nexpectAssignable<StdinOption>([asyncStringIterable]);\nexpectNotAssignable<StdinSyncOption>([asyncStringIterable]);\n\nexpectNotAssignable<StdoutStderrOption>(asyncStringIterable);\nexpectNotAssignable<StdoutStderrSyncOption>(asyncStringIterable);\nexpectNotAssignable<StdoutStderrOption>([asyncStringIterable]);\nexpectNotAssignable<StdoutStderrSyncOption>([asyncStringIterable]);\n"
  },
  {
    "path": "test-d/stdio/option/iterable-binary.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst binaryIterableFunction = function * () {\n\tyield new Uint8Array(0);\n};\n\nconst binaryIterable = binaryIterableFunction();\n\nawait execa('unicorns', {stdin: binaryIterable});\nexecaSync('unicorns', {stdin: binaryIterable});\nawait execa('unicorns', {stdin: [binaryIterable]});\nexecaSync('unicorns', {stdin: [binaryIterable]});\n\nexpectError(await execa('unicorns', {stdout: binaryIterable}));\nexpectError(execaSync('unicorns', {stdout: binaryIterable}));\nexpectError(await execa('unicorns', {stdout: [binaryIterable]}));\nexpectError(execaSync('unicorns', {stdout: [binaryIterable]}));\n\nexpectError(await execa('unicorns', {stderr: binaryIterable}));\nexpectError(execaSync('unicorns', {stderr: binaryIterable}));\nexpectError(await execa('unicorns', {stderr: [binaryIterable]}));\nexpectError(execaSync('unicorns', {stderr: [binaryIterable]}));\n\nexpectError(await execa('unicorns', {stdio: binaryIterable}));\nexpectError(execaSync('unicorns', {stdio: binaryIterable}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', binaryIterable]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', binaryIterable]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryIterable]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [binaryIterable]]}));\n\nexpectAssignable<StdinOption>(binaryIterable);\nexpectAssignable<StdinSyncOption>(binaryIterable);\nexpectAssignable<StdinOption>([binaryIterable]);\nexpectAssignable<StdinSyncOption>([binaryIterable]);\n\nexpectNotAssignable<StdoutStderrOption>(binaryIterable);\nexpectNotAssignable<StdoutStderrSyncOption>(binaryIterable);\nexpectNotAssignable<StdoutStderrOption>([binaryIterable]);\nexpectNotAssignable<StdoutStderrSyncOption>([binaryIterable]);\n"
  },
  {
    "path": "test-d/stdio/option/iterable-object.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst objectIterableFunction = function * () {\n\tyield {};\n};\n\nconst objectIterable = objectIterableFunction();\n\nawait execa('unicorns', {stdin: objectIterable});\nexecaSync('unicorns', {stdin: objectIterable});\nawait execa('unicorns', {stdin: [objectIterable]});\nexecaSync('unicorns', {stdin: [objectIterable]});\n\nexpectError(await execa('unicorns', {stdout: objectIterable}));\nexpectError(execaSync('unicorns', {stdout: objectIterable}));\nexpectError(await execa('unicorns', {stdout: [objectIterable]}));\nexpectError(execaSync('unicorns', {stdout: [objectIterable]}));\n\nexpectError(await execa('unicorns', {stderr: objectIterable}));\nexpectError(execaSync('unicorns', {stderr: objectIterable}));\nexpectError(await execa('unicorns', {stderr: [objectIterable]}));\nexpectError(execaSync('unicorns', {stderr: [objectIterable]}));\n\nexpectError(await execa('unicorns', {stdio: objectIterable}));\nexpectError(execaSync('unicorns', {stdio: objectIterable}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectIterable]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', objectIterable]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectIterable]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [objectIterable]]}));\n\nexpectAssignable<StdinOption>(objectIterable);\nexpectAssignable<StdinSyncOption>(objectIterable);\nexpectAssignable<StdinOption>([objectIterable]);\nexpectAssignable<StdinSyncOption>([objectIterable]);\n\nexpectNotAssignable<StdoutStderrOption>(objectIterable);\nexpectNotAssignable<StdoutStderrSyncOption>(objectIterable);\nexpectNotAssignable<StdoutStderrOption>([objectIterable]);\nexpectNotAssignable<StdoutStderrSyncOption>([objectIterable]);\n"
  },
  {
    "path": "test-d/stdio/option/iterable-string.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst stringIterableFunction = function * () {\n\tyield '';\n};\n\nconst stringIterable = stringIterableFunction();\n\nawait execa('unicorns', {stdin: stringIterable});\nexecaSync('unicorns', {stdin: stringIterable});\nawait execa('unicorns', {stdin: [stringIterable]});\nexecaSync('unicorns', {stdin: [stringIterable]});\n\nexpectError(await execa('unicorns', {stdout: stringIterable}));\nexpectError(execaSync('unicorns', {stdout: stringIterable}));\nexpectError(await execa('unicorns', {stdout: [stringIterable]}));\nexpectError(execaSync('unicorns', {stdout: [stringIterable]}));\n\nexpectError(await execa('unicorns', {stderr: stringIterable}));\nexpectError(execaSync('unicorns', {stderr: stringIterable}));\nexpectError(await execa('unicorns', {stderr: [stringIterable]}));\nexpectError(execaSync('unicorns', {stderr: [stringIterable]}));\n\nexpectError(await execa('unicorns', {stdio: stringIterable}));\nexpectError(execaSync('unicorns', {stdio: stringIterable}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringIterable]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', stringIterable]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringIterable]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [stringIterable]]}));\n\nexpectAssignable<StdinOption>(stringIterable);\nexpectAssignable<StdinSyncOption>(stringIterable);\nexpectAssignable<StdinOption>([stringIterable]);\nexpectAssignable<StdinSyncOption>([stringIterable]);\n\nexpectNotAssignable<StdoutStderrOption>(stringIterable);\nexpectNotAssignable<StdoutStderrSyncOption>(stringIterable);\nexpectNotAssignable<StdoutStderrOption>([stringIterable]);\nexpectNotAssignable<StdoutStderrSyncOption>([stringIterable]);\n"
  },
  {
    "path": "test-d/stdio/option/null.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: null}));\nexpectError(execaSync('unicorns', {stdin: null}));\nexpectError(await execa('unicorns', {stdin: [null]}));\nexpectError(execaSync('unicorns', {stdin: [null]}));\n\nexpectError(await execa('unicorns', {stdout: null}));\nexpectError(execaSync('unicorns', {stdout: null}));\nexpectError(await execa('unicorns', {stdout: [null]}));\nexpectError(execaSync('unicorns', {stdout: [null]}));\n\nexpectError(await execa('unicorns', {stderr: null}));\nexpectError(execaSync('unicorns', {stderr: null}));\nexpectError(await execa('unicorns', {stderr: [null]}));\nexpectError(execaSync('unicorns', {stderr: [null]}));\n\nexpectError(await execa('unicorns', {stdio: null}));\nexpectError(execaSync('unicorns', {stdio: null}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', null]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', null]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [null]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [null]]}));\n\nexpectNotAssignable<StdinOption>(null);\nexpectNotAssignable<StdinSyncOption>(null);\nexpectNotAssignable<StdinOption>([null]);\nexpectNotAssignable<StdinSyncOption>([null]);\n\nexpectNotAssignable<StdoutStderrOption>(null);\nexpectNotAssignable<StdoutStderrSyncOption>(null);\nexpectNotAssignable<StdoutStderrOption>([null]);\nexpectNotAssignable<StdoutStderrSyncOption>([null]);\n"
  },
  {
    "path": "test-d/stdio/option/overlapped.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 'overlapped'});\nexpectError(execaSync('unicorns', {stdin: 'overlapped'}));\nawait execa('unicorns', {stdin: ['overlapped']});\nexpectError(execaSync('unicorns', {stdin: ['overlapped']}));\n\nawait execa('unicorns', {stdout: 'overlapped'});\nexpectError(execaSync('unicorns', {stdout: 'overlapped'}));\nawait execa('unicorns', {stdout: ['overlapped']});\nexpectError(execaSync('unicorns', {stdout: ['overlapped']}));\n\nawait execa('unicorns', {stderr: 'overlapped'});\nexpectError(execaSync('unicorns', {stderr: 'overlapped'}));\nawait execa('unicorns', {stderr: ['overlapped']});\nexpectError(execaSync('unicorns', {stderr: ['overlapped']}));\n\nawait execa('unicorns', {stdio: 'overlapped'});\nexpectError(execaSync('unicorns', {stdio: 'overlapped'}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'overlapped']});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'overlapped']}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['overlapped']]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['overlapped']]}));\n\nexpectAssignable<StdinOption>('overlapped');\nexpectNotAssignable<StdinSyncOption>('overlapped');\nexpectAssignable<StdinOption>(['overlapped']);\nexpectNotAssignable<StdinSyncOption>(['overlapped']);\n\nexpectAssignable<StdoutStderrOption>('overlapped');\nexpectNotAssignable<StdoutStderrSyncOption>('overlapped');\nexpectAssignable<StdoutStderrOption>(['overlapped']);\nexpectNotAssignable<StdoutStderrSyncOption>(['overlapped']);\n"
  },
  {
    "path": "test-d/stdio/option/pipe-inherit.test-d.ts",
    "content": "import {expectError, expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst pipeInherit = ['pipe', 'inherit'] as const;\n\nawait execa('unicorns', {stdin: pipeInherit});\nexecaSync('unicorns', {stdin: pipeInherit});\n\nawait execa('unicorns', {stdout: pipeInherit});\nexecaSync('unicorns', {stdout: pipeInherit});\n\nawait execa('unicorns', {stderr: pipeInherit});\nexecaSync('unicorns', {stderr: pipeInherit});\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeInherit]}));\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeInherit]});\n\nexpectAssignable<StdinOption>(pipeInherit);\nexpectAssignable<StdinSyncOption>(pipeInherit);\n\nexpectAssignable<StdoutStderrOption>(pipeInherit);\nexpectAssignable<StdoutStderrSyncOption>(pipeInherit);\n"
  },
  {
    "path": "test-d/stdio/option/pipe-undefined.test-d.ts",
    "content": "import {expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst pipeUndefined = ['pipe', undefined] as const;\n\nawait execa('unicorns', {stdin: pipeUndefined});\nexecaSync('unicorns', {stdin: pipeUndefined});\n\nawait execa('unicorns', {stdout: pipeUndefined});\nexecaSync('unicorns', {stdout: pipeUndefined});\n\nawait execa('unicorns', {stderr: pipeUndefined});\nexecaSync('unicorns', {stderr: pipeUndefined});\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeUndefined]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', pipeUndefined]});\n\nexpectAssignable<StdinOption>(pipeUndefined);\nexpectAssignable<StdinSyncOption>(pipeUndefined);\n\nexpectAssignable<StdoutStderrOption>(pipeUndefined);\nexpectAssignable<StdoutStderrSyncOption>(pipeUndefined);\n"
  },
  {
    "path": "test-d/stdio/option/pipe-wide.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst pipe = 'pipe' as string;\nconst pipes = ['pipe'] as string[];\nconst pipesOfPipes = [['pipe']] as string[][];\n\nexpectError(await execa('unicorns', {stdin: pipe}));\nexpectError(execaSync('unicorns', {stdin: pipe}));\nexpectError(await execa('unicorns', {stdin: pipes}));\nexpectError(execaSync('unicorns', {stdin: pipes}));\n\nexpectError(await execa('unicorns', {stdout: pipe}));\nexpectError(execaSync('unicorns', {stdout: pipe}));\nexpectError(await execa('unicorns', {stdout: pipes}));\nexpectError(execaSync('unicorns', {stdout: pipes}));\n\nexpectError(await execa('unicorns', {stderr: pipe}));\nexpectError(execaSync('unicorns', {stderr: pipe}));\nexpectError(await execa('unicorns', {stderr: pipes}));\nexpectError(execaSync('unicorns', {stderr: pipes}));\n\nexpectError(await execa('unicorns', {stdio: pipe}));\nexpectError(execaSync('unicorns', {stdio: pipe}));\n\nexpectError(await execa('unicorns', {stdio: pipes}));\nexpectError(execaSync('unicorns', {stdio: pipes}));\nexpectError(await execa('unicorns', {stdio: pipesOfPipes}));\nexpectError(execaSync('unicorns', {stdio: pipesOfPipes}));\n\nexpectNotAssignable<StdinOption>(pipe);\nexpectNotAssignable<StdinSyncOption>(pipe);\nexpectNotAssignable<StdinOption>(pipes);\nexpectNotAssignable<StdinSyncOption>(pipes);\n\nexpectNotAssignable<StdoutStderrOption>(pipe);\nexpectNotAssignable<StdoutStderrSyncOption>(pipe);\nexpectNotAssignable<StdoutStderrOption>(pipes);\nexpectNotAssignable<StdoutStderrSyncOption>(pipes);\n"
  },
  {
    "path": "test-d/stdio/option/pipe.test-d.ts",
    "content": "import {expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: 'pipe'});\nexecaSync('unicorns', {stdin: 'pipe'});\nawait execa('unicorns', {stdin: ['pipe']});\nexecaSync('unicorns', {stdin: ['pipe']});\n\nawait execa('unicorns', {stdout: 'pipe'});\nexecaSync('unicorns', {stdout: 'pipe'});\nawait execa('unicorns', {stdout: ['pipe']});\nexecaSync('unicorns', {stdout: ['pipe']});\n\nawait execa('unicorns', {stderr: 'pipe'});\nexecaSync('unicorns', {stderr: 'pipe'});\nawait execa('unicorns', {stderr: ['pipe']});\nexecaSync('unicorns', {stderr: ['pipe']});\n\nawait execa('unicorns', {stdio: 'pipe'});\nexecaSync('unicorns', {stdio: 'pipe'});\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe']});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'pipe']});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['pipe']]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['pipe']]});\n\nexpectAssignable<StdinOption>('pipe');\nexpectAssignable<StdinSyncOption>('pipe');\nexpectAssignable<StdinOption>(['pipe']);\nexpectAssignable<StdinSyncOption>(['pipe']);\n\nexpectAssignable<StdoutStderrOption>('pipe');\nexpectAssignable<StdoutStderrSyncOption>('pipe');\nexpectAssignable<StdoutStderrOption>(['pipe']);\nexpectAssignable<StdoutStderrSyncOption>(['pipe']);\n"
  },
  {
    "path": "test-d/stdio/option/process-stderr.test-d.ts",
    "content": "import * as process from 'node:process';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: process.stderr}));\nexpectError(execaSync('unicorns', {stdin: process.stderr}));\nexpectError(await execa('unicorns', {stdin: [process.stderr]}));\nexpectError(execaSync('unicorns', {stdin: [process.stderr]}));\n\nawait execa('unicorns', {stdout: process.stderr});\nexecaSync('unicorns', {stdout: process.stderr});\nawait execa('unicorns', {stdout: [process.stderr]});\nexpectError(execaSync('unicorns', {stdout: [process.stderr]}));\n\nawait execa('unicorns', {stderr: process.stderr});\nexecaSync('unicorns', {stderr: process.stderr});\nawait execa('unicorns', {stderr: [process.stderr]});\nexpectError(execaSync('unicorns', {stderr: [process.stderr]}));\n\nexpectError(await execa('unicorns', {stdio: process.stderr}));\nexpectError(execaSync('unicorns', {stdio: process.stderr}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', process.stderr]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', process.stderr]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [process.stderr]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [process.stderr]]}));\n\nexpectNotAssignable<StdinOption>(process.stderr);\nexpectNotAssignable<StdinSyncOption>(process.stderr);\nexpectNotAssignable<StdinOption>([process.stderr]);\nexpectNotAssignable<StdinSyncOption>([process.stderr]);\n\nexpectAssignable<StdoutStderrOption>(process.stderr);\nexpectAssignable<StdoutStderrSyncOption>(process.stderr);\nexpectAssignable<StdoutStderrOption>([process.stderr]);\nexpectNotAssignable<StdoutStderrSyncOption>([process.stderr]);\n"
  },
  {
    "path": "test-d/stdio/option/process-stdin.test-d.ts",
    "content": "import * as process from 'node:process';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: process.stdin});\nexecaSync('unicorns', {stdin: process.stdin});\nawait execa('unicorns', {stdin: [process.stdin]});\nexpectError(execaSync('unicorns', {stdin: [process.stdin]}));\n\nexpectError(await execa('unicorns', {stdout: process.stdin}));\nexpectError(execaSync('unicorns', {stdout: process.stdin}));\nexpectError(await execa('unicorns', {stdout: [process.stdin]}));\nexpectError(execaSync('unicorns', {stdout: [process.stdin]}));\n\nexpectError(await execa('unicorns', {stderr: process.stdin}));\nexpectError(execaSync('unicorns', {stderr: process.stdin}));\nexpectError(await execa('unicorns', {stderr: [process.stdin]}));\nexpectError(execaSync('unicorns', {stderr: [process.stdin]}));\n\nexpectError(await execa('unicorns', {stdio: process.stdin}));\nexpectError(execaSync('unicorns', {stdio: process.stdin}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', process.stdin]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', process.stdin]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [process.stdin]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [process.stdin]]}));\n\nexpectAssignable<StdinOption>(process.stdin);\nexpectAssignable<StdinSyncOption>(process.stdin);\nexpectAssignable<StdinOption>([process.stdin]);\nexpectNotAssignable<StdinSyncOption>([process.stdin]);\n\nexpectNotAssignable<StdoutStderrOption>(process.stdin);\nexpectNotAssignable<StdoutStderrSyncOption>(process.stdin);\nexpectNotAssignable<StdoutStderrOption>([process.stdin]);\nexpectNotAssignable<StdoutStderrSyncOption>([process.stdin]);\n"
  },
  {
    "path": "test-d/stdio/option/process-stdout.test-d.ts",
    "content": "import * as process from 'node:process';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: process.stdout}));\nexpectError(execaSync('unicorns', {stdin: process.stdout}));\nexpectError(await execa('unicorns', {stdin: [process.stdout]}));\nexpectError(execaSync('unicorns', {stdin: [process.stdout]}));\n\nawait execa('unicorns', {stdout: process.stdout});\nexecaSync('unicorns', {stdout: process.stdout});\nawait execa('unicorns', {stdout: [process.stdout]});\nexpectError(execaSync('unicorns', {stdout: [process.stdout]}));\n\nawait execa('unicorns', {stderr: process.stdout});\nexecaSync('unicorns', {stderr: process.stdout});\nawait execa('unicorns', {stderr: [process.stdout]});\nexpectError(execaSync('unicorns', {stderr: [process.stdout]}));\n\nexpectError(await execa('unicorns', {stdio: process.stdout}));\nexpectError(execaSync('unicorns', {stdio: process.stdout}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', process.stdout]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', process.stdout]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [process.stdout]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [process.stdout]]}));\n\nexpectNotAssignable<StdinOption>(process.stdout);\nexpectNotAssignable<StdinSyncOption>(process.stdout);\nexpectNotAssignable<StdinOption>([process.stdout]);\nexpectNotAssignable<StdinSyncOption>([process.stdout]);\n\nexpectAssignable<StdoutStderrOption>(process.stdout);\nexpectAssignable<StdoutStderrSyncOption>(process.stdout);\nexpectAssignable<StdoutStderrOption>([process.stdout]);\nexpectNotAssignable<StdoutStderrSyncOption>([process.stdout]);\n"
  },
  {
    "path": "test-d/stdio/option/readable-stream.test-d.ts",
    "content": "import {ReadableStream} from 'node:stream/web';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: new ReadableStream()});\nexpectError(execaSync('unicorns', {stdin: new ReadableStream()}));\nawait execa('unicorns', {stdin: [new ReadableStream()]});\nexpectError(execaSync('unicorns', {stdin: [new ReadableStream()]}));\n\nexpectError(await execa('unicorns', {stdout: new ReadableStream()}));\nexpectError(execaSync('unicorns', {stdout: new ReadableStream()}));\nexpectError(await execa('unicorns', {stdout: [new ReadableStream()]}));\nexpectError(execaSync('unicorns', {stdout: [new ReadableStream()]}));\n\nexpectError(await execa('unicorns', {stderr: new ReadableStream()}));\nexpectError(execaSync('unicorns', {stderr: new ReadableStream()}));\nexpectError(await execa('unicorns', {stderr: [new ReadableStream()]}));\nexpectError(execaSync('unicorns', {stderr: [new ReadableStream()]}));\n\nexpectError(await execa('unicorns', {stdio: new ReadableStream()}));\nexpectError(execaSync('unicorns', {stdio: new ReadableStream()}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new ReadableStream()]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new ReadableStream()]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new ReadableStream()]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new ReadableStream()]]}));\n\nexpectAssignable<StdinOption>(new ReadableStream());\nexpectNotAssignable<StdinSyncOption>(new ReadableStream());\nexpectAssignable<StdinOption>([new ReadableStream()]);\nexpectNotAssignable<StdinSyncOption>([new ReadableStream()]);\n\nexpectNotAssignable<StdoutStderrOption>(new ReadableStream());\nexpectNotAssignable<StdoutStderrSyncOption>(new ReadableStream());\nexpectNotAssignable<StdoutStderrOption>([new ReadableStream()]);\nexpectNotAssignable<StdoutStderrSyncOption>([new ReadableStream()]);\n"
  },
  {
    "path": "test-d/stdio/option/readable.test-d.ts",
    "content": "import {Readable} from 'node:stream';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: new Readable()});\nexecaSync('unicorns', {stdin: new Readable()});\nawait execa('unicorns', {stdin: [new Readable()]});\nexpectError(execaSync('unicorns', {stdin: [new Readable()]}));\n\nexpectError(await execa('unicorns', {stdout: new Readable()}));\nexpectError(execaSync('unicorns', {stdout: new Readable()}));\nexpectError(await execa('unicorns', {stdout: [new Readable()]}));\nexpectError(execaSync('unicorns', {stdout: [new Readable()]}));\n\nexpectError(await execa('unicorns', {stderr: new Readable()}));\nexpectError(execaSync('unicorns', {stderr: new Readable()}));\nexpectError(await execa('unicorns', {stderr: [new Readable()]}));\nexpectError(execaSync('unicorns', {stderr: [new Readable()]}));\n\nexpectError(await execa('unicorns', {stdio: new Readable()}));\nexpectError(execaSync('unicorns', {stdio: new Readable()}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new Readable()]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new Readable()]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new Readable()]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new Readable()]]}));\n\nexpectAssignable<StdinOption>(new Readable());\nexpectAssignable<StdinSyncOption>(new Readable());\nexpectAssignable<StdinOption>([new Readable()]);\nexpectNotAssignable<StdinSyncOption>([new Readable()]);\n\nexpectNotAssignable<StdoutStderrOption>(new Readable());\nexpectNotAssignable<StdoutStderrSyncOption>(new Readable());\nexpectNotAssignable<StdoutStderrOption>([new Readable()]);\nexpectNotAssignable<StdoutStderrSyncOption>([new Readable()]);\n"
  },
  {
    "path": "test-d/stdio/option/uint-array.test-d.ts",
    "content": "import {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: new Uint8Array()});\nexecaSync('unicorns', {stdin: new Uint8Array()});\nawait execa('unicorns', {stdin: [new Uint8Array()]});\nexecaSync('unicorns', {stdin: [new Uint8Array()]});\n\nexpectError(await execa('unicorns', {stdout: new Uint8Array()}));\nexpectError(execaSync('unicorns', {stdout: new Uint8Array()}));\nexpectError(await execa('unicorns', {stdout: [new Uint8Array()]}));\nexpectError(execaSync('unicorns', {stdout: [new Uint8Array()]}));\n\nexpectError(await execa('unicorns', {stderr: new Uint8Array()}));\nexpectError(execaSync('unicorns', {stderr: new Uint8Array()}));\nexpectError(await execa('unicorns', {stderr: [new Uint8Array()]}));\nexpectError(execaSync('unicorns', {stderr: [new Uint8Array()]}));\n\nexpectError(await execa('unicorns', {stdio: new Uint8Array()}));\nexpectError(execaSync('unicorns', {stdio: new Uint8Array()}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new Uint8Array()]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new Uint8Array()]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new Uint8Array()]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new Uint8Array()]]}));\n\nexpectAssignable<StdinOption>(new Uint8Array());\nexpectAssignable<StdinSyncOption>(new Uint8Array());\nexpectAssignable<StdinOption>([new Uint8Array()]);\nexpectAssignable<StdinSyncOption>([new Uint8Array()]);\n\nexpectNotAssignable<StdoutStderrOption>(new Uint8Array());\nexpectNotAssignable<StdoutStderrSyncOption>(new Uint8Array());\nexpectNotAssignable<StdoutStderrOption>([new Uint8Array()]);\nexpectNotAssignable<StdoutStderrSyncOption>([new Uint8Array()]);\n"
  },
  {
    "path": "test-d/stdio/option/undefined.test-d.ts",
    "content": "import {expectAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nawait execa('unicorns', {stdin: undefined});\nexecaSync('unicorns', {stdin: undefined});\nawait execa('unicorns', {stdin: [undefined]});\nexecaSync('unicorns', {stdin: [undefined]});\n\nawait execa('unicorns', {stdout: undefined});\nexecaSync('unicorns', {stdout: undefined});\nawait execa('unicorns', {stdout: [undefined]});\nexecaSync('unicorns', {stdout: [undefined]});\n\nawait execa('unicorns', {stderr: undefined});\nexecaSync('unicorns', {stderr: undefined});\nawait execa('unicorns', {stderr: [undefined]});\nexecaSync('unicorns', {stderr: [undefined]});\n\nawait execa('unicorns', {stdio: undefined});\nexecaSync('unicorns', {stdio: undefined});\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', undefined]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', undefined]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [undefined]]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [undefined]]});\n\nexpectAssignable<StdinOption>(undefined);\nexpectAssignable<StdinSyncOption>(undefined);\nexpectAssignable<StdinOption>([undefined]);\nexpectAssignable<StdinSyncOption>([undefined]);\n\nexpectAssignable<StdoutStderrOption>(undefined);\nexpectAssignable<StdoutStderrSyncOption>(undefined);\nexpectAssignable<StdoutStderrOption>([undefined]);\nexpectAssignable<StdoutStderrSyncOption>([undefined]);\n"
  },
  {
    "path": "test-d/stdio/option/unknown.test-d.ts",
    "content": "import {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: 'unknown'}));\nexpectError(execaSync('unicorns', {stdin: 'unknown'}));\nexpectError(await execa('unicorns', {stdin: ['unknown']}));\nexpectError(execaSync('unicorns', {stdin: ['unknown']}));\n\nexpectError(await execa('unicorns', {stdout: 'unknown'}));\nexpectError(execaSync('unicorns', {stdout: 'unknown'}));\nexpectError(await execa('unicorns', {stdout: ['unknown']}));\nexpectError(execaSync('unicorns', {stdout: ['unknown']}));\n\nexpectError(await execa('unicorns', {stderr: 'unknown'}));\nexpectError(execaSync('unicorns', {stderr: 'unknown'}));\nexpectError(await execa('unicorns', {stderr: ['unknown']}));\nexpectError(execaSync('unicorns', {stderr: ['unknown']}));\n\nexpectError(await execa('unicorns', {stdio: 'unknown'}));\nexpectError(execaSync('unicorns', {stdio: 'unknown'}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'unknown']}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', 'unknown']}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['unknown']]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', ['unknown']]}));\n\nexpectNotAssignable<StdinOption>('unknown');\nexpectNotAssignable<StdinSyncOption>('unknown');\nexpectNotAssignable<StdinOption>(['unknown']);\nexpectNotAssignable<StdinSyncOption>(['unknown']);\n\nexpectNotAssignable<StdoutStderrOption>('unknown');\nexpectNotAssignable<StdoutStderrSyncOption>('unknown');\nexpectNotAssignable<StdoutStderrOption>(['unknown']);\nexpectNotAssignable<StdoutStderrSyncOption>(['unknown']);\n"
  },
  {
    "path": "test-d/stdio/option/web-transform-instance.test-d.ts",
    "content": "import {TransformStream} from 'node:stream/web';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst webTransformInstance = new TransformStream();\n\nawait execa('unicorns', {stdin: webTransformInstance});\nexpectError(execaSync('unicorns', {stdin: webTransformInstance}));\nawait execa('unicorns', {stdin: [webTransformInstance]});\nexpectError(execaSync('unicorns', {stdin: [webTransformInstance]}));\n\nawait execa('unicorns', {stdout: webTransformInstance});\nexpectError(execaSync('unicorns', {stdout: webTransformInstance}));\nawait execa('unicorns', {stdout: [webTransformInstance]});\nexpectError(execaSync('unicorns', {stdout: [webTransformInstance]}));\n\nawait execa('unicorns', {stderr: webTransformInstance});\nexpectError(execaSync('unicorns', {stderr: webTransformInstance}));\nawait execa('unicorns', {stderr: [webTransformInstance]});\nexpectError(execaSync('unicorns', {stderr: [webTransformInstance]}));\n\nexpectError(await execa('unicorns', {stdio: webTransformInstance}));\nexpectError(execaSync('unicorns', {stdio: webTransformInstance}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransformInstance]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransformInstance]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransformInstance]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransformInstance]]}));\n\nexpectAssignable<StdinOption>(webTransformInstance);\nexpectNotAssignable<StdinSyncOption>(webTransformInstance);\nexpectAssignable<StdinOption>([webTransformInstance]);\nexpectNotAssignable<StdinSyncOption>([webTransformInstance]);\n\nexpectAssignable<StdoutStderrOption>(webTransformInstance);\nexpectNotAssignable<StdoutStderrSyncOption>(webTransformInstance);\nexpectAssignable<StdoutStderrOption>([webTransformInstance]);\nexpectNotAssignable<StdoutStderrSyncOption>([webTransformInstance]);\n"
  },
  {
    "path": "test-d/stdio/option/web-transform-invalid.test-d.ts",
    "content": "import {TransformStream} from 'node:stream/web';\nimport {expectError, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst webTransformWithInvalidObjectMode = {\n\ttransform: new TransformStream(),\n\tobjectMode: 'true',\n} as const;\n\nexpectError(await execa('unicorns', {stdin: webTransformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdin: webTransformWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stdin: [webTransformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdin: [webTransformWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stdout: webTransformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdout: webTransformWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stdout: [webTransformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdout: [webTransformWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stderr: webTransformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stderr: webTransformWithInvalidObjectMode}));\nexpectError(await execa('unicorns', {stderr: [webTransformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stderr: [webTransformWithInvalidObjectMode]}));\n\nexpectError(await execa('unicorns', {stdio: webTransformWithInvalidObjectMode}));\nexpectError(execaSync('unicorns', {stdio: webTransformWithInvalidObjectMode}));\n\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransformWithInvalidObjectMode]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransformWithInvalidObjectMode]}));\nexpectError(await execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransformWithInvalidObjectMode]]}));\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransformWithInvalidObjectMode]]}));\n\nexpectNotAssignable<StdinOption>(webTransformWithInvalidObjectMode);\nexpectNotAssignable<StdinSyncOption>(webTransformWithInvalidObjectMode);\nexpectNotAssignable<StdinOption>([webTransformWithInvalidObjectMode]);\nexpectNotAssignable<StdinSyncOption>([webTransformWithInvalidObjectMode]);\n\nexpectNotAssignable<StdoutStderrOption>(webTransformWithInvalidObjectMode);\nexpectNotAssignable<StdoutStderrSyncOption>(webTransformWithInvalidObjectMode);\nexpectNotAssignable<StdoutStderrOption>([webTransformWithInvalidObjectMode]);\nexpectNotAssignable<StdoutStderrSyncOption>([webTransformWithInvalidObjectMode]);\n"
  },
  {
    "path": "test-d/stdio/option/web-transform-object.test-d.ts",
    "content": "import {TransformStream} from 'node:stream/web';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst webTransformObject = {\n\ttransform: new TransformStream(),\n\tobjectMode: true as const,\n} as const;\n\nawait execa('unicorns', {stdin: webTransformObject});\nexpectError(execaSync('unicorns', {stdin: webTransformObject}));\nawait execa('unicorns', {stdin: [webTransformObject]});\nexpectError(execaSync('unicorns', {stdin: [webTransformObject]}));\n\nawait execa('unicorns', {stdout: webTransformObject});\nexpectError(execaSync('unicorns', {stdout: webTransformObject}));\nawait execa('unicorns', {stdout: [webTransformObject]});\nexpectError(execaSync('unicorns', {stdout: [webTransformObject]}));\n\nawait execa('unicorns', {stderr: webTransformObject});\nexpectError(execaSync('unicorns', {stderr: webTransformObject}));\nawait execa('unicorns', {stderr: [webTransformObject]});\nexpectError(execaSync('unicorns', {stderr: [webTransformObject]}));\n\nexpectError(await execa('unicorns', {stdio: webTransformObject}));\nexpectError(execaSync('unicorns', {stdio: webTransformObject}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransformObject]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransformObject]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransformObject]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransformObject]]}));\n\nexpectAssignable<StdinOption>(webTransformObject);\nexpectNotAssignable<StdinSyncOption>(webTransformObject);\nexpectAssignable<StdinOption>([webTransformObject]);\nexpectNotAssignable<StdinSyncOption>([webTransformObject]);\n\nexpectAssignable<StdoutStderrOption>(webTransformObject);\nexpectNotAssignable<StdoutStderrSyncOption>(webTransformObject);\nexpectAssignable<StdoutStderrOption>([webTransformObject]);\nexpectNotAssignable<StdoutStderrSyncOption>([webTransformObject]);\n"
  },
  {
    "path": "test-d/stdio/option/web-transform.test-d.ts",
    "content": "import {TransformStream} from 'node:stream/web';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nconst webTransform = {transform: new TransformStream()} as const;\n\nawait execa('unicorns', {stdin: webTransform});\nexpectError(execaSync('unicorns', {stdin: webTransform}));\nawait execa('unicorns', {stdin: [webTransform]});\nexpectError(execaSync('unicorns', {stdin: [webTransform]}));\n\nawait execa('unicorns', {stdout: webTransform});\nexpectError(execaSync('unicorns', {stdout: webTransform}));\nawait execa('unicorns', {stdout: [webTransform]});\nexpectError(execaSync('unicorns', {stdout: [webTransform]}));\n\nawait execa('unicorns', {stderr: webTransform});\nexpectError(execaSync('unicorns', {stderr: webTransform}));\nawait execa('unicorns', {stderr: [webTransform]});\nexpectError(execaSync('unicorns', {stderr: [webTransform]}));\n\nexpectError(await execa('unicorns', {stdio: webTransform}));\nexpectError(execaSync('unicorns', {stdio: webTransform}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransform]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', webTransform]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransform]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [webTransform]]}));\n\nexpectAssignable<StdinOption>(webTransform);\nexpectNotAssignable<StdinSyncOption>(webTransform);\nexpectAssignable<StdinOption>([webTransform]);\nexpectNotAssignable<StdinSyncOption>([webTransform]);\n\nexpectAssignable<StdoutStderrOption>(webTransform);\nexpectNotAssignable<StdoutStderrSyncOption>(webTransform);\nexpectAssignable<StdoutStderrOption>([webTransform]);\nexpectNotAssignable<StdoutStderrSyncOption>([webTransform]);\n"
  },
  {
    "path": "test-d/stdio/option/writable-stream.test-d.ts",
    "content": "import {WritableStream} from 'node:stream/web';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: new WritableStream()}));\nexpectError(execaSync('unicorns', {stdin: new WritableStream()}));\nexpectError(await execa('unicorns', {stdin: [new WritableStream()]}));\nexpectError(execaSync('unicorns', {stdin: [new WritableStream()]}));\n\nawait execa('unicorns', {stdout: new WritableStream()});\nexpectError(execaSync('unicorns', {stdout: new WritableStream()}));\nawait execa('unicorns', {stdout: [new WritableStream()]});\nexpectError(execaSync('unicorns', {stdout: [new WritableStream()]}));\n\nawait execa('unicorns', {stderr: new WritableStream()});\nexpectError(execaSync('unicorns', {stderr: new WritableStream()}));\nawait execa('unicorns', {stderr: [new WritableStream()]});\nexpectError(execaSync('unicorns', {stderr: [new WritableStream()]}));\n\nexpectError(await execa('unicorns', {stdio: new WritableStream()}));\nexpectError(execaSync('unicorns', {stdio: new WritableStream()}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new WritableStream()]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new WritableStream()]}));\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new WritableStream()]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new WritableStream()]]}));\n\nexpectNotAssignable<StdinOption>(new WritableStream());\nexpectNotAssignable<StdinSyncOption>(new WritableStream());\nexpectNotAssignable<StdinOption>([new WritableStream()]);\nexpectNotAssignable<StdinSyncOption>([new WritableStream()]);\n\nexpectAssignable<StdoutStderrOption>(new WritableStream());\nexpectNotAssignable<StdoutStderrSyncOption>(new WritableStream());\nexpectAssignable<StdoutStderrOption>([new WritableStream()]);\nexpectNotAssignable<StdoutStderrSyncOption>([new WritableStream()]);\n"
  },
  {
    "path": "test-d/stdio/option/writable.test-d.ts",
    "content": "import {Writable} from 'node:stream';\nimport {expectError, expectAssignable, expectNotAssignable} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype StdinOption,\n\ttype StdinSyncOption,\n\ttype StdoutStderrOption,\n\ttype StdoutStderrSyncOption,\n} from '../../../index.js';\n\nexpectError(await execa('unicorns', {stdin: new Writable()}));\nexpectError(execaSync('unicorns', {stdin: new Writable()}));\nexpectError(await execa('unicorns', {stdin: [new Writable()]}));\nexpectError(execaSync('unicorns', {stdin: [new Writable()]}));\n\nawait execa('unicorns', {stdout: new Writable()});\nexecaSync('unicorns', {stdout: new Writable()});\nawait execa('unicorns', {stdout: [new Writable()]});\nexpectError(execaSync('unicorns', {stdout: [new Writable()]}));\n\nawait execa('unicorns', {stderr: new Writable()});\nexecaSync('unicorns', {stderr: new Writable()});\nawait execa('unicorns', {stderr: [new Writable()]});\nexpectError(execaSync('unicorns', {stderr: [new Writable()]}));\n\nexpectError(await execa('unicorns', {stdio: new Writable()}));\nexpectError(execaSync('unicorns', {stdio: new Writable()}));\n\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new Writable()]});\nexecaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', new Writable()]});\nawait execa('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new Writable()]]});\nexpectError(execaSync('unicorns', {stdio: ['pipe', 'pipe', 'pipe', [new Writable()]]}));\n\nexpectNotAssignable<StdinOption>(new Writable());\nexpectNotAssignable<StdinSyncOption>(new Writable());\nexpectNotAssignable<StdinOption>([new Writable()]);\nexpectNotAssignable<StdinSyncOption>([new Writable()]);\n\nexpectAssignable<StdoutStderrOption>(new Writable());\nexpectAssignable<StdoutStderrSyncOption>(new Writable());\nexpectAssignable<StdoutStderrOption>([new Writable()]);\nexpectNotAssignable<StdoutStderrSyncOption>([new Writable()]);\n"
  },
  {
    "path": "test-d/subprocess/all.test-d.ts",
    "content": "import type {Readable} from 'node:stream';\nimport {expectType} from 'tsd';\nimport {execa} from '../../index.js';\n\nconst allSubprocess = execa('unicorns', {all: true});\nexpectType<Readable>(allSubprocess.all);\n\nconst noAllSubprocess = execa('unicorns');\nexpectType<undefined>(noAllSubprocess.all);\n"
  },
  {
    "path": "test-d/subprocess/stdio.test-d.ts",
    "content": "import type {Readable, Writable} from 'node:stream';\nimport {expectType, expectError} from 'tsd';\nimport {execa, type Subprocess} from '../../index.js';\n\nexpectType<Writable | null>({} as Subprocess['stdin']);\nexpectType<Readable | null>({} as Subprocess['stdout']);\nexpectType<Readable | null>({} as Subprocess['stderr']);\nexpectType<Readable | undefined>({} as Subprocess['all']);\n\nconst bufferSubprocess = execa('unicorns', {encoding: 'buffer', all: true});\nexpectType<Writable>(bufferSubprocess.stdin);\nexpectType<Writable>(bufferSubprocess.stdio[0]);\nexpectType<Readable>(bufferSubprocess.stdout);\nexpectType<Readable>(bufferSubprocess.stdio[1]);\nexpectType<Readable>(bufferSubprocess.stderr);\nexpectType<Readable>(bufferSubprocess.stdio[2]);\nexpectType<Readable>(bufferSubprocess.all);\nexpectError(bufferSubprocess.stdio[3].destroy());\n\nconst hexSubprocess = execa('unicorns', {encoding: 'hex', all: true});\nexpectType<Writable>(hexSubprocess.stdin);\nexpectType<Writable>(hexSubprocess.stdio[0]);\nexpectType<Readable>(hexSubprocess.stdout);\nexpectType<Readable>(hexSubprocess.stdio[1]);\nexpectType<Readable>(hexSubprocess.stderr);\nexpectType<Readable>(hexSubprocess.stdio[2]);\nexpectType<Readable>(hexSubprocess.all);\nexpectError(hexSubprocess.stdio[3].destroy());\n\nconst multipleStdinSubprocess = execa('unicorns', {stdin: ['inherit', 'pipe']});\nexpectType<Writable>(multipleStdinSubprocess.stdin);\n\nconst multipleStdoutSubprocess = execa('unicorns', {stdout: ['inherit', 'pipe'] as ['inherit', 'pipe'], all: true});\nexpectType<Writable>(multipleStdoutSubprocess.stdin);\nexpectType<Writable>(multipleStdoutSubprocess.stdio[0]);\nexpectType<Readable>(multipleStdoutSubprocess.stdout);\nexpectType<Readable>(multipleStdoutSubprocess.stdio[1]);\nexpectType<Readable>(multipleStdoutSubprocess.stderr);\nexpectType<Readable>(multipleStdoutSubprocess.stdio[2]);\nexpectType<Readable>(multipleStdoutSubprocess.all);\nexpectError(multipleStdoutSubprocess.stdio[3].destroy());\n"
  },
  {
    "path": "test-d/subprocess/subprocess.test-d.ts",
    "content": "import {expectType, expectError, expectAssignable} from 'tsd';\nimport {execa, type Subprocess} from '../../index.js';\n\nconst subprocess = execa('unicorns');\nexpectAssignable<Subprocess>(subprocess);\n\nexpectType<number | undefined>(subprocess.pid);\n\nexpectType<boolean>(subprocess.kill());\nsubprocess.kill('SIGKILL');\nsubprocess.kill(undefined);\nsubprocess.kill(new Error('test'));\nsubprocess.kill('SIGKILL', new Error('test'));\nsubprocess.kill(undefined, new Error('test'));\nexpectError(subprocess.kill(null));\nexpectError(subprocess.kill(0n));\nexpectError(subprocess.kill('Sigkill'));\nexpectError(subprocess.kill('sigkill'));\nexpectError(subprocess.kill('SIGOTHER'));\nexpectError(subprocess.kill('SIGEMT'));\nexpectError(subprocess.kill('SIGCLD'));\nexpectError(subprocess.kill('SIGRT1'));\nexpectError(subprocess.kill([new Error('test')]));\nexpectError(subprocess.kill({message: 'test'}));\nexpectError(subprocess.kill(undefined, {}));\nexpectError(subprocess.kill('SIGKILL', {}));\nexpectError(subprocess.kill(null, new Error('test')));\n\nconst ipcSubprocess = execa('unicorns', {ipc: true});\nexpectAssignable<Subprocess>(subprocess);\n"
  },
  {
    "path": "test-d/transform/object-mode.test-d.ts",
    "content": "import {Duplex} from 'node:stream';\nimport {TransformStream} from 'node:stream/web';\nimport {expectType} from 'tsd';\nimport {execa, type ExecaError} from '../../index.js';\n\nconst duplexStream = new Duplex();\nconst duplex = {transform: duplexStream} as const;\nconst duplexObject = {transform: duplexStream as Duplex & {readonly readableObjectMode: true}} as const;\nconst duplexNotObject = {transform: duplexStream as Duplex & {readonly readableObjectMode: false}} as const;\nconst duplexObjectProperty = {transform: duplexStream, objectMode: true as const} as const;\nconst duplexNotObjectProperty = {transform: duplexStream, objectMode: false as const} as const;\n\nconst webTransformInstance = new TransformStream();\nconst webTransform = {transform: webTransformInstance} as const;\nconst webTransformObject = {transform: webTransformInstance, objectMode: true as const} as const;\nconst webTransformNotObject = {transform: webTransformInstance, objectMode: false as const} as const;\n\nconst objectGenerator = function * (line: unknown) {\n\tyield JSON.parse(line as string) as object;\n};\n\nconst objectFinal = function * () {\n\tyield {};\n};\n\nconst objectTransformLinesStdoutResult = await execa('unicorns', {lines: true, stdout: {transform: objectGenerator, final: objectFinal, objectMode: true} as const});\nexpectType<unknown[]>(objectTransformLinesStdoutResult.stdout);\nexpectType<[undefined, unknown[], string[]]>(objectTransformLinesStdoutResult.stdio);\n\nconst objectWebTransformStdoutResult = await execa('unicorns', {stdout: webTransformObject});\nexpectType<unknown[]>(objectWebTransformStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(objectWebTransformStdoutResult.stdio);\n\nconst objectDuplexStdoutResult = await execa('unicorns', {stdout: duplexObject});\nexpectType<unknown[]>(objectDuplexStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(objectDuplexStdoutResult.stdio);\n\nconst objectDuplexPropertyStdoutResult = await execa('unicorns', {stdout: duplexObjectProperty});\nexpectType<unknown[]>(objectDuplexPropertyStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(objectDuplexPropertyStdoutResult.stdio);\n\nconst objectTransformStdoutResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal, objectMode: true} as const});\nexpectType<unknown[]>(objectTransformStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(objectTransformStdoutResult.stdio);\n\nconst objectWebTransformStderrResult = await execa('unicorns', {stderr: webTransformObject});\nexpectType<unknown[]>(objectWebTransformStderrResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectWebTransformStderrResult.stdio);\n\nconst objectDuplexStderrResult = await execa('unicorns', {stderr: duplexObject});\nexpectType<unknown[]>(objectDuplexStderrResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectDuplexStderrResult.stdio);\n\nconst objectDuplexPropertyStderrResult = await execa('unicorns', {stderr: duplexObjectProperty});\nexpectType<unknown[]>(objectDuplexPropertyStderrResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectDuplexPropertyStderrResult.stdio);\n\nconst objectTransformStderrResult = await execa('unicorns', {stderr: {transform: objectGenerator, final: objectFinal, objectMode: true} as const});\nexpectType<unknown[]>(objectTransformStderrResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectTransformStderrResult.stdio);\n\nconst objectWebTransformStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', webTransformObject]});\nexpectType<unknown[]>(objectWebTransformStdioResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectWebTransformStdioResult.stdio);\n\nconst objectDuplexStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', duplexObject]});\nexpectType<unknown[]>(objectDuplexStdioResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectDuplexStdioResult.stdio);\n\nconst objectDuplexPropertyStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', duplexObjectProperty]});\nexpectType<unknown[]>(objectDuplexPropertyStdioResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectDuplexPropertyStdioResult.stdio);\n\nconst objectTransformStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', {transform: objectGenerator, final: objectFinal, objectMode: true} as const]});\nexpectType<unknown[]>(objectTransformStdioResult.stderr);\nexpectType<[undefined, string, unknown[]]>(objectTransformStdioResult.stdio);\n\nconst singleObjectWebTransformStdoutResult = await execa('unicorns', {stdout: [webTransformObject]});\nexpectType<unknown[]>(singleObjectWebTransformStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(singleObjectWebTransformStdoutResult.stdio);\n\nconst singleObjectDuplexStdoutResult = await execa('unicorns', {stdout: [duplexObject]});\nexpectType<unknown[]>(singleObjectDuplexStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(singleObjectDuplexStdoutResult.stdio);\n\nconst singleObjectDuplexPropertyStdoutResult = await execa('unicorns', {stdout: [duplexObjectProperty]});\nexpectType<unknown[]>(singleObjectDuplexPropertyStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(singleObjectDuplexPropertyStdoutResult.stdio);\n\nconst singleObjectTransformStdoutResult = await execa('unicorns', {stdout: [{transform: objectGenerator, final: objectFinal, objectMode: true} as const]});\nexpectType<unknown[]>(singleObjectTransformStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(singleObjectTransformStdoutResult.stdio);\n\nconst manyObjectWebTransformStdoutResult = await execa('unicorns', {stdout: [webTransformObject, webTransformObject]});\nexpectType<unknown[]>(manyObjectWebTransformStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(manyObjectWebTransformStdoutResult.stdio);\n\nconst manyObjectDuplexStdoutResult = await execa('unicorns', {stdout: [duplexObject, duplexObject]});\nexpectType<unknown[]>(manyObjectDuplexStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(manyObjectDuplexStdoutResult.stdio);\n\nconst manyObjectDuplexPropertyStdoutResult = await execa('unicorns', {stdout: [duplexObjectProperty, duplexObjectProperty]});\nexpectType<unknown[]>(manyObjectDuplexPropertyStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(manyObjectDuplexPropertyStdoutResult.stdio);\n\nconst manyObjectTransformStdoutResult = await execa('unicorns', {stdout: [{transform: objectGenerator, final: objectFinal, objectMode: true} as const, {transform: objectGenerator, final: objectFinal, objectMode: true} as const]});\nexpectType<unknown[]>(manyObjectTransformStdoutResult.stdout);\nexpectType<[undefined, unknown[], string]>(manyObjectTransformStdoutResult.stdio);\n\nconst falseObjectWebTransformStdoutResult = await execa('unicorns', {stdout: webTransformNotObject});\nexpectType<string>(falseObjectWebTransformStdoutResult.stdout);\nexpectType<[undefined, string, string]>(falseObjectWebTransformStdoutResult.stdio);\n\nconst falseObjectDuplexStdoutResult = await execa('unicorns', {stdout: duplexNotObject});\nexpectType<string>(falseObjectDuplexStdoutResult.stdout);\nexpectType<[undefined, string, string]>(falseObjectDuplexStdoutResult.stdio);\n\nconst falseObjectDuplexPropertyStdoutResult = await execa('unicorns', {stdout: duplexNotObjectProperty});\nexpectType<string>(falseObjectDuplexPropertyStdoutResult.stdout);\nexpectType<[undefined, string, string]>(falseObjectDuplexPropertyStdoutResult.stdio);\n\nconst falseObjectTransformStdoutResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal, objectMode: false} as const});\nexpectType<string>(falseObjectTransformStdoutResult.stdout);\nexpectType<[undefined, string, string]>(falseObjectTransformStdoutResult.stdio);\n\nconst falseObjectWebTransformStderrResult = await execa('unicorns', {stderr: webTransformNotObject});\nexpectType<string>(falseObjectWebTransformStderrResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectWebTransformStderrResult.stdio);\n\nconst falseObjectDuplexStderrResult = await execa('unicorns', {stderr: duplexNotObject});\nexpectType<string>(falseObjectDuplexStderrResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectDuplexStderrResult.stdio);\n\nconst falseObjectDuplexPropertyStderrResult = await execa('unicorns', {stderr: duplexNotObjectProperty});\nexpectType<string>(falseObjectDuplexPropertyStderrResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectDuplexPropertyStderrResult.stdio);\n\nconst falseObjectTransformStderrResult = await execa('unicorns', {stderr: {transform: objectGenerator, final: objectFinal, objectMode: false} as const});\nexpectType<string>(falseObjectTransformStderrResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectTransformStderrResult.stdio);\n\nconst falseObjectWebTransformStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', webTransformNotObject]});\nexpectType<string>(falseObjectWebTransformStdioResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectWebTransformStdioResult.stdio);\n\nconst falseObjectDuplexStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', duplexNotObject]});\nexpectType<string>(falseObjectDuplexStdioResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectDuplexStdioResult.stdio);\n\nconst falseObjectDuplexPropertyStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', duplexNotObjectProperty]});\nexpectType<string>(falseObjectDuplexPropertyStdioResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectDuplexPropertyStdioResult.stdio);\n\nconst falseObjectTransformStdioResult = await execa('unicorns', {stdio: ['pipe', 'pipe', {transform: objectGenerator, final: objectFinal, objectMode: false} as const]});\nexpectType<string>(falseObjectTransformStdioResult.stderr);\nexpectType<[undefined, string, string]>(falseObjectTransformStdioResult.stdio);\n\nconst topObjectWebTransformStdoutResult = await execa('unicorns', {stdout: webTransformInstance});\nexpectType<string>(topObjectWebTransformStdoutResult.stdout);\nexpectType<[undefined, string, string]>(topObjectWebTransformStdoutResult.stdio);\n\nconst undefinedObjectWebTransformStdoutResult = await execa('unicorns', {stdout: webTransform});\nexpectType<string>(undefinedObjectWebTransformStdoutResult.stdout);\nexpectType<[undefined, string, string]>(undefinedObjectWebTransformStdoutResult.stdio);\n\nconst undefinedObjectDuplexStdoutResult = await execa('unicorns', {stdout: duplex});\nexpectType<string | unknown[]>(undefinedObjectDuplexStdoutResult.stdout);\nexpectType<[undefined, string | unknown[], string]>(undefinedObjectDuplexStdoutResult.stdio);\n\nconst undefinedObjectTransformStdoutResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal}});\nexpectType<string>(undefinedObjectTransformStdoutResult.stdout);\nexpectType<[undefined, string, string]>(undefinedObjectTransformStdoutResult.stdio);\n\nconst noObjectTransformStdoutResult = await execa('unicorns', {stdout: objectGenerator, final: objectFinal});\nexpectType<string>(noObjectTransformStdoutResult.stdout);\nexpectType<[undefined, string, string]>(noObjectTransformStdoutResult.stdio);\n\nconst trueTrueObjectTransformResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal, objectMode: true} as const, stderr: {transform: objectGenerator, final: objectFinal, objectMode: true} as const, all: true});\nexpectType<unknown[]>(trueTrueObjectTransformResult.stdout);\nexpectType<unknown[]>(trueTrueObjectTransformResult.stderr);\nexpectType<unknown[]>(trueTrueObjectTransformResult.all);\nexpectType<[undefined, unknown[], unknown[]]>(trueTrueObjectTransformResult.stdio);\n\nconst trueFalseObjectTransformResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal, objectMode: true} as const, stderr: {transform: objectGenerator, final: objectFinal, objectMode: false} as const, all: true});\nexpectType<unknown[]>(trueFalseObjectTransformResult.stdout);\nexpectType<string>(trueFalseObjectTransformResult.stderr);\nexpectType<unknown[]>(trueFalseObjectTransformResult.all);\nexpectType<[undefined, unknown[], string]>(trueFalseObjectTransformResult.stdio);\n\nconst falseTrueObjectTransformResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal, objectMode: false} as const, stderr: {transform: objectGenerator, final: objectFinal, objectMode: true} as const, all: true});\nexpectType<string>(falseTrueObjectTransformResult.stdout);\nexpectType<unknown[]>(falseTrueObjectTransformResult.stderr);\nexpectType<unknown[]>(falseTrueObjectTransformResult.all);\nexpectType<[undefined, string, unknown[]]>(falseTrueObjectTransformResult.stdio);\n\nconst falseFalseObjectTransformResult = await execa('unicorns', {stdout: {transform: objectGenerator, final: objectFinal, objectMode: false} as const, stderr: {transform: objectGenerator, final: objectFinal, objectMode: false} as const, all: true});\nexpectType<string>(falseFalseObjectTransformResult.stdout);\nexpectType<string>(falseFalseObjectTransformResult.stderr);\nexpectType<string>(falseFalseObjectTransformResult.all);\nexpectType<[undefined, string, string]>(falseFalseObjectTransformResult.stdio);\n\nconst objectTransformStdoutError = new Error('.') as ExecaError<{stdout: {transform: typeof objectGenerator; final: typeof objectFinal; readonly objectMode: true}}>;\nexpectType<unknown[]>(objectTransformStdoutError.stdout);\nexpectType<[undefined, unknown[], string]>(objectTransformStdoutError.stdio);\n\nconst objectTransformStderrError = new Error('.') as ExecaError<{stderr: {transform: typeof objectGenerator; final: typeof objectFinal; readonly objectMode: true}}>;\nexpectType<unknown[]>(objectTransformStderrError.stderr);\nexpectType<[undefined, string, unknown[]]>(objectTransformStderrError.stdio);\n\nconst objectTransformStdioError = new Error('.') as ExecaError<{stdio: ['pipe', 'pipe', {transform: typeof objectGenerator; final: typeof objectFinal; readonly objectMode: true}]}>;\nexpectType<unknown[]>(objectTransformStdioError.stderr);\nexpectType<[undefined, string, unknown[]]>(objectTransformStdioError.stdio);\n\nconst falseObjectTransformStdoutError = new Error('.') as ExecaError<{stdout: {transform: typeof objectGenerator; final: typeof objectFinal; readonly objectMode: false}}>;\nexpectType<string>(falseObjectTransformStdoutError.stdout);\nexpectType<[undefined, string, string]>(falseObjectTransformStdoutError.stdio);\n\nconst falseObjectTransformStderrError = new Error('.') as ExecaError<{stderr: {transform: typeof objectGenerator; final: typeof objectFinal; readonly objectMode: false}}>;\nexpectType<string>(falseObjectTransformStderrError.stderr);\nexpectType<[undefined, string, string]>(falseObjectTransformStderrError.stdio);\n\nconst falseObjectTransformStdioError = new Error('.') as ExecaError<{stdio: ['pipe', 'pipe', {transform: typeof objectGenerator; final: typeof objectFinal; readonly objectMode: false}]}>;\nexpectType<string>(falseObjectTransformStdioError.stderr);\nexpectType<[undefined, string, string]>(falseObjectTransformStdioError.stdio);\n"
  },
  {
    "path": "test-d/verbose.test-d.ts",
    "content": "import {\n\texpectType,\n\texpectNotType,\n\texpectAssignable,\n\texpectNotAssignable,\n\texpectError,\n} from 'tsd';\nimport {\n\texeca,\n\texecaSync,\n\ttype VerboseObject,\n\ttype SyncVerboseObject,\n\ttype Options,\n\ttype SyncOptions,\n\ttype Result,\n\ttype SyncResult,\n} from '../index.js';\n\nawait execa('unicorns', {verbose: 'none'});\nexecaSync('unicorns', {verbose: 'none'});\nawait execa('unicorns', {verbose: 'short'});\nexecaSync('unicorns', {verbose: 'short'});\nawait execa('unicorns', {verbose: 'full'});\nexecaSync('unicorns', {verbose: 'full'});\nexpectError(await execa('unicorns', {verbose: 'full' as string}));\nexpectError(execaSync('unicorns', {verbose: 'full' as string}));\nexpectError(await execa('unicorns', {verbose: 'other'}));\nexpectError(execaSync('unicorns', {verbose: 'other'}));\n\nconst voidVerbose = () => {\n\tconsole.log('');\n};\n\nawait execa('unicorns', {verbose: voidVerbose});\nexecaSync('unicorns', {verbose: voidVerbose});\nawait execa('unicorns', {verbose: () => ''});\nexecaSync('unicorns', {verbose: () => ''});\nawait execa('unicorns', {verbose: voidVerbose as () => never});\nexecaSync('unicorns', {verbose: voidVerbose as () => never});\nexpectError(await execa('unicorns', {verbose: () => true}));\nexpectError(execaSync('unicorns', {verbose: () => true}));\nexpectError(await execa('unicorns', {verbose: () => '' as unknown}));\nexpectError(execaSync('unicorns', {verbose: () => '' as unknown}));\n\nawait execa('unicorns', {verbose: (verboseLine: string) => ''});\nexecaSync('unicorns', {verbose: (verboseLine: string) => ''});\nawait execa('unicorns', {verbose: (verboseLine: unknown) => ''});\nexecaSync('unicorns', {verbose: (verboseLine: unknown) => ''});\nexpectError(await execa('unicorns', {verbose: (verboseLine: boolean) => ''}));\nexpectError(execaSync('unicorns', {verbose: (verboseLine: boolean) => ''}));\nexpectError(await execa('unicorns', {verbose: (verboseLine: never) => ''}));\nexpectError(execaSync('unicorns', {verbose: (verboseLine: never) => ''}));\n\nawait execa('unicorns', {verbose: (verboseLine: string, verboseObject: object) => ''});\nexecaSync('unicorns', {verbose: (verboseLine: string, verboseObject: object) => ''});\nawait execa('unicorns', {verbose: (verboseLine: string, verboseObject: VerboseObject) => ''});\nexecaSync('unicorns', {verbose: (verboseLine: string, verboseObject: VerboseObject) => ''});\nawait execa('unicorns', {verbose: (verboseLine: string, verboseObject: unknown) => ''});\nexecaSync('unicorns', {verbose: (verboseLine: string, verboseObject: unknown) => ''});\nexpectError(await execa('unicorns', {verbose: (verboseLine: string, verboseObject: string) => ''}));\nexpectError(execaSync('unicorns', {verbose: (verboseLine: string, verboseObject: string) => ''}));\nexpectError(await execa('unicorns', {verbose: (verboseLine: string, verboseObject: never) => ''}));\nexpectError(execaSync('unicorns', {verbose: (verboseLine: string, verboseObject: never) => ''}));\n\nexpectError(await execa('unicorns', {verbose: (verboseLine: string, verboseObject: object, other: string) => ''}));\nexpectError(execaSync('unicorns', {verbose: (verboseLine: string, verboseObject: object, other: string) => ''}));\n\nawait execa('unicorns', {\n\tverbose(verboseLine: string, verboseObject: VerboseObject) {\n\t\texpectNotType<string>(verboseObject.type);\n\t\texpectAssignable<string>(verboseObject.type);\n\t\texpectNotAssignable<boolean>(verboseObject.type);\n\t\texpectType<string>(verboseObject.message);\n\t\texpectType<string>(verboseObject.escapedCommand);\n\t\texpectType<string>(verboseObject.commandId);\n\t\texpectType<Date>(verboseObject.timestamp);\n\t\texpectType<Result | undefined>(verboseObject.result);\n\t\texpectType<boolean>(verboseObject.piped);\n\t\texpectType<Options>(verboseObject.options);\n\t\texpectError(verboseObject.other);\n\t},\n});\nexecaSync('unicorns', {\n\tverbose(verboseLine: string, verboseObject: SyncVerboseObject) {\n\t\texpectNotType<string>(verboseObject.type);\n\t\texpectAssignable<string>(verboseObject.type);\n\t\texpectNotAssignable<boolean>(verboseObject.type);\n\t\texpectType<string>(verboseObject.message);\n\t\texpectType<string>(verboseObject.escapedCommand);\n\t\texpectType<string>(verboseObject.commandId);\n\t\texpectType<Date>(verboseObject.timestamp);\n\t\texpectType<SyncResult | undefined>(verboseObject.result);\n\t\texpectType<boolean>(verboseObject.piped);\n\t\texpectType<SyncOptions>(verboseObject.options);\n\t\texpectError(verboseObject.other);\n\t},\n});\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n\t\"compilerOptions\": {\n\t\t\"module\": \"nodenext\",\n\t\t\"moduleResolution\": \"nodenext\",\n\t\t\"target\": \"ES2022\",\n\t\t\"strict\": true\n\t},\n\t\"files\": [\n\t\t\"index.d.ts\"\n\t]\n}\n"
  },
  {
    "path": "types/arguments/encoding-option.d.ts",
    "content": "type DefaultEncodingOption = 'utf8';\ntype TextEncodingOption =\n  | DefaultEncodingOption\n  | 'utf16le';\n\nexport type BufferEncodingOption = 'buffer';\nexport type BinaryEncodingOption =\n  | BufferEncodingOption\n  | 'hex'\n  | 'base64'\n  | 'base64url'\n  | 'latin1'\n  | 'ascii';\n\n// `options.encoding`\nexport type EncodingOption =\n\t| TextEncodingOption\n\t| BinaryEncodingOption\n\t| undefined;\n\nexport {};\n"
  },
  {
    "path": "types/arguments/fd-options.d.ts",
    "content": "type FileDescriptorOption = `fd${number}`;\n\n// `from` option of `subprocess.readable|duplex|iterable|pipe()`\n// Also used by fd-specific options\nexport type FromOption = 'stdout' | 'stderr' | 'all' | FileDescriptorOption;\n\n// `to` option of `subprocess.writable|duplex|pipe()`\nexport type ToOption = 'stdin' | FileDescriptorOption;\n\nexport {};\n"
  },
  {
    "path": "types/arguments/options.d.ts",
    "content": "import type {SignalConstants} from 'node:os';\nimport type {Readable} from 'node:stream';\nimport type {Unless} from '../utils.js';\nimport type {Message} from '../ipc.js';\nimport type {StdinOptionCommon, StdoutStderrOptionCommon, StdioOptionsProperty} from '../stdio/type.js';\nimport type {VerboseOption} from '../verbose.js';\nimport type {FdGenericOption} from './specific.js';\nimport type {EncodingOption} from './encoding-option.js';\n\nexport type CommonOptions<IsSync extends boolean = boolean> = {\n\t/**\n\tPrefer locally installed binaries when looking for a binary to execute.\n\n\t@default `true` with `$`, `false` otherwise\n\t*/\n\treadonly preferLocal?: boolean;\n\n\t/**\n\tPreferred path to find locally installed binaries, when using the `preferLocal` option.\n\n\t@default `cwd` option\n\t*/\n\treadonly localDir?: string | URL;\n\n\t/**\n\tIf `true`, runs with Node.js. The first argument must be a Node.js file.\n\n\tThe subprocess inherits the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) and version. This can be overridden using the `nodeOptions` and `nodePath` options.\n\n\t@default `true` with `execaNode()`, `false` otherwise\n\t*/\n\treadonly node?: boolean;\n\n\t/**\n\tList of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the Node.js executable.\n\n\tRequires the `node` option to be `true`.\n\n\t@default [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI flags)\n\t*/\n\treadonly nodeOptions?: readonly string[];\n\n\t/**\n\tPath to the Node.js executable.\n\n\tRequires the `node` option to be `true`.\n\n\t@default [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)\n\t*/\n\treadonly nodePath?: string | URL;\n\n\t/**\n\tIf `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).\n\n\tUses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/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.\n\n\tWe recommend against using this option.\n\n\t@default false\n\t*/\n\treadonly shell?: boolean | string | URL;\n\n\t/**\n\tCurrent [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.\n\n\tThis is also used to resolve the `nodePath` option when it is a relative path.\n\n\t@default process.cwd()\n\t*/\n\treadonly cwd?: string | URL;\n\n\t/**\n\t[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).\n\n\tUnless the `extendEnv` option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).\n\n\t@default [process.env](https://nodejs.org/api/process.html#processenv)\n\t*/\n\treadonly env?: Readonly<Partial<Record<string, string>>>;\n\n\t/**\n\tIf `true`, the subprocess uses both the `env` option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).\n\tIf `false`, only the `env` option is used, not `process.env`.\n\n\t@default true\n\t*/\n\treadonly extendEnv?: boolean;\n\n\t/**\n\tWrite some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).\n\n\tSee also the `inputFile` and `stdin` options.\n\t*/\n\treadonly input?: string | Uint8Array | Readable;\n\n\t/**\n\tUse a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).\n\n\tSee also the `input` and `stdin` options.\n\t*/\n\treadonly inputFile?: string | URL;\n\n\t/**\n\tHow to setup the subprocess' [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be `'pipe'`, `'overlapped'`, `'ignore`, `'inherit'`, a file descriptor integer, a Node.js `Readable` stream, a web `ReadableStream`, a `{ file: 'path' }` object, a file URL, an `Iterable`, an `AsyncIterable`, an `Uint8Array`, a generator function, a `Duplex` or a web `TransformStream`.\n\n\tThis can be an array of values such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.\n\n\t@default `'inherit'` with `$`, `'pipe'` otherwise\n\t*/\n\treadonly stdin?: StdinOptionCommon<IsSync>;\n\n\t/**\n\tHow to setup the subprocess' [standard output](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be `'pipe'`, `'overlapped'`, `'ignore`, `'inherit'`, a file descriptor integer, a Node.js `Writable` stream, a web `WritableStream`, a `{ file: 'path' }` object, a file URL, a generator function, a `Duplex` or a web `TransformStream`.\n\n\tThis can be an array of values such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.\n\n\t@default 'pipe'\n\t*/\n\treadonly stdout?: StdoutStderrOptionCommon<IsSync>;\n\n\t/**\n\tHow to setup the subprocess' [standard error](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be `'pipe'`, `'overlapped'`, `'ignore`, `'inherit'`, a file descriptor integer, a Node.js `Writable` stream, a web `WritableStream`, a `{ file: 'path' }` object, a file URL, a generator function, a `Duplex` or a web `TransformStream`.\n\n\tThis can be an array of values such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.\n\n\t@default 'pipe'\n\t*/\n\treadonly stderr?: StdoutStderrOptionCommon<IsSync>;\n\n\t/**\n\tLike the `stdin`, `stdout` and `stderr` options but for all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.\n\n\tA single string can be used as a shortcut.\n\n\tThe array can have more than 3 items, to create additional file descriptors beyond `stdin`/`stdout`/`stderr`.\n\n\t@default 'pipe'\n\t*/\n\treadonly stdio?: StdioOptionsProperty<IsSync>;\n\n\t/**\n\tAdd a `subprocess.all` stream and a `result.all` property. They contain the combined/interleaved output of the subprocess' `stdout` and `stderr`.\n\n\t@default false\n\t*/\n\treadonly all?: boolean;\n\n\t/**\n\tIf the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).\n\n\tIf it outputs binary data instead, this should be either:\n\t- `'buffer'`: returns the binary output as an `Uint8Array`.\n\t- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.\n\n\tThe output is available with `result.stdout`, `result.stderr` and `result.stdio`.\n\n\t@default 'utf8'\n\t*/\n\treadonly encoding?: EncodingOption;\n\n\t/**\n\tSet `result.stdout`, `result.stderr`, `result.all` and `result.stdio` as arrays of strings, splitting the subprocess' output into lines.\n\n\tThis cannot be used if the `encoding` option is binary.\n\n\tBy default, this applies to both `stdout` and `stderr`, but different values can also be passed.\n\n\t@default false\n\t*/\n\treadonly lines?: FdGenericOption<boolean>;\n\n\t/**\n\tStrip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.\n\n\tIf the `lines` option is true, this applies to each output line instead.\n\n\tBy default, this applies to both `stdout` and `stderr`, but different values can also be passed.\n\n\t@default true\n\t*/\n\treadonly stripFinalNewline?: FdGenericOption<boolean>;\n\n\t/**\n\tLargest amount of data allowed on `stdout`, `stderr` and `stdio`.\n\n\tBy default, this applies to both `stdout` and `stderr`, but different values can also be passed.\n\n\tWhen reached, `error.isMaxBuffer` becomes `true`.\n\n\t@default 100_000_000\n\t*/\n\treadonly maxBuffer?: FdGenericOption<number>;\n\n\t/**\n\tWhen `buffer` is `false`, the `result.stdout`, `result.stderr`, `result.all` and `result.stdio` properties are not set.\n\n\tBy default, this applies to both `stdout` and `stderr`, but different values can also be passed.\n\n\t@default true\n\t*/\n\treadonly buffer?: FdGenericOption<boolean>;\n\n\t/**\n\tEnables exchanging messages with the subprocess using `subprocess.sendMessage(message)`, `subprocess.getOneMessage()` and `subprocess.getEachMessage()`.\n\n\tThe subprocess must be a Node.js file.\n\n\t@default `true` if the `node`, `ipcInput` or `gracefulCancel` option is set, `false` otherwise\n\t*/\n\treadonly ipc?: Unless<IsSync, boolean>;\n\n\t/**\n\tSpecify the kind of serialization used for sending messages between subprocesses when using the `ipc` option.\n\n\t@default 'advanced'\n\t*/\n\treadonly serialization?: Unless<IsSync, 'json' | 'advanced'>;\n\n\t/**\n\tSends an IPC message when the subprocess starts.\n\n\tThe subprocess must be a Node.js file. The value's type depends on the `serialization` option.\n\t*/\n\treadonly ipcInput?: Unless<IsSync, Message>;\n\n\t/**\n\tIf `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.\n\n\tIf `verbose` is `'full'` or a function, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and IPC messages are also printed.\n\n\tA function can be passed to customize logging.\n\n\tBy default, this applies to both `stdout` and `stderr`, but different values can also be passed.\n\n\t@default 'none'\n\t*/\n\treadonly verbose?: VerboseOption;\n\n\t/**\n\tSetting this to `false` resolves the result's promise with the error instead of rejecting it.\n\n\t@default true\n\t*/\n\treadonly reject?: boolean;\n\n\t/**\n\tIf `timeout` is greater than `0`, the subprocess will be terminated if it runs for longer than that amount of milliseconds.\n\n\tOn timeout, `error.timedOut` becomes `true`.\n\n\t@default 0\n\t*/\n\treadonly timeout?: number;\n\n\t/**\n\tWhen the `cancelSignal` is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), terminate the subprocess using a `SIGTERM` signal.\n\n\tWhen aborted, `error.isCanceled` becomes `true`.\n\n\t@example\n\t```\n\timport {execaNode} from 'execa';\n\n\tconst controller = new AbortController();\n\tconst cancelSignal = controller.signal;\n\n\tsetTimeout(() => {\n\t\tcontroller.abort();\n\t}, 5000);\n\n\ttry {\n\t\tawait execaNode({cancelSignal})`build.js`;\n\t} catch (error) {\n\t\tif (error.isCanceled) {\n\t\t\tconsole.error('Canceled by cancelSignal.');\n\t\t}\n\n\t\tthrow error;\n\t}\n\t```\n\t*/\n\treadonly cancelSignal?: Unless<IsSync, AbortSignal>;\n\n\t/**\n\tWhen the `cancelSignal` option is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), do not send any `SIGTERM`. Instead, abort the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) returned by `getCancelSignal()`. The subprocess should use it to terminate gracefully.\n\n\tThe subprocess must be a Node.js file.\n\n\tWhen aborted, `error.isGracefullyCanceled` becomes `true`.\n\n\t@default false\n\t*/\n\treadonly gracefulCancel?: Unless<IsSync, boolean>;\n\n\t/**\n\tIf the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).\n\n\tWhen this happens, `error.isForcefullyTerminated` becomes `true`.\n\n\t@default 5000\n\t*/\n\treadonly forceKillAfterDelay?: Unless<IsSync, number | boolean>;\n\n\t/**\n\tDefault [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.\n\n\tThis can be either a name (like `'SIGTERM'`) or a number (like `9`).\n\n\t@default 'SIGTERM'\n\t*/\n\treadonly killSignal?: keyof SignalConstants | number;\n\n\t/**\n\tRun the subprocess independently from the current process.\n\n\t@default false\n\t*/\n\treadonly detached?: Unless<IsSync, boolean>;\n\n\t/**\n\tKill the subprocess when the current process exits.\n\n\t@default true\n\t*/\n\treadonly cleanup?: Unless<IsSync, boolean>;\n\n\t/**\n\tSets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.\n\n\t@default current user identifier\n\t*/\n\treadonly uid?: number;\n\n\t/**\n\tSets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.\n\n\t@default current group identifier\n\t*/\n\treadonly gid?: number;\n\n\t/**\n\tValue of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.\n\n\t@default file being executed\n\t*/\n\treadonly argv0?: string;\n\n\t/**\n\tOn Windows, do not create a new console window.\n\n\t@default true\n\t*/\n\treadonly windowsHide?: boolean;\n\n\t/**\n\tIf `false`, escapes the command arguments on Windows.\n\n\t@default `true` if the `shell` option is `true`, `false` otherwise\n\t*/\n\treadonly windowsVerbatimArguments?: boolean;\n};\n\n/**\nSubprocess options.\n\nSome options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), `ipc`, `fd3`, etc.\n\n@example\n\n```\n// Same value for stdout and stderr\nawait execa({verbose: 'full'})`npm run build`;\n\n// Different values for stdout and stderr\nawait execa({verbose: {stdout: 'none', stderr: 'full'}})`npm run build`;\n```\n*/\nexport type Options = CommonOptions<false>;\n\n/**\nSubprocess options, with synchronous methods.\n\nSome options are related to the subprocess output: `verbose`, `lines`, `stripFinalNewline`, `buffer`, `maxBuffer`. By default, those options apply to all file descriptors (`stdout`, `stderr`, etc.). A plain object can be passed instead to apply them to only `stdout`, `stderr`, `all` (both stdout and stderr), `ipc`, `fd3`, etc.\n\n@example\n\n```\n// Same value for stdout and stderr\nexecaSync({verbose: 'full'})`npm run build`;\n\n// Different values for stdout and stderr\nexecaSync({verbose: {stdout: 'none', stderr: 'full'}})`npm run build`;\n```\n*/\nexport type SyncOptions = CommonOptions<true>;\n\nexport type StricterOptions<\n\tWideOptions extends CommonOptions,\n\tStrictOptions extends CommonOptions,\n> = WideOptions extends StrictOptions ? WideOptions : StrictOptions;\n\nexport {};\n"
  },
  {
    "path": "types/arguments/specific.d.ts",
    "content": "import type {FromOption} from './fd-options.js';\n\n// Options which can be fd-specific like `{verbose: {stdout: 'none', stderr: 'full'}}`\nexport type FdGenericOption<OptionType> = OptionType | GenericOptionObject<OptionType>;\n\ntype GenericOptionObject<OptionType> = {\n\treadonly [FdName in GenericFromOption]?: OptionType\n};\n\ntype GenericFromOption = FromOption | 'ipc';\n\n// Retrieve fd-specific option's value\nexport type FdSpecificOption<\n\tGenericOption extends FdGenericOption<unknown>,\n\tFdNumber extends string,\n> = GenericOption extends GenericOptionObject<unknown>\n\t? FdSpecificObjectOption<GenericOption, FdNumber>\n\t: GenericOption;\n\ntype FdSpecificObjectOption<\n\tGenericOption extends GenericOptionObject<unknown>,\n\tFdNumber extends string,\n> = keyof GenericOption extends GenericFromOption\n\t? FdNumberToFromOption<FdNumber, keyof GenericOption> extends never\n\t\t? undefined\n\t\t: GenericOption[FdNumberToFromOption<FdNumber, keyof GenericOption>]\n\t: GenericOption;\n\ntype FdNumberToFromOption<\n\tFdNumber extends string,\n\tGenericOptionKeys extends GenericFromOption,\n> = FdNumber extends '1'\n\t? 'stdout' extends GenericOptionKeys\n\t\t? 'stdout'\n\t\t: 'fd1' extends GenericOptionKeys\n\t\t\t? 'fd1'\n\t\t\t: 'all' extends GenericOptionKeys\n\t\t\t\t? 'all'\n\t\t\t\t: never\n\t: FdNumber extends '2'\n\t\t? 'stderr' extends GenericOptionKeys\n\t\t\t? 'stderr'\n\t\t\t: 'fd2' extends GenericOptionKeys\n\t\t\t\t? 'fd2'\n\t\t\t\t: 'all' extends GenericOptionKeys\n\t\t\t\t\t? 'all'\n\t\t\t\t\t: never\n\t\t: `fd${FdNumber}` extends GenericOptionKeys\n\t\t\t? `fd${FdNumber}`\n\t\t\t: 'ipc' extends GenericOptionKeys\n\t\t\t\t? 'ipc'\n\t\t\t\t: never;\n\nexport {};\n"
  },
  {
    "path": "types/convert.d.ts",
    "content": "import type {BinaryEncodingOption} from './arguments/encoding-option.js';\nimport type {Options} from './arguments/options.js';\nimport type {FromOption, ToOption} from './arguments/fd-options.js';\n\n// `subprocess.readable|duplex|iterable()` options\nexport type ReadableOptions = {\n\t/**\n\tWhich stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n\t`\"all\"` reads both `stdout` and `stderr`. This requires the `all` option to be `true`.\n\n\t@default 'stdout'\n\t*/\n\treadonly from?: FromOption;\n\n\t/**\n\tIf `false`, iterates over lines. Each line is a string.\n\n\tIf `true`, iterates over arbitrary chunks of data. Each line is an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (with `subprocess.iterable()`) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (with `subprocess.readable()`/`subprocess.duplex()`).\n\n\tThis is always `true` when the `encoding` option is binary.\n\n\t@default `false` with `subprocess.iterable()`, `true` otherwise\n\t*/\n\treadonly binary?: boolean;\n\n\t/**\n\tIf both this option and the `binary` option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.\n\n\t@default `false` with `subprocess.iterable()`, `true` otherwise\n\t*/\n\treadonly preserveNewlines?: boolean;\n};\n\n// `subprocess.writable|duplex()` options\nexport type WritableOptions = {\n\t/**\n\tWhich stream to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n\t@default 'stdin'\n\t*/\n\treadonly to?: ToOption;\n};\n\n// `subprocess.duplex()` options\nexport type DuplexOptions = ReadableOptions & WritableOptions;\n\n// `subprocess.iterable()` return value\nexport type SubprocessAsyncIterable<\n\tBinaryOption extends boolean | undefined,\n\tEncodingOption extends Options['encoding'],\n> = AsyncIterableIterator<\nEncodingOption extends BinaryEncodingOption\n\t? Uint8Array\n\t: BinaryOption extends true\n\t\t? Uint8Array\n\t\t: string\n>;\n\nexport {};\n"
  },
  {
    "path": "types/ipc.d.ts",
    "content": "import type {Options} from './arguments/options.js';\n\n// Message when the `serialization` option is `'advanced'`\ntype AdvancedMessage =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| object;\n\n// Message when the `serialization` option is `'json'`\ntype JsonMessage =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| readonly JsonMessage[]\n\t| {readonly [key: string | number]: JsonMessage};\n\n/**\nType of messages exchanged between a process and its subprocess using `sendMessage()`, `getOneMessage()` and `getEachMessage()`.\n\nThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n*/\nexport type Message<\n\tSerialization extends Options['serialization'] = Options['serialization'],\n> = Serialization extends 'json' ? JsonMessage : AdvancedMessage;\n\n/**\nOptions to `sendMessage()` and `subprocess.sendMessage()`\n*/\ntype SendMessageOptions = {\n\t/**\n\tThrow when the other process is not receiving or listening to messages.\n\n\t@default false\n\t*/\n\treadonly strict?: boolean;\n};\n\n// IPC methods in subprocess\n/**\nSend a `message` to the parent process.\n\nThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n*/\nexport function sendMessage(message: Message, sendMessageOptions?: SendMessageOptions): Promise<void>;\n\n/**\nOptions to `getOneMessage()` and `subprocess.getOneMessage()`\n*/\ntype GetOneMessageOptions<\n\tSerialization extends Options['serialization'],\n> = {\n\t/**\n\tIgnore any `message` that returns `false`.\n\t*/\n\treadonly filter?: (message: Message<Serialization>) => boolean;\n\n\t/**\n\tKeep the subprocess alive while `getOneMessage()` is waiting.\n\n\t@default true\n\t*/\n\treadonly reference?: boolean;\n};\n\n/**\nReceive a single `message` from the parent process.\n\nThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n*/\nexport function getOneMessage(getOneMessageOptions?: GetOneMessageOptions<Options['serialization']>): Promise<Message>;\n\n/**\nOptions to `getEachMessage()` and `subprocess.getEachMessage()`\n*/\ntype GetEachMessageOptions = {\n\t/**\n\tKeep the subprocess alive while `getEachMessage()` is waiting.\n\n\t@default true\n\t*/\n\treadonly reference?: boolean;\n};\n\n/**\nIterate over each `message` from the parent process.\n\nThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n*/\nexport function getEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message>;\n\n/**\nRetrieves the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) shared by the `cancelSignal` option.\n\nThis can only be called inside a subprocess. This requires the `gracefulCancel` option to be `true`.\n*/\nexport function getCancelSignal(): Promise<AbortSignal>;\n\n// IPC methods in the subprocess\nexport type IpcMethods<\n\tIpcEnabled extends boolean,\n\tSerialization extends Options['serialization'],\n> = IpcEnabled extends true\n\t? {\n\t\t/**\n\t\tSend a `message` to the subprocess.\n\n\t\tThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n\t\t*/\n\t\tsendMessage(message: Message<Serialization>, sendMessageOptions?: SendMessageOptions): Promise<void>;\n\n\t\t/**\n\t\tReceive a single `message` from the subprocess.\n\n\t\tThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n\t\t*/\n\t\tgetOneMessage(getOneMessageOptions?: GetOneMessageOptions<Serialization>): Promise<Message<Serialization>>;\n\n\t\t/**\n\t\tIterate over each `message` from the subprocess.\n\n\t\tThis requires the `ipc` option to be `true`. The type of `message` depends on the `serialization` option.\n\t\t*/\n\t\tgetEachMessage(getEachMessageOptions?: GetEachMessageOptions): AsyncIterableIterator<Message<Serialization>>;\n\t}\n\t// Those methods only work if the `ipc` option is `true`.\n\t// At runtime, they are actually defined, in order to provide with a nice error message.\n\t// At type check time, they are typed as `undefined` to prevent calling them.\n\t: {\n\t\tsendMessage: undefined;\n\t\tgetOneMessage: undefined;\n\t\tgetEachMessage: undefined;\n\t};\n\n// Whether IPC is enabled, based on the `ipc`, `ipcInput` and `gracefulCancel` options\nexport type HasIpc<OptionsType extends Options> = HasIpcOption<\nOptionsType['ipc'],\n'ipcInput' extends keyof OptionsType ? OptionsType['ipcInput'] : undefined,\n'gracefulCancel' extends keyof OptionsType ? OptionsType['gracefulCancel'] : undefined\n>;\n\ntype HasIpcOption<\n\tIpcOption extends Options['ipc'],\n\tIpcInputOption extends Options['ipcInput'],\n\tGracefulCancelOption extends Options['gracefulCancel'],\n> = IpcOption extends true\n\t? true\n\t: IpcOption extends false\n\t\t? false\n\t\t: IpcInputOption extends undefined\n\t\t\t? GracefulCancelOption extends true\n\t\t\t\t? true\n\t\t\t\t: false\n\t\t\t: true;\n\nexport {};\n"
  },
  {
    "path": "types/methods/command.d.ts",
    "content": "import type {Options, SyncOptions} from '../arguments/options.js';\nimport type {SyncResult} from '../return/result.js';\nimport type {ResultPromise} from '../subprocess/subprocess.js';\nimport type {SimpleTemplateString} from './template.js';\n\n/**\nExecutes a command. `command` is a string that includes both the `file` and its `arguments`.\n\nWhen `command` is a template string, it includes both the `file` and its `arguments`.\n\n`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.\n\nThis is only intended for very specific cases, such as a REPL. This should be avoided otherwise.\n\n@param command - The program/script to execute and its arguments.\n@returns A `ResultPromise` that is both:\n- the subprocess.\n- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.\n@throws `ExecaError`\n\n@example\n```\nimport {execaCommand} from 'execa';\n\nfor await (const commandAndArguments of getReplLine()) {\n\tawait execaCommand(commandAndArguments);\n}\n```\n*/\nexport declare const execaCommand: ExecaCommandMethod<{}>;\n\ntype ExecaCommandMethod<OptionsType extends Options> =\n\t& ExecaCommandBind<OptionsType>\n\t& ExecaCommandTemplate<OptionsType>\n\t& ExecaCommandArray<OptionsType>;\n\n// `execaCommand(options)` binding\ntype ExecaCommandBind<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(options: NewOptionsType)\n\t=> ExecaCommandMethod<OptionsType & NewOptionsType>;\n\n// `execaCommand`command`` template syntax\ntype ExecaCommandTemplate<OptionsType extends Options> =\n\t(...templateString: SimpleTemplateString)\n\t=> ResultPromise<OptionsType>;\n\n// `execaCommand('command', {})` array syntax\ntype ExecaCommandArray<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(command: string, options?: NewOptionsType)\n\t=> ResultPromise<OptionsType & NewOptionsType>;\n\n/**\nSame as `execaCommand()` but synchronous.\n\nWhen `command` is a template string, it includes both the `file` and its `arguments`.\n\n`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.\n\nReturns a subprocess `result` or throws an `error`. The `subprocess` is not returned: its methods and properties are not available.\n\n@param command - The program/script to execute and its arguments.\n@returns `SyncResult`\n@throws `ExecaSyncError`\n\n@example\n```\nimport {execaCommandSync} from 'execa';\n\nfor (const commandAndArguments of getReplLine()) {\n\texecaCommandSync(commandAndArguments);\n}\n```\n*/\nexport declare const execaCommandSync: ExecaCommandSyncMethod<{}>;\n\ntype ExecaCommandSyncMethod<OptionsType extends SyncOptions> =\n\t& ExecaCommandSyncBind<OptionsType>\n\t& ExecaCommandSyncTemplate<OptionsType>\n\t& ExecaCommandSyncArray<OptionsType>;\n\n// `execaCommandSync(options)` binding\ntype ExecaCommandSyncBind<OptionsType extends SyncOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(options: NewOptionsType)\n\t=> ExecaCommandSyncMethod<OptionsType & NewOptionsType>;\n\n// `execaCommandSync`command`` template syntax\ntype ExecaCommandSyncTemplate<OptionsType extends SyncOptions> =\n\t(...templateString: SimpleTemplateString)\n\t=> SyncResult<OptionsType>;\n\n// `execaCommandSync('command', {})` array syntax\ntype ExecaCommandSyncArray<OptionsType extends SyncOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(command: string, options?: NewOptionsType)\n\t=> SyncResult<OptionsType & NewOptionsType>;\n\n/**\nSplit a `command` string into an array. For example, `'npm run build'` returns `['npm', 'run', 'build']` and `'argument otherArgument'` returns `['argument', 'otherArgument']`.\n\n@param command - The file to execute and/or its arguments.\n@returns fileOrArgument[]\n\n@example\n```\nimport {execa, parseCommandString} from 'execa';\n\nconst commandString = 'npm run task';\nconst commandArray = parseCommandString(commandString);\nawait execa`${commandArray}`;\n\nconst [file, ...commandArguments] = commandArray;\nawait execa(file, commandArguments);\n```\n*/\nexport function parseCommandString(command: string): string[];\n\nexport {};\n"
  },
  {
    "path": "types/methods/main-async.d.ts",
    "content": "import type {Options} from '../arguments/options.js';\nimport type {ResultPromise} from '../subprocess/subprocess.js';\nimport type {TemplateString} from './template.js';\n\n/**\nExecutes a command using `file ...arguments`.\n\nWhen `command` is a template string, it includes both the `file` and its `arguments`.\n\n`execa(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.\n\n@param file - The program/script to execute, as a string or file URL\n@param arguments - Arguments to pass to `file` on execution.\n@returns A `ResultPromise` that is both:\n- the subprocess.\n- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.\n@throws `ExecaError`\n\n@example <caption>Simple syntax</caption>\n\n```\nimport {execa} from 'execa';\n\nconst {stdout} = await execa`npm run build`;\n// Print command's output\nconsole.log(stdout);\n```\n\n@example <caption>Script</caption>\n\n```\nimport {$} from 'execa';\n\nconst {stdout: name} = await $`cat package.json`.pipe`grep name`;\nconsole.log(name);\n\nconst branch = await $`git branch --show-current`;\nawait $`dep deploy --branch=${branch}`;\n\nawait Promise.all([\n\t$`sleep 1`,\n\t$`sleep 2`,\n\t$`sleep 3`,\n]);\n\nconst directoryName = 'foo bar';\nawait $`mkdir /tmp/${directoryName}`;\n```\n\n@example <caption>Local binaries</caption>\n\n```\n$ npm install -D eslint\n```\n\n```\nawait execa({preferLocal: true})`eslint`;\n```\n\n@example <caption>Pipe multiple subprocesses</caption>\n\n```\nconst {stdout, pipedFrom} = await execa`npm run build`\n\t.pipe`sort`\n\t.pipe`head -n 2`;\n\n// Output of `npm run build | sort | head -n 2`\nconsole.log(stdout);\n// Output of `npm run build | sort`\nconsole.log(pipedFrom[0].stdout);\n// Output of `npm run build`\nconsole.log(pipedFrom[0].pipedFrom[0].stdout);\n```\n\n@example <caption>Interleaved output</caption>\n\n```\nconst {all} = await execa({all: true})`npm run build`;\n// stdout + stderr, interleaved\nconsole.log(all);\n```\n\n@example <caption>Programmatic + terminal output</caption>\n\n```\nconst {stdout} = await execa({stdout: ['pipe', 'inherit']})`npm run build`;\n// stdout is also printed to the terminal\nconsole.log(stdout);\n```\n\n@example <caption>Simple input</caption>\n\n```\nconst getInputString = () => { /* ... *\\/ };\nconst {stdout} = await execa({input: getInputString()})`sort`;\nconsole.log(stdout);\n```\n\n@example <caption>File input</caption>\n\n```\n// Similar to: npm run build < input.txt\nawait execa({stdin: {file: 'input.txt'}})`npm run build`;\n```\n\n@example <caption>File output</caption>\n\n```\n// Similar to: npm run build > output.txt\nawait execa({stdout: {file: 'output.txt'}})`npm run build`;\n```\n\n@example <caption>Split into text lines</caption>\n\n```\nconst {stdout} = await execa({lines: true})`npm run build`;\n// Print first 10 lines\nconsole.log(stdout.slice(0, 10).join('\\n'));\n```\n\n@example <caption>Iterate over text lines</caption>\n\n```\nfor await (const line of execa`npm run build`) {\n\tif (line.includes('WARN')) {\n\t\tconsole.warn(line);\n\t}\n}\n```\n\n@example <caption>Transform/filter output</caption>\n\n```\nlet count = 0;\n\n// Filter out secret lines, then prepend the line number\nconst transform = function * (line) {\n\tif (!line.includes('secret')) {\n\t\tyield `[${count++}] ${line}`;\n\t}\n};\n\nawait execa({stdout: transform})`npm run build`;\n```\n\n@example <caption>Web streams</caption>\n\n```\nconst response = await fetch('https://example.com');\nawait execa({stdin: response.body})`sort`;\n```\n\n@example <caption>Convert to Duplex stream</caption>\n\n```\nimport {execa} from 'execa';\nimport {pipeline} from 'node:stream/promises';\nimport {createReadStream, createWriteStream} from 'node:fs';\n\nawait pipeline(\n\tcreateReadStream('./input.txt'),\n\texeca`node ./transform.js`.duplex(),\n\tcreateWriteStream('./output.txt'),\n);\n```\n\n@example <caption>Exchange messages</caption>\n\n```\n// parent.js\nimport {execaNode} from 'execa';\n\nconst subprocess = execaNode`child.js`;\nawait subprocess.sendMessage('Hello from parent');\nconst message = await subprocess.getOneMessage();\nconsole.log(message); // 'Hello from child'\n```\n\n```\n// child.js\nimport {getOneMessage, sendMessage} from 'execa';\n\nconst message = await getOneMessage(); // 'Hello from parent'\nconst newMessage = message.replace('parent', 'child'); // 'Hello from child'\nawait sendMessage(newMessage);\n```\n\n@example <caption>Any input type</caption>\n\n```\n// main.js\nimport {execaNode} from 'execa';\n\nconst ipcInput = [\n\t{task: 'lint', ignore: /test\\.js/},\n\t{task: 'copy', files: new Set(['main.js', 'index.js']),\n}];\nawait execaNode({ipcInput})`build.js`;\n```\n\n```\n// build.js\nimport {getOneMessage} from 'execa';\n\nconst ipcInput = await getOneMessage();\n```\n\n@example <caption>Any output type</caption>\n\n```\n// main.js\nimport {execaNode} from 'execa';\n\nconst {ipcOutput} = await execaNode`build.js`;\nconsole.log(ipcOutput[0]); // {kind: 'start', timestamp: date}\nconsole.log(ipcOutput[1]); // {kind: 'stop', timestamp: date}\n```\n\n```\n// build.js\nimport {sendMessage} from 'execa';\n\nconst runBuild = () => { /* ... *\\/ };\n\nawait sendMessage({kind: 'start', timestamp: new Date()});\nawait runBuild();\nawait sendMessage({kind: 'stop', timestamp: new Date()});\n```\n\n@example <caption>Graceful termination</caption>\n\n```\n// main.js\nimport {execaNode} from 'execa';\n\nconst controller = new AbortController();\nsetTimeout(() => {\n\tcontroller.abort();\n}, 5000);\n\nawait execaNode({\n\tcancelSignal: controller.signal,\n\tgracefulCancel: true,\n})`build.js`;\n```\n\n```\n// build.js\nimport {getCancelSignal} from 'execa';\n\nconst cancelSignal = await getCancelSignal();\nconst url = 'https://example.com/build/info';\nconst response = await fetch(url, {signal: cancelSignal});\n```\n\n@example <caption>Detailed error</caption>\n\n```\nimport {execa, ExecaError} from 'execa';\n\ntry {\n\tawait execa`unknown command`;\n} catch (error) {\n\tif (error instanceof ExecaError) {\n\t\tconsole.log(error);\n\t}\n\t/*\n\tExecaError: Command failed with ENOENT: unknown command\n\tspawn unknown ENOENT\n\t\t\tat ...\n\t\t\tat ... {\n\t\tshortMessage: 'Command failed with ENOENT: unknown command\\nspawn unknown ENOENT',\n\t\toriginalMessage: 'spawn unknown ENOENT',\n\t\tcommand: 'unknown command',\n\t\tescapedCommand: 'unknown command',\n\t\tcwd: '/path/to/cwd',\n\t\tdurationMs: 28.217566,\n\t\tfailed: true,\n\t\ttimedOut: false,\n\t\tisCanceled: false,\n\t\tisTerminated: false,\n\t\tisMaxBuffer: false,\n\t\tcode: 'ENOENT',\n\t\tstdout: '',\n\t\tstderr: '',\n\t\tstdio: [undefined, '', ''],\n\t\tpipedFrom: []\n\t\t[cause]: Error: spawn unknown ENOENT\n\t\t\t\tat ...\n\t\t\t\tat ... {\n\t\t\terrno: -2,\n\t\t\tcode: 'ENOENT',\n\t\t\tsyscall: 'spawn unknown',\n\t\t\tpath: 'unknown',\n\t\t\tspawnargs: [ 'command' ]\n\t\t}\n\t}\n\t*\\/\n}\n```\n\n@example <caption>Verbose mode</caption>\n\n```\nawait execa`npm run build`;\nawait execa`npm run test`;\n```\n\n```\n$ NODE_DEBUG=execa node build.js\n[00:57:44.581] [0] $ npm run build\n[00:57:44.653] [0]   Building application...\n[00:57:44.653] [0]   Done building.\n[00:57:44.658] [0] ✔ (done in 78ms)\n[00:57:44.658] [1] $ npm run test\n[00:57:44.740] [1]   Running tests...\n[00:57:44.740] [1]   Error: the entrypoint is invalid.\n[00:57:44.747] [1] ✘ Command failed with exit code 1: npm run test\n[00:57:44.747] [1] ✘ (done in 89ms)\n```\n\n@example <caption>Custom logging</caption>\n\n```\nimport {execa as execa_} from 'execa';\nimport {createLogger, transports} from 'winston';\n\n// Log to a file using Winston\nconst transport = new transports.File({filename: 'logs.txt'});\nconst logger = createLogger({transports: [transport]});\nconst LOG_LEVELS = {\n\tcommand: 'info',\n\toutput: 'verbose',\n\tipc: 'verbose',\n\terror: 'error',\n\tduration: 'info',\n};\n\nconst execa = execa_({\n\tverbose(verboseLine, {message, ...verboseObject}) {\n\t\tconst level = LOG_LEVELS[verboseObject.type];\n\t\tlogger[level](message, verboseObject);\n\t},\n});\n\nawait execa`npm run build`;\nawait execa`npm run test`;\n```\n*/\nexport declare const execa: ExecaMethod<{}>;\n\n/**\n`execa()` method either exported by Execa, or bound using `execa(options)`.\n*/\nexport type ExecaMethod<OptionsType extends Options = Options> =\n\t& ExecaBind<OptionsType>\n\t& ExecaTemplate<OptionsType>\n\t& ExecaArrayLong<OptionsType>\n\t& ExecaArrayShort<OptionsType>;\n\n// `execa(options)` binding\ntype ExecaBind<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(options: NewOptionsType)\n\t=> ExecaMethod<OptionsType & NewOptionsType>;\n\n// `execa`command`` template syntax\ntype ExecaTemplate<OptionsType extends Options> =\n\t(...templateString: TemplateString)\n\t=> ResultPromise<OptionsType>;\n\n// `execa('file', ['argument'], {})` array syntax\ntype ExecaArrayLong<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(file: string | URL, arguments?: readonly string[], options?: NewOptionsType)\n\t=> ResultPromise<OptionsType & NewOptionsType>;\n\n// `execa('file', {})` array syntax\ntype ExecaArrayShort<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(file: string | URL, options?: NewOptionsType)\n\t=> ResultPromise<OptionsType & NewOptionsType>;\n\nexport {};\n"
  },
  {
    "path": "types/methods/main-sync.d.ts",
    "content": "import type {SyncOptions} from '../arguments/options.js';\nimport type {SyncResult} from '../return/result.js';\nimport type {TemplateString} from './template.js';\n\n/**\nSame as `execa()` but synchronous.\n\nReturns a subprocess `result` or throws an `error`. The `subprocess` is not returned: its methods and properties are not available.\n\nWhen `command` is a template string, it includes both the `file` and its `arguments`.\n\n`execaSync(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.\n\nThis method is discouraged as it holds the CPU and lacks multiple features.\n\n@param file - The program/script to execute, as a string or file URL\n@param arguments - Arguments to pass to `file` on execution.\n@returns `SyncResult`\n@throws `ExecaSyncError`\n\n@example\n\n```\nimport {execaSync} from 'execa';\n\nconst {stdout} = execaSync`npm run build`;\n// Print command's output\nconsole.log(stdout);\n```\n*/\nexport declare const execaSync: ExecaSyncMethod<{}>;\n\n// For the moment, we purposely do not export `ExecaSyncMethod` and `ExecaScriptSyncMethod`.\n// This is because synchronous invocation is discouraged.\nexport type ExecaSyncMethod<OptionsType extends SyncOptions = SyncOptions> =\n\t& ExecaSyncBind<OptionsType>\n\t& ExecaSyncTemplate<OptionsType>\n\t& ExecaSyncArrayLong<OptionsType>\n\t& ExecaSyncArrayShort<OptionsType>;\n\n// `execaSync(options)` binding\ntype ExecaSyncBind<OptionsType extends SyncOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(options: NewOptionsType)\n\t=> ExecaSyncMethod<OptionsType & NewOptionsType>;\n\n// `execaSync`command`` template syntax\ntype ExecaSyncTemplate<OptionsType extends SyncOptions> =\n\t(...templateString: TemplateString)\n\t=> SyncResult<OptionsType>;\n\n// `execaSync('file', ['argument'], {})` array syntax\ntype ExecaSyncArrayLong<OptionsType extends SyncOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(file: string | URL, arguments?: readonly string[], options?: NewOptionsType)\n\t=> SyncResult<OptionsType & NewOptionsType>;\n\n// `execaSync('file', {})` array syntax\ntype ExecaSyncArrayShort<OptionsType extends SyncOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(file: string | URL, options?: NewOptionsType)\n\t=> SyncResult<OptionsType & NewOptionsType>;\n\nexport {};\n"
  },
  {
    "path": "types/methods/node.d.ts",
    "content": "import type {Options} from '../arguments/options.js';\nimport type {ResultPromise} from '../subprocess/subprocess.js';\nimport type {TemplateString} from './template.js';\n\n/**\nSame as `execa()` but using the `node: true` option.\nExecutes a Node.js file using `node scriptPath ...arguments`.\n\nWhen `command` is a template string, it includes both the `file` and its `arguments`.\n\n`execaNode(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.\n\nThis is the preferred method when executing Node.js files.\n\n@param scriptPath - Node.js script to execute, as a string or file URL\n@param arguments - Arguments to pass to `scriptPath` on execution.\n@returns A `ResultPromise` that is both:\n- the subprocess.\n- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.\n@throws `ExecaError`\n\n@example\n```\nimport {execaNode, execa} from 'execa';\n\nawait execaNode`file.js argument`;\n// Is the same as:\nawait execa({node: true})`file.js argument`;\n// Or:\nawait execa`node file.js argument`;\n```\n*/\nexport declare const execaNode: ExecaNodeMethod<{}>;\n\n/**\n`execaNode()` method either exported by Execa, or bound using `execaNode(options)`.\n*/\nexport type ExecaNodeMethod<OptionsType extends Options = Options> =\n\t& ExecaNodeBind<OptionsType>\n\t& ExecaNodeTemplate<OptionsType>\n\t& ExecaNodeArrayLong<OptionsType>\n\t& ExecaNodeArrayShort<OptionsType>;\n\n// `execaNode(options)` binding\ntype ExecaNodeBind<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(options: NewOptionsType)\n\t=> ExecaNodeMethod<OptionsType & NewOptionsType>;\n\n// `execaNode`command`` template syntax\ntype ExecaNodeTemplate<OptionsType extends Options> =\n\t(...templateString: TemplateString)\n\t=> ResultPromise<OptionsType>;\n\n// `execaNode('script', ['argument'], {})` array syntax\ntype ExecaNodeArrayLong<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(scriptPath: string | URL, arguments?: readonly string[], options?: NewOptionsType)\n\t=> ResultPromise<OptionsType & NewOptionsType>;\n\n// `execaNode('script', {})` array syntax\ntype ExecaNodeArrayShort<OptionsType extends Options> =\n\t<NewOptionsType extends Options = {}>(scriptPath: string | URL, options?: NewOptionsType)\n\t=> ResultPromise<OptionsType & NewOptionsType>;\n\nexport {};\n"
  },
  {
    "path": "types/methods/script.d.ts",
    "content": "import type {\n\tCommonOptions,\n\tOptions,\n\tSyncOptions,\n\tStricterOptions,\n} from '../arguments/options.js';\nimport type {SyncResult} from '../return/result.js';\nimport type {ResultPromise} from '../subprocess/subprocess.js';\nimport type {TemplateString} from './template.js';\n\n/**\nSame as `execa()` but using script-friendly default options.\n\nWhen `command` is a template string, it includes both the `file` and its `arguments`.\n\n`$(options)` can be used to return a new instance of this method but with different default `options`. Consecutive calls are merged to previous ones.\n\nThis is the preferred method when executing multiple commands in a script file.\n\n@returns A `ResultPromise` that is both:\n- the subprocess.\n- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.\n@throws `ExecaError`\n\n@example <caption>Basic</caption>\n```\nimport {$} from 'execa';\n\nconst branch = await $`git branch --show-current`;\nawait $`dep deploy --branch=${branch}`;\n```\n\n@example <caption>Verbose mode</caption>\n```\n$ node build.js\nBuilding application...\nDone building.\nRunning tests...\nError: the entrypoint is invalid.\n\n$ NODE_DEBUG=execa node build.js\n[00:57:44.581] [0] $ npm run build\n[00:57:44.653] [0]   Building application...\n[00:57:44.653] [0]   Done building.\n[00:57:44.658] [0] ✔ (done in 78ms)\n[00:57:44.658] [1] $ npm run test\n[00:57:44.740] [1]   Running tests...\n[00:57:44.740] [1]   Error: the entrypoint is invalid.\n[00:57:44.747] [1] ✘ Command failed with exit code 1: npm run test\n[00:57:44.747] [1] ✘ (done in 89ms)\n```\n*/\nexport const $: ExecaScriptMethod<{}>;\n\n/**\n`$()` method either exported by Execa, or bound using `$(options)`.\n*/\nexport type ExecaScriptMethod<OptionsType extends CommonOptions = CommonOptions> =\n\t& ExecaScriptBind<OptionsType>\n\t& ExecaScriptTemplate<OptionsType>\n\t& ExecaScriptArrayLong<OptionsType>\n\t& ExecaScriptArrayShort<OptionsType>\n\t& {sync: ExecaScriptSyncMethod<OptionsType>}\n\t& {s: ExecaScriptSyncMethod<OptionsType>};\n\n// `$(options)` binding\ntype ExecaScriptBind<OptionsType extends CommonOptions> =\n\t<NewOptionsType extends CommonOptions = {}>(options: NewOptionsType)\n\t=> ExecaScriptMethod<OptionsType & NewOptionsType>;\n\n// `$`command`` template syntax\ntype ExecaScriptTemplate<OptionsType extends CommonOptions> =\n\t(...templateString: TemplateString)\n\t=> ResultPromise<StricterOptions<OptionsType, Options>>;\n\n// `$('file', ['arg'], {})` array syntax\ntype ExecaScriptArrayLong<OptionsType extends CommonOptions> =\n\t<NewOptionsType extends Options = {}>(file: string | URL, arguments?: readonly string[], options?: NewOptionsType)\n\t=> ResultPromise<StricterOptions<OptionsType & NewOptionsType, Options>>;\n\n// `$('file', {})` array syntax\ntype ExecaScriptArrayShort<OptionsType extends CommonOptions> =\n\t<NewOptionsType extends Options = {}>(file: string | URL, options?: NewOptionsType)\n\t=> ResultPromise<StricterOptions<OptionsType & NewOptionsType, Options>>;\n\n// We must intersect the overloaded methods with & instead of using a simple object as a workaround for a TypeScript bug\n// See https://github.com/microsoft/TypeScript/issues/58765\n/**\n`$.sync()` method either exported by Execa, or bound using `$.sync(options)`.\n*/\nexport type ExecaScriptSyncMethod<OptionsType extends CommonOptions = CommonOptions> =\n\t& ExecaScriptSyncBind<OptionsType>\n\t& ExecaScriptSyncTemplate<OptionsType>\n\t& ExecaScriptSyncArrayLong<OptionsType>\n\t& ExecaScriptSyncArrayShort<OptionsType>;\n\n// `$.sync(options)` binding\ntype ExecaScriptSyncBind<OptionsType extends CommonOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(options: NewOptionsType)\n\t=> ExecaScriptSyncMethod<OptionsType & NewOptionsType>;\n\n// $.sync`command` template syntax\ntype ExecaScriptSyncTemplate<OptionsType extends CommonOptions> =\n\t(...templateString: TemplateString)\n\t=> SyncResult<StricterOptions<OptionsType, SyncOptions>>;\n\n// `$.sync('file', ['arg'], {})` array syntax\ntype ExecaScriptSyncArrayLong<OptionsType extends CommonOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(file: string | URL, arguments?: readonly string[], options?: NewOptionsType)\n\t=> SyncResult<StricterOptions<OptionsType & NewOptionsType, SyncOptions>>;\n\n// `$.sync('file', {})` array syntax\ntype ExecaScriptSyncArrayShort<OptionsType extends CommonOptions> =\n\t<NewOptionsType extends SyncOptions = {}>(file: string | URL, options?: NewOptionsType)\n\t=> SyncResult<StricterOptions<OptionsType & NewOptionsType, SyncOptions>>;\n\nexport {};\n"
  },
  {
    "path": "types/methods/template.d.ts",
    "content": "import type {Result, SyncResult} from '../return/result.js';\n\ntype TemplateExpressionItem =\n\t| string\n\t| number\n\t| Result\n\t| SyncResult;\n\n/**\nValue allowed inside `${...}` when using the template string syntax.\n*/\nexport type TemplateExpression = TemplateExpressionItem | readonly TemplateExpressionItem[];\n\n// `...${...}...` template syntax\nexport type TemplateString = readonly [TemplateStringsArray, ...readonly TemplateExpression[]];\n\n// `...${...}...` template syntax, but only allowing a single argument, for `execaCommand()`\nexport type SimpleTemplateString = readonly [TemplateStringsArray, string?];\n\nexport {};\n"
  },
  {
    "path": "types/pipe.d.ts",
    "content": "import type {Options} from './arguments/options.js';\nimport type {Result} from './return/result.js';\nimport type {FromOption, ToOption} from './arguments/fd-options.js';\nimport type {ResultPromise} from './subprocess/subprocess.js';\nimport type {TemplateExpression} from './methods/template.js';\n\n// `subprocess.pipe()` options\ntype PipeOptions = {\n\t/**\n\tWhich stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\n\t`\"all\"` pipes both `stdout` and `stderr`. This requires the `all` option to be `true`.\n\t*/\n\treadonly from?: FromOption;\n\n\t/**\n\tWhich stream to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `\"fd3\"` can also be passed.\n\t*/\n\treadonly to?: ToOption;\n\n\t/**\n\tUnpipe the subprocess when the signal aborts.\n\t*/\n\treadonly unpipeSignal?: AbortSignal;\n};\n\n// `subprocess.pipe()`\nexport type PipableSubprocess = {\n\t/**\n\t[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' `stdout` to a second Execa subprocess' `stdin`. This resolves with that second subprocess' result. If either subprocess is rejected, this is rejected with that subprocess' error instead.\n\n\tThis follows the same syntax as `execa(file, arguments?, options?)` except both regular options and pipe-specific options can be specified.\n\t*/\n\tpipe<OptionsType extends Options & PipeOptions = {}>(\n\t\tfile: string | URL,\n\t\targuments?: readonly string[],\n\t\toptions?: OptionsType,\n\t): Promise<Result<OptionsType>> & PipableSubprocess;\n\tpipe<OptionsType extends Options & PipeOptions = {}>(\n\t\tfile: string | URL,\n\t\toptions?: OptionsType,\n\t): Promise<Result<OptionsType>> & PipableSubprocess;\n\n\t/**\n\tLike `subprocess.pipe(file, arguments?, options?)` but using a `command` template string instead. This follows the same syntax as `$`.\n\t*/\n\tpipe(templates: TemplateStringsArray, ...expressions: readonly TemplateExpression[]):\n\tPromise<Result<{}>> & PipableSubprocess;\n\tpipe<OptionsType extends Options & PipeOptions = {}>(options: OptionsType):\n\t(templates: TemplateStringsArray, ...expressions: readonly TemplateExpression[])\n\t=> Promise<Result<OptionsType>> & PipableSubprocess;\n\n\t/**\n\tLike `subprocess.pipe(file, arguments?, options?)` but using the return value of another `execa()` call instead.\n\t*/\n\tpipe<Destination extends ResultPromise>(destination: Destination, options?: PipeOptions):\n\tPromise<Awaited<Destination>> & PipableSubprocess;\n};\n\nexport {};\n"
  },
  {
    "path": "types/return/final-error.d.ts",
    "content": "import type {CommonOptions, Options, SyncOptions} from '../arguments/options.js';\nimport {CommonResult} from './result.js';\n\ndeclare abstract class CommonError<\n\tIsSync extends boolean,\n\tOptionsType extends CommonOptions,\n> extends CommonResult<IsSync, OptionsType> {\n\tmessage: CommonErrorProperty<IsSync, OptionsType, 'message'>;\n\tshortMessage: CommonErrorProperty<IsSync, OptionsType, 'shortMessage'>;\n\toriginalMessage: CommonErrorProperty<IsSync, OptionsType, 'originalMessage'>;\n\treadonly name: CommonErrorProperty<IsSync, OptionsType, 'name'>;\n\tstack: CommonErrorProperty<IsSync, OptionsType, 'stack'>;\n}\n\ntype CommonErrorProperty<\n\tIsSync extends boolean,\n\tOptionsType extends CommonOptions,\n\tPropertyName extends keyof CommonResult<IsSync, OptionsType>,\n> = NonNullable<CommonResult<IsSync, OptionsType>[PropertyName]>;\n\n// `result.*` defined only on failure, i.e. on `error.*`\nexport type ErrorProperties =\n  | 'name'\n  | 'message'\n  | 'stack'\n  | 'cause'\n  | 'shortMessage'\n  | 'originalMessage'\n  | 'code';\n\n/**\nResult of a subprocess failed execution.\n\nThis error is thrown as an exception. If the `reject` option is false, it is returned instead.\n\nThis has the same shape as successful results, with a few additional properties.\n*/\nexport class ExecaError<OptionsType extends Options = Options> extends CommonError<false, OptionsType> {\n\treadonly name: 'ExecaError';\n}\n\n/**\nResult of a subprocess failed execution.\n\nThis error is thrown as an exception. If the `reject` option is false, it is returned instead.\n\nThis has the same shape as successful results, with a few additional properties.\n*/\nexport class ExecaSyncError<OptionsType extends SyncOptions = SyncOptions> extends CommonError<true, OptionsType> {\n\treadonly name: 'ExecaSyncError';\n}\n\nexport {};\n"
  },
  {
    "path": "types/return/ignore.d.ts",
    "content": "import type {NoStreamStdioOption} from '../stdio/type.js';\nimport type {IsInputFd} from '../stdio/direction.js';\nimport type {FdStdioOption} from '../stdio/option.js';\nimport type {FdSpecificOption} from '../arguments/specific.js';\nimport type {CommonOptions} from '../arguments/options.js';\n\n// Whether `result.stdin|stdout|stderr|all|stdio[*]` is `undefined`\nexport type IgnoresResultOutput<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = FdSpecificOption<OptionsType['buffer'], FdNumber> extends false\n\t? true\n\t: IsInputFd<FdNumber, OptionsType> extends true\n\t\t? true\n\t\t: IgnoresSubprocessOutput<FdNumber, OptionsType>;\n\n// Whether `subprocess.stdout|stderr|all` is `undefined|null`\nexport type IgnoresSubprocessOutput<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = IgnoresOutput<FdNumber, FdStdioOption<FdNumber, OptionsType>>;\n\ntype IgnoresOutput<\n\tFdNumber extends string,\n\tStdioOptionType,\n> = StdioOptionType extends NoStreamStdioOption<FdNumber> ? true : false;\n\nexport {};\n"
  },
  {
    "path": "types/return/result-all.d.ts",
    "content": "import type {IsObjectFd} from '../transform/object-mode.js';\nimport type {CommonOptions} from '../arguments/options.js';\nimport type {FdSpecificOption} from '../arguments/specific.js';\nimport type {IgnoresResultOutput} from './ignore.js';\nimport type {ResultStdio} from './result-stdout.js';\n\n// `result.all`\nexport type ResultAll<OptionsType extends CommonOptions> =\n\tResultAllProperty<OptionsType['all'], OptionsType>;\n\ntype ResultAllProperty<\n\tAllOption extends CommonOptions['all'],\n\tOptionsType extends CommonOptions,\n> = AllOption extends true\n\t? ResultStdio<\n\tAllMainFd<OptionsType>,\n\tAllObjectFd<OptionsType>,\n\tAllLinesFd<OptionsType>,\n\tOptionsType\n\t>\n\t: undefined;\n\ntype AllMainFd<OptionsType extends CommonOptions> =\n\tIgnoresResultOutput<'1', OptionsType> extends true ? '2' : '1';\n\ntype AllObjectFd<OptionsType extends CommonOptions> =\n\tIsObjectFd<'1', OptionsType> extends true ? '1' : '2';\n\ntype AllLinesFd<OptionsType extends CommonOptions> =\n\tFdSpecificOption<OptionsType['lines'], '1'> extends true ? '1' : '2';\n\nexport {};\n"
  },
  {
    "path": "types/return/result-ipc.d.ts",
    "content": "import type {FdSpecificOption} from '../arguments/specific.js';\nimport type {CommonOptions, Options, StricterOptions} from '../arguments/options.js';\nimport type {Message, HasIpc} from '../ipc.js';\n\n// `result.ipcOutput`\n// This is empty unless the `ipc` option is `true`.\n// Also, this is empty if the `buffer` option is `false`.\nexport type ResultIpcOutput<\n\tIsSync,\n\tOptionsType extends CommonOptions,\n> = IsSync extends true\n\t? []\n\t: ResultIpcAsync<\n\tFdSpecificOption<OptionsType['buffer'], 'ipc'>,\n\tHasIpc<StricterOptions<OptionsType, Options>>,\n\tOptionsType['serialization']\n\t>;\n\ntype ResultIpcAsync<\n\tBufferOption extends boolean | undefined,\n\tIpcEnabled extends boolean,\n\tSerializationOption extends CommonOptions['serialization'],\n> = BufferOption extends false\n\t? []\n\t: IpcEnabled extends true\n\t\t? Array<Message<SerializationOption>>\n\t\t: [];\n\nexport {};\n"
  },
  {
    "path": "types/return/result-stdio.d.ts",
    "content": "import type {StdioOptionNormalizedArray} from '../stdio/array.js';\nimport type {CommonOptions} from '../arguments/options.js';\nimport type {ResultStdioNotAll} from './result-stdout.js';\n\n// `result.stdio`\nexport type ResultStdioArray<OptionsType extends CommonOptions> =\n\tMapResultStdio<StdioOptionNormalizedArray<OptionsType>, OptionsType>;\n\ntype MapResultStdio<\n\tStdioOptionsArrayType,\n\tOptionsType extends CommonOptions,\n> = {\n\t-readonly [FdNumber in keyof StdioOptionsArrayType]: ResultStdioNotAll<\n\tFdNumber extends string ? FdNumber : string,\n\tOptionsType\n\t>\n};\n\nexport {};\n"
  },
  {
    "path": "types/return/result-stdout.d.ts",
    "content": "import type {BufferEncodingOption, BinaryEncodingOption} from '../arguments/encoding-option.js';\nimport type {IsObjectFd} from '../transform/object-mode.js';\nimport type {FdSpecificOption} from '../arguments/specific.js';\nimport type {CommonOptions} from '../arguments/options.js';\nimport type {IgnoresResultOutput} from './ignore.js';\n\n// `result.stdout|stderr|stdio`\nexport type ResultStdioNotAll<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = ResultStdio<FdNumber, FdNumber, FdNumber, OptionsType>;\n\n// `result.stdout|stderr|stdio|all`\nexport type ResultStdio<\n\tMainFdNumber extends string,\n\tObjectFdNumber extends string,\n\tLinesFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = ResultStdioProperty<\nObjectFdNumber,\nLinesFdNumber,\nIgnoresResultOutput<MainFdNumber, OptionsType>,\nOptionsType\n>;\n\ntype ResultStdioProperty<\n\tObjectFdNumber extends string,\n\tLinesFdNumber extends string,\n\tStreamOutputIgnored,\n\tOptionsType extends CommonOptions,\n> = StreamOutputIgnored extends true\n\t? undefined\n\t: ResultStdioItem<\n\tIsObjectFd<ObjectFdNumber, OptionsType>,\n\tFdSpecificOption<OptionsType['lines'], LinesFdNumber>,\n\tOptionsType['encoding']\n\t>;\n\ntype ResultStdioItem<\n\tIsObjectResult,\n\tLinesOption extends boolean | undefined,\n\tEncoding extends CommonOptions['encoding'],\n> = IsObjectResult extends true ? unknown[]\n\t: Encoding extends BufferEncodingOption\n\t\t? Uint8Array\n\t\t: LinesOption extends true\n\t\t\t? Encoding extends BinaryEncodingOption\n\t\t\t\t? string\n\t\t\t\t: string[]\n\t\t\t: string;\n\nexport {};\n"
  },
  {
    "path": "types/return/result.d.ts",
    "content": "import type {SignalConstants} from 'node:os';\nimport type {Unless} from '../utils.js';\nimport type {CommonOptions, Options, SyncOptions} from '../arguments/options.js';\nimport type {ErrorProperties} from './final-error.js';\nimport type {ResultAll} from './result-all.js';\nimport type {ResultStdioArray} from './result-stdio.js';\nimport type {ResultStdioNotAll} from './result-stdout.js';\nimport type {ResultIpcOutput} from './result-ipc.js';\n\nexport declare abstract class CommonResult<\n\tIsSync extends boolean,\n\tOptionsType extends CommonOptions,\n> {\n\t/**\n\tThe output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).\n\n\tThis is `undefined` if the `stdout` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\n\tThis is an array if the `lines` option is `true`, or if the `stdout` option is a transform in object mode.\n\t*/\n\tstdout: ResultStdioNotAll<'1', OptionsType>;\n\n\t/**\n\tThe output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).\n\n\tThis is `undefined` if the `stderr` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\n\tThis is an array if the `lines` option is `true`, or if the `stderr` option is a transform in object mode.\n\t*/\n\tstderr: ResultStdioNotAll<'2', OptionsType>;\n\n\t/**\n\tThe output of the subprocess with `result.stdout` and `result.stderr` interleaved.\n\n\tThis requires the `all` option to be `true`.\n\n\tThis is `undefined` if both `stdout` and `stderr` options are set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\n\tThis is an array if the `lines` option is `true`, or if either the `stdout` or `stderr` option is a transform in object mode.\n\t*/\n\tall: ResultAll<OptionsType>;\n\n\t/**\n\tThe output of the subprocess on `stdin`, `stdout`, `stderr` and other file descriptors.\n\n\tItems are `undefined` when their corresponding `stdio` option is set to only `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\n\tItems are arrays when their corresponding `stdio` option is a transform in object mode.\n\t*/\n\tstdio: ResultStdioArray<OptionsType>;\n\n\t/**\n\tAll the messages sent by the subprocess to the current process.\n\n\tThis is empty unless the `ipc` option is `true`. Also, this is empty if the `buffer` option is `false`.\n\t*/\n\tipcOutput: ResultIpcOutput<IsSync, OptionsType>;\n\n\t/**\n\tResults of the other subprocesses that were piped into this subprocess.\n\n\tThis array is initially empty and is populated each time the `subprocess.pipe()` method resolves.\n\t*/\n\tpipedFrom: Unless<IsSync, Result[], []>;\n\n\t/**\n\tThe file and arguments that were run.\n\t*/\n\tcommand: string;\n\n\t/**\n\tSame as `command` but escaped.\n\t*/\n\tescapedCommand: string;\n\n\t/**\n\tThe current directory in which the command was run.\n\t*/\n\tcwd: string;\n\n\t/**\n\tDuration of the subprocess, in milliseconds.\n\t*/\n\tdurationMs: number;\n\n\t/**\n\tWhether the subprocess failed to run.\n\n\tWhen this is `true`, the result is an `ExecaError` instance with additional error-related properties.\n\t*/\n\tfailed: boolean;\n\n\t/**\n\tWhether the subprocess timed out due to the `timeout` option.\n\t*/\n\ttimedOut: boolean;\n\n\t/**\n\tWhether the subprocess was canceled using the `cancelSignal` option.\n\t*/\n\tisCanceled: boolean;\n\n\t/**\n\tWhether the subprocess was canceled using both the `cancelSignal` and the `gracefulCancel` options.\n\t*/\n\tisGracefullyCanceled: boolean;\n\n\t/**\n\tWhether the subprocess failed because its output was larger than the `maxBuffer` option.\n\t*/\n\tisMaxBuffer: boolean;\n\n\t/**\n\tWhether the subprocess was terminated by a signal (like `SIGTERM`) sent by either:\n\t- The current process.\n\t- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).\n\t*/\n\tisTerminated: boolean;\n\n\t/**\n\tWhether the subprocess was terminated by the `SIGKILL` signal sent by the `forceKillAfterDelay` option.\n\t*/\n\tisForcefullyTerminated: boolean;\n\n\t/**\n\tThe numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.\n\n\tThis is `undefined` when the subprocess could not be spawned or was terminated by a signal.\n\t*/\n\texitCode?: number;\n\n\t/**\n\tThe name of the signal (like `SIGTERM`) that terminated the subprocess, sent by either:\n\t- The current process.\n\t- Another process. This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).\n\n\tIf a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`.\n\t*/\n\tsignal?: keyof SignalConstants;\n\n\t/**\n\tA human-friendly description of the signal that was used to terminate the subprocess.\n\n\tIf a signal terminated the subprocess, 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.\n\t*/\n\tsignalDescription?: string;\n\n\t/**\n\tError message when the subprocess failed to run.\n\t*/\n\tmessage?: string;\n\n\t/**\n\tThis is the same as `error.message` except it does not include the subprocess output.\n\t*/\n\tshortMessage?: string;\n\n\t/**\n\tOriginal error message. This is the same as `error.message` excluding the subprocess output and some additional information added by Execa.\n\n\tThis exists only in specific instances, such as during a timeout.\n\t*/\n\toriginalMessage?: string;\n\n\t/**\n\tUnderlying error, if there is one. For example, this is set by `subprocess.kill(error)`.\n\n\tThis is usually an `Error` instance.\n\t*/\n\tcause?: unknown;\n\n\t/**\n\tNode.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.\n\t*/\n\tcode?: string;\n\n\t// We cannot `extend Error` because `message` must be optional. So we copy its types here.\n\treadonly name?: Error['name'];\n\tstack?: Error['stack'];\n}\n\nexport type SuccessResult<\n\tIsSync extends boolean = boolean,\n\tOptionsType extends CommonOptions = CommonOptions,\n> = InstanceType<typeof CommonResult<IsSync, OptionsType>> & OmitErrorIfReject<OptionsType['reject']>;\n\ntype OmitErrorIfReject<RejectOption extends CommonOptions['reject']> = {\n\t[ErrorProperty in ErrorProperties]: RejectOption extends false ? unknown : never\n};\n\n/**\nResult of a subprocess successful execution.\n\nWhen the subprocess fails, it is rejected with an `ExecaError` instead.\n*/\nexport type Result<OptionsType extends Options = Options> = SuccessResult<false, OptionsType>;\n\n/**\nResult of a subprocess successful execution.\n\nWhen the subprocess fails, it is rejected with an `ExecaError` instead.\n*/\nexport type SyncResult<OptionsType extends SyncOptions = SyncOptions> = SuccessResult<true, OptionsType>;\n\nexport {};\n"
  },
  {
    "path": "types/stdio/array.d.ts",
    "content": "import type {CommonOptions} from '../arguments/options.js';\nimport type {StdinOptionCommon, StdoutStderrOptionCommon, StdioOptionsArray} from './type.js';\n\n// `options.stdio`, normalized as an array\nexport type StdioOptionNormalizedArray<OptionsType extends CommonOptions> = StdioOptionNormalized<OptionsType['stdio']>;\n\ntype StdioOptionNormalized<StdioOption extends CommonOptions['stdio']> = StdioOption extends StdioOptionsArray\n\t? StdioOption\n\t: StdioOption extends StdinOptionCommon\n\t\t? StdioOption extends StdoutStderrOptionCommon\n\t\t\t? readonly [StdioOption, StdioOption, StdioOption]\n\t\t\t: DefaultStdioOption\n\t\t: DefaultStdioOption;\n\n// `options.stdio` default value\ntype DefaultStdioOption = readonly ['pipe', 'pipe', 'pipe'];\n\nexport {};\n"
  },
  {
    "path": "types/stdio/direction.d.ts",
    "content": "import type {CommonOptions} from '../arguments/options.js';\nimport type {Intersects} from '../utils.js';\nimport type {StdioSingleOptionItems, InputStdioOption} from './type.js';\nimport type {FdStdioArrayOption} from './option.js';\n\n// Whether `result.stdio[FdNumber]` is an input stream\nexport type IsInputFd<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = FdNumber extends '0'\n\t? true\n\t: Intersects<StdioSingleOptionItems<FdStdioArrayOption<FdNumber, OptionsType>>, InputStdioOption>;\n\nexport {};\n"
  },
  {
    "path": "types/stdio/option.d.ts",
    "content": "import type {CommonOptions} from '../arguments/options.js';\nimport type {StdioOptionNormalizedArray} from './array.js';\nimport type {StandardStreams, StdioOptionCommon, StdioOptionsArray} from './type.js';\n\n// `options.stdin|stdout|stderr|stdio` for a given file descriptor\nexport type FdStdioOption<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = FdStdioOptionProperty<FdNumber, OptionsType>;\n\ntype FdStdioOptionProperty<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = string extends FdNumber ? StdioOptionCommon\n\t: FdNumber extends keyof StandardStreams\n\t\t? StandardStreams[FdNumber] extends keyof OptionsType\n\t\t\t? OptionsType[StandardStreams[FdNumber]] extends undefined\n\t\t\t\t? FdStdioArrayOption<FdNumber, OptionsType>\n\t\t\t\t: OptionsType[StandardStreams[FdNumber]]\n\t\t\t: FdStdioArrayOption<FdNumber, OptionsType>\n\t\t: FdStdioArrayOption<FdNumber, OptionsType>;\n\n// `options.stdio[FdNumber]`, excluding `options.stdin|stdout|stderr`\nexport type FdStdioArrayOption<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = FdStdioArrayOptionProperty<FdNumber, StdioOptionNormalizedArray<OptionsType>>;\n\ntype FdStdioArrayOptionProperty<\n\tFdNumber extends string,\n\tStdioOptionsType,\n> = string extends FdNumber\n\t? StdioOptionCommon | undefined\n\t: StdioOptionsType extends StdioOptionsArray\n\t\t? FdNumber extends keyof StdioOptionsType\n\t\t\t? StdioOptionsType[FdNumber]\n\t\t\t: StdioOptionNormalizedArray<CommonOptions> extends StdioOptionsType\n\t\t\t\t? StdioOptionsType[number]\n\t\t\t\t: undefined\n\t\t: undefined;\n\nexport {};\n"
  },
  {
    "path": "types/stdio/type.d.ts",
    "content": "import type {Readable, Writable} from 'node:stream';\nimport type {ReadableStream, WritableStream, TransformStream} from 'node:stream/web';\nimport type {\n\tNot,\n\tAnd,\n\tOr,\n\tUnless,\n\tAndUnless,\n} from '../utils.js';\nimport type {\n\tGeneratorTransform,\n\tGeneratorTransformFull,\n\tDuplexTransform,\n\tWebTransform,\n} from '../transform/normalize.js';\n\ntype IsStandardStream<FdNumber extends string> = FdNumber extends keyof StandardStreams ? true : false;\n\nexport type StandardStreams = readonly ['stdin', 'stdout', 'stderr'];\n\n// When `options.stdin|stdout|stderr|stdio` is set to one of those values, no stream is created\nexport type NoStreamStdioOption<FdNumber extends string> =\n\t| 'ignore'\n\t| 'inherit'\n\t| 'ipc'\n\t| number\n\t| Readable\n\t| Writable\n\t| Unless<IsStandardStream<FdNumber>, undefined>\n\t| readonly [NoStreamStdioOption<FdNumber>];\n\n// `options.stdio` when it is not an array\ntype SimpleStdioOption<\n\tIsSync extends boolean,\n\tIsExtra extends boolean,\n\tIsArray extends boolean,\n> =\n\t| undefined\n\t| 'pipe'\n\t| Unless<And<And<Not<IsSync>, IsArray>, IsExtra>, 'inherit'>\n\t| Unless<IsArray, 'ignore'>\n\t| Unless<IsSync, 'overlapped'>;\n\n// Values available in both `options.stdin|stdio` and `options.stdout|stderr|stdio`\ntype CommonStdioOption<\n\tIsSync extends boolean,\n\tIsExtra extends boolean,\n\tIsArray extends boolean,\n> =\n\t| SimpleStdioOption<IsSync, IsExtra, IsArray>\n\t| URL\n\t| {readonly file: string; readonly append?: boolean}\n\t| GeneratorTransform<IsSync>\n\t| GeneratorTransformFull<IsSync>\n\t| Unless<And<Not<IsSync>, IsArray>, 3 | 4 | 5 | 6 | 7 | 8 | 9>\n\t| Unless<Or<IsSync, IsArray>, 'ipc'>\n\t| Unless<IsSync, DuplexTransform | WebTransform | TransformStream>;\n\n// Synchronous iterables excluding strings, Uint8Arrays and Arrays\ntype IterableObject<IsArray extends boolean> = Iterable<unknown>\n& object\n& {readonly BYTES_PER_ELEMENT?: never}\n& AndUnless<IsArray, {readonly lastIndexOf?: never}>;\n\n// `process.stdin|stdout|stderr` are `Duplex` with a `fd` property.\n// This ensures they can only be passed to `stdin`/`stdout`/`stderr`, based on their direction.\ntype ProcessStdinFd = {readonly fd?: 0};\ntype ProcessStdoutStderrFd = {readonly fd?: 1 | 2};\n\n// Values available only in `options.stdin|stdio`\nexport type InputStdioOption<\n\tIsSync extends boolean = boolean,\n\tIsExtra extends boolean = boolean,\n\tIsArray extends boolean = boolean,\n> =\n\t| 0\n\t| Unless<And<IsSync, IsExtra>, Uint8Array | IterableObject<IsArray>>\n\t| Unless<And<IsSync, IsArray>, Readable & ProcessStdinFd>\n\t| Unless<IsSync, (AsyncIterable<unknown> & ProcessStdinFd) | ReadableStream>;\n\n// Values available only in `options.stdout|stderr|stdio`\ntype OutputStdioOption<\n\tIsSync extends boolean,\n\tIsArray extends boolean,\n> =\n\t| 1\n\t| 2\n\t| Unless<And<IsSync, IsArray>, Writable & ProcessStdoutStderrFd>\n\t| Unless<IsSync, WritableStream>;\n\n// `options.stdin` array items\ntype StdinSingleOption<\n\tIsSync extends boolean,\n\tIsExtra extends boolean,\n\tIsArray extends boolean,\n> =\n\t| CommonStdioOption<IsSync, IsExtra, IsArray>\n\t| InputStdioOption<IsSync, IsExtra, IsArray>;\n\n// `options.stdin`\nexport type StdinOptionCommon<\n\tIsSync extends boolean = boolean,\n\tIsExtra extends boolean = boolean,\n> =\n\t| StdinSingleOption<IsSync, IsExtra, false>\n\t| ReadonlyArray<StdinSingleOption<IsSync, IsExtra, true>>;\n\n// `options.stdin`, async\nexport type StdinOption = StdinOptionCommon<false, false>;\n// `options.stdin`, sync\nexport type StdinSyncOption = StdinOptionCommon<true, false>;\n\n// `options.stdout|stderr` array items\ntype StdoutStderrSingleOption<\n\tIsSync extends boolean,\n\tIsExtra extends boolean,\n\tIsArray extends boolean,\n> =\n  | CommonStdioOption<IsSync, IsExtra, IsArray>\n  | OutputStdioOption<IsSync, IsArray>;\n\n// `options.stdout|stderr`\nexport type StdoutStderrOptionCommon<\n\tIsSync extends boolean = boolean,\n\tIsExtra extends boolean = boolean,\n> =\n\t| StdoutStderrSingleOption<IsSync, IsExtra, false>\n\t| ReadonlyArray<StdoutStderrSingleOption<IsSync, IsExtra, true>>;\n\n// `options.stdout|stderr`, async\nexport type StdoutStderrOption = StdoutStderrOptionCommon<false, false>;\n// `options.stdout|stderr`, sync\nexport type StdoutStderrSyncOption = StdoutStderrOptionCommon<true, false>;\n\n// `options.stdio[3+]`\ntype StdioExtraOptionCommon<IsSync extends boolean> =\n\t| StdinOptionCommon<IsSync, true>\n\t| StdoutStderrOptionCommon<IsSync, true>;\n\n// `options.stdin|stdout|stderr|stdio` array items\ntype StdioSingleOption<\n\tIsSync extends boolean = boolean,\n\tIsExtra extends boolean = boolean,\n\tIsArray extends boolean = boolean,\n> =\n\t| StdinSingleOption<IsSync, IsExtra, IsArray>\n\t| StdoutStderrSingleOption<IsSync, IsExtra, IsArray>;\n\n// Get `options.stdin|stdout|stderr|stdio` items if it is an array, else keep as is\nexport type StdioSingleOptionItems<StdioOptionType> = StdioOptionType extends readonly StdioSingleOption[]\n\t? StdioOptionType[number]\n\t: StdioOptionType;\n\n// `options.stdin|stdout|stderr|stdio`\nexport type StdioOptionCommon<IsSync extends boolean = boolean> =\n\t| StdinOptionCommon<IsSync>\n\t| StdoutStderrOptionCommon<IsSync>;\n\n// `options.stdio` when it is an array\nexport type StdioOptionsArray<IsSync extends boolean = boolean> = readonly [\n\tStdinOptionCommon<IsSync, false>,\n\tStdoutStderrOptionCommon<IsSync, false>,\n\tStdoutStderrOptionCommon<IsSync, false>,\n\t...ReadonlyArray<StdioExtraOptionCommon<IsSync>>,\n];\n\n// `options.stdio`\nexport type StdioOptionsProperty<IsSync extends boolean = boolean> =\n\t| SimpleStdioOption<IsSync, false, false>\n\t| StdioOptionsArray<IsSync>;\n\nexport {};\n"
  },
  {
    "path": "types/subprocess/all.d.ts",
    "content": "import type {Readable} from 'node:stream';\nimport type {IgnoresSubprocessOutput} from '../return/ignore.js';\nimport type {Options} from '../arguments/options.js';\n\n// `subprocess.all`\nexport type SubprocessAll<OptionsType extends Options> = AllStream<AllIgnored<OptionsType['all'], OptionsType>>;\n\ntype AllStream<IsIgnored> = IsIgnored extends true ? undefined : Readable;\n\ntype AllIgnored<\n\tAllOption,\n\tOptionsType extends Options,\n> = AllOption extends true\n\t? IgnoresSubprocessOutput<'1', OptionsType> extends true\n\t\t? IgnoresSubprocessOutput<'2', OptionsType>\n\t\t: false\n\t: true;\n\nexport {};\n"
  },
  {
    "path": "types/subprocess/stdio.d.ts",
    "content": "import type {StdioOptionNormalizedArray} from '../stdio/array.js';\nimport type {Options} from '../arguments/options.js';\nimport type {SubprocessStdioStream} from './stdout.js';\n\n// `subprocess.stdio`\nexport type SubprocessStdioArray<OptionsType extends Options> = MapStdioStreams<StdioOptionNormalizedArray<OptionsType>, OptionsType>;\n\n// We cannot use mapped types because it must be compatible with Node.js `ChildProcess[\"stdio\"]` which uses a tuple with exactly 5 items\ntype MapStdioStreams<\n\tStdioOptionsArrayType,\n\tOptionsType extends Options,\n> = [\n\tSubprocessStdioStream<'0', OptionsType>,\n\tSubprocessStdioStream<'1', OptionsType>,\n\tSubprocessStdioStream<'2', OptionsType>,\n\t'3' extends keyof StdioOptionsArrayType ? SubprocessStdioStream<'3', OptionsType> : never,\n\t'4' extends keyof StdioOptionsArrayType ? SubprocessStdioStream<'4', OptionsType> : never,\n];\n\nexport {};\n"
  },
  {
    "path": "types/subprocess/stdout.d.ts",
    "content": "import type {Readable, Writable} from 'node:stream';\nimport type {IsInputFd} from '../stdio/direction.js';\nimport type {IgnoresSubprocessOutput} from '../return/ignore.js';\nimport type {Options} from '../arguments/options.js';\n\n// `subprocess.stdin|stdout|stderr|stdio`\nexport type SubprocessStdioStream<\n\tFdNumber extends string,\n\tOptionsType extends Options,\n> = SubprocessStream<FdNumber, IgnoresSubprocessOutput<FdNumber, OptionsType>, OptionsType>;\n\ntype SubprocessStream<\n\tFdNumber extends string,\n\tStreamResultIgnored,\n\tOptionsType extends Options,\n> = StreamResultIgnored extends true\n\t? null\n\t: InputOutputStream<IsInputFd<FdNumber, OptionsType>>;\n\ntype InputOutputStream<IsInput extends boolean> = IsInput extends true\n\t? Writable\n\t: Readable;\n\nexport {};\n"
  },
  {
    "path": "types/subprocess/subprocess.d.ts",
    "content": "import type {ChildProcess} from 'node:child_process';\nimport type {SignalConstants} from 'node:os';\nimport type {Readable, Writable, Duplex} from 'node:stream';\nimport type {Options} from '../arguments/options.js';\nimport type {Result} from '../return/result.js';\nimport type {PipableSubprocess} from '../pipe.js';\nimport type {\n\tReadableOptions,\n\tWritableOptions,\n\tDuplexOptions,\n\tSubprocessAsyncIterable,\n} from '../convert.js';\nimport type {IpcMethods, HasIpc} from '../ipc.js';\nimport type {SubprocessStdioStream} from './stdout.js';\nimport type {SubprocessStdioArray} from './stdio.js';\nimport type {SubprocessAll} from './all.js';\n\ntype ExecaCustomSubprocess<OptionsType extends Options> = {\n\t/**\n\tProcess identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).\n\n\tThis is `undefined` if the subprocess failed to spawn.\n\t*/\n\tpid?: number;\n\n\t/**\n\tThe subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.\n\n\tThis is `null` if the `stdin` option is set to `'inherit'`, `'ignore'`, `Readable` or `integer`.\n\t*/\n\tstdin: SubprocessStdioStream<'0', OptionsType>;\n\n\t/**\n\tThe subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.\n\n\tThis is `null` if the `stdout` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\t*/\n\tstdout: SubprocessStdioStream<'1', OptionsType>;\n\n\t/**\n\tThe subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.\n\n\tThis is `null` if the `stderr` option is set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\t*/\n\tstderr: SubprocessStdioStream<'2', OptionsType>;\n\n\t/**\n\tStream combining/interleaving `subprocess.stdout` and `subprocess.stderr`.\n\n\tThis requires the `all` option to be `true`.\n\n\tThis is `undefined` if `stdout` and `stderr` options are set to `'inherit'`, `'ignore'`, `Writable` or `integer`, or if the `buffer` option is `false`.\n\t*/\n\tall: SubprocessAll<OptionsType>;\n\n\t/**\n\tThe subprocess `stdin`, `stdout`, `stderr` and other files descriptors as an array of streams.\n\n\tEach array item is `null` if the corresponding `stdin`, `stdout`, `stderr` or `stdio` option is set to `'inherit'`, `'ignore'`, `Stream` or `integer`, or if the `buffer` option is `false`.\n\t*/\n\tstdio: SubprocessStdioArray<OptionsType>;\n\n\t/**\n\tSends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the `killSignal` option. `killSignal` defaults to `SIGTERM`, which terminates the subprocess.\n\n\tThis returns `false` when the signal could not be sent, for example when the subprocess has already exited.\n\n\tWhen an error is passed as argument, it is set to the subprocess' `error.cause`. The subprocess is then terminated with the default signal. This does not emit the [`error` event](https://nodejs.org/api/child_process.html#event-error).\n\n\t[More info.](https://nodejs.org/api/child_process.html#subprocesskillsignal)\n\t*/\n\tkill(signal?: keyof SignalConstants | number, error?: Error): boolean;\n\tkill(error?: Error): boolean;\n\n\t/**\n\tSubprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.\n\t*/\n\t[Symbol.asyncIterator](): SubprocessAsyncIterable<undefined, OptionsType['encoding']>;\n\n\t/**\n\tSame as `subprocess[Symbol.asyncIterator]` except options can be provided.\n\t*/\n\titerable<IterableOptions extends ReadableOptions = {}>(readableOptions?: IterableOptions): SubprocessAsyncIterable<IterableOptions['binary'], OptionsType['encoding']>;\n\n\t/**\n\tConverts the subprocess to a readable stream.\n\t*/\n\treadable(readableOptions?: ReadableOptions): Readable;\n\n\t/**\n\tConverts the subprocess to a writable stream.\n\t*/\n\twritable(writableOptions?: WritableOptions): Writable;\n\n\t/**\n\tConverts the subprocess to a duplex stream.\n\t*/\n\tduplex(duplexOptions?: DuplexOptions): Duplex;\n}\n& IpcMethods<HasIpc<OptionsType>, OptionsType['serialization']>\n& PipableSubprocess;\n\n/**\n[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with additional methods and properties.\n*/\nexport type Subprocess<OptionsType extends Options = Options> =\n\t& Omit<ChildProcess, keyof ExecaCustomSubprocess<OptionsType>>\n\t& ExecaCustomSubprocess<OptionsType>;\n\n/**\nThe return value of all asynchronous methods is both:\n- the subprocess.\n- a `Promise` either resolving with its successful `result`, or rejecting with its `error`.\n*/\nexport type ResultPromise<OptionsType extends Options = Options> =\n\t& Subprocess<OptionsType>\n\t& Promise<Result<OptionsType>>;\n\nexport {};\n"
  },
  {
    "path": "types/transform/normalize.d.ts",
    "content": "import type {TransformStream} from 'node:stream/web';\nimport type {Duplex} from 'node:stream';\nimport type {Unless} from '../utils.js';\n\n// `options.std*: Generator`\n// @todo Use `string`, `Uint8Array` or `unknown` for both the argument and the return type, based on whether `encoding: 'buffer'` and `objectMode: true` are used.\n// See https://github.com/sindresorhus/execa/issues/694\nexport type GeneratorTransform<IsSync extends boolean> = (chunk: unknown) =>\n| Unless<IsSync, AsyncGenerator<unknown, void, void>>\n| Generator<unknown, void, void>;\ntype GeneratorFinal<IsSync extends boolean> = () =>\n| Unless<IsSync, AsyncGenerator<unknown, void, void>>\n| Generator<unknown, void, void>;\n\nexport type TransformCommon = {\n\t/**\n\tIf `true`, allow `transformOptions.transform` and `transformOptions.final` to return any type, not just `string` or `Uint8Array`.\n\t*/\n\treadonly objectMode?: boolean;\n};\n\n/**\nA transform or an array of transforms can be passed to the `stdin`, `stdout`, `stderr` or `stdio` option.\n\nA transform is either a generator function or a plain object with the following members.\n*/\nexport type GeneratorTransformFull<IsSync extends boolean> = {\n\t/**\n\tMap or filter the input or output of the subprocess.\n\t*/\n\treadonly transform: GeneratorTransform<IsSync>;\n\n\t/**\n\tCreate additional lines after the last one.\n\t*/\n\treadonly final?: GeneratorFinal<IsSync>;\n\n\t/**\n\tIf `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.\n\t*/\n\treadonly binary?: boolean;\n\n\t/**\n\tIf `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.\n\t*/\n\treadonly preserveNewlines?: boolean;\n} & TransformCommon;\n\n// `options.std*: Duplex`\nexport type DuplexTransform = {\n\treadonly transform: Duplex;\n} & TransformCommon;\n\n// `options.std*: TransformStream`\nexport type WebTransform = {\n\treadonly transform: TransformStream;\n} & TransformCommon;\n\nexport {};\n"
  },
  {
    "path": "types/transform/object-mode.d.ts",
    "content": "import type {StdioSingleOptionItems} from '../stdio/type.js';\nimport type {FdStdioOption} from '../stdio/option.js';\nimport type {CommonOptions} from '../arguments/options.js';\nimport type {DuplexTransform, TransformCommon} from './normalize.js';\n\n// Whether a file descriptor is in object mode\n// I.e. whether `result.stdout|stderr|stdio|all` is an array of `unknown` due to `objectMode: true`\nexport type IsObjectFd<\n\tFdNumber extends string,\n\tOptionsType extends CommonOptions,\n> = IsObjectStdioOption<FdStdioOption<FdNumber, OptionsType>>;\n\ntype IsObjectStdioOption<StdioOptionType> = IsObjectStdioSingleOption<StdioSingleOptionItems<StdioOptionType>>;\n\ntype IsObjectStdioSingleOption<StdioSingleOptionType> = StdioSingleOptionType extends TransformCommon\n\t? BooleanObjectMode<StdioSingleOptionType['objectMode']>\n\t: StdioSingleOptionType extends DuplexTransform\n\t\t? StdioSingleOptionType['transform']['readableObjectMode']\n\t\t: false;\n\ntype BooleanObjectMode<ObjectModeOption extends boolean | undefined> = ObjectModeOption extends true ? true : false;\n\nexport {};\n"
  },
  {
    "path": "types/utils.d.ts",
    "content": "export type Not<Value extends boolean> = Value extends true ? false : true;\n\nexport type And<First extends boolean, Second extends boolean> = First extends true ? Second : false;\n\nexport type Or<First extends boolean, Second extends boolean> = First extends true ? true : Second;\n\nexport type Unless<Condition extends boolean, ThenValue, ElseValue = never> = Condition extends true ? ElseValue : ThenValue;\n\nexport type AndUnless<Condition extends boolean, ThenValue, ElseValue = unknown> = Condition extends true ? ElseValue : ThenValue;\n\n// Whether any of T's union element is the same as one of U's union element.\n// `&` does not work here.\nexport type Intersects<T, U> = true extends (T extends U ? true : false) ? true : false;\n\nexport {};\n"
  },
  {
    "path": "types/verbose.d.ts",
    "content": "import type {FdGenericOption} from './arguments/specific.js';\nimport type {Options, SyncOptions} from './arguments/options.js';\nimport type {Result, SyncResult} from './return/result.js';\n\nexport type VerboseOption = FdGenericOption<\n| 'none'\n| 'short'\n| 'full'\n| VerboseFunction\n>;\n\ntype VerboseFunction = (verboseLine: string, verboseObject: MinimalVerboseObject) => string | void;\n\ntype GenericVerboseObject = {\n\t/**\n\tEvent type. This can be:\n\t- `'command'`: subprocess start\n\t- `'output'`: `stdout`/`stderr` output\n\t- `'ipc'`: IPC output\n\t- `'error'`: subprocess failure\n\t- `'duration'`: subprocess success or failure\n\t*/\n\ttype: 'command' | 'output' | 'ipc' | 'error' | 'duration';\n\n\t/**\n\tDepending on `verboseObject.type`, this is:\n\t- `'command'`: the `result.escapedCommand`\n\t- `'output'`: one line from `result.stdout` or `result.stderr`\n\t- `'ipc'`: one IPC message from `result.ipcOutput`\n\t- `'error'`: the `error.shortMessage`\n\t- `'duration'`: the `result.durationMs`\n\t*/\n\tmessage: string;\n\n\t/**\n\tThe file and arguments that were run. This is the same as `result.escapedCommand`.\n\t*/\n\tescapedCommand: string;\n\n\t/**\n\tSerial number identifying the subprocess within the current process. It is incremented from `'0'`.\n\n\tThis is helpful when multiple subprocesses are running at the same time.\n\n\tThis is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.\n\t*/\n\tcommandId: string;\n\n\t/**\n\tEvent date/time.\n\t*/\n\ttimestamp: Date;\n\n\t/**\n\tWhether another subprocess is piped into this subprocess. This is `false` when `result.pipedFrom` is empty.\n\t*/\n\tpiped: boolean;\n};\n\ntype MinimalVerboseObject = GenericVerboseObject & {\n\t// We cannot use the `CommonOptions` type because it would make this type recursive\n\toptions: object;\n\tresult?: never;\n};\n\n/**\nSubprocess event object, for logging purpose, using the `verbose` option and `execa()`.\n*/\nexport type VerboseObject = GenericVerboseObject & {\n\t/**\n\tThe options passed to the subprocess.\n\t*/\n\toptions: Options;\n\n\t/**\n\tSubprocess result.\n\n\tThis is `undefined` if `verboseObject.type` is `'command'`, `'output'` or `'ipc'`.\n\t*/\n\tresult?: Result;\n};\n\n/**\nSubprocess event object, for logging purpose, using the `verbose` option and `execaSync()`.\n*/\nexport type SyncVerboseObject = GenericVerboseObject & {\n\t/**\n\tThe options passed to the subprocess.\n\t*/\n\toptions: SyncOptions;\n\n\t/**\n\tSubprocess result.\n\n\tThis is `undefined` if `verboseObject.type` is `'command'`, `'output'` or `'ipc'`.\n\t*/\n\tresult?: SyncResult;\n};\n\nexport {};\n"
  }
]