Skip to content

feat: accept array as stdio() arg#1311

Merged
antongolub merged 1 commit into
google:mainfrom
antongolub:accept-stdio-arr
Aug 7, 2025
Merged

feat: accept array as stdio() arg#1311
antongolub merged 1 commit into
google:mainfrom
antongolub:accept-stdio-arr

Conversation

@antongolub

Copy link
Copy Markdown
Collaborator
  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub antongolub requested a review from Copilot August 7, 2025 16:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for accepting an array as the first argument to the stdio() method, allowing users to pass the complete stdio configuration in a single array parameter instead of requiring separate arguments for stdin, stdout, and stderr.

  • Modified the stdio() method signature to accept either individual parameters or an array
  • Updated related type imports and removed unused type exports
  • Refactored some internal variable names and logic optimizations

Reviewed Changes

Copilot reviewed 5 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/core.ts Enhanced stdio() method to accept array parameter and minor refactoring
src/util.ts Updated type import from TSpawnStoreChunks to TSpawnStore
src/vendor-core.ts Removed unused type exports
test/core.test.js Added test case for array-based stdio() usage and reorganized existing tests
build/core.cjs Compiled JavaScript output reflecting the TypeScript changes

Comment thread src/core.ts
const $ = self._snapshot
const id = self.id
const cwd = $.cwd ?? $[CWD]
const cwd = $.cwd || $[CWD]

Copilot AI Aug 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change from nullish coalescing operator (??) to logical OR (||) may introduce unintended behavior. The || operator will use the fallback for falsy values like empty strings, while ?? only checks for null/undefined. If $.cwd could legitimately be an empty string, this change could break that functionality.

Suggested change
const cwd = $.cwd || $[CWD]
const cwd = $.cwd ?? $[CWD]

Copilot uses AI. Check for mistakes.
Comment thread src/core.ts
@@ -433,8 +432,14 @@ export class ProcessPromise extends Promise<ProcessOutput> {
}

// Configurators

Copilot AI Aug 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modified stdio() method signature lacks documentation explaining the new array parameter option. Consider adding JSDoc comments to clarify that the first parameter can be either an IOType for stdin or a complete StdioOptions array.

Suggested change
// Configurators
// Configurators
/**
* Sets the stdio configuration for the process.
*
* The first parameter can be either:
* - An IOType value for stdin (e.g. 'pipe', 'inherit', etc.), in which case
* stdout and stderr can also be specified as IOType values.
* - A complete StdioOptions array, which will be used directly.
*
* @param stdin - IOType for stdin, or a StdioOptions array for all stdio streams.
* @param stdout - IOType for stdout (ignored if stdin is an array).
* @param stderr - IOType for stderr (ignored if stdin is an array).
* @returns this
*/

Copilot uses AI. Check for mistakes.
@antongolub antongolub merged commit ce05968 into google:main Aug 7, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants