Skip to content

feat: let piping of rejected processes - #1296

Merged
antongolub merged 3 commits into
google:mainfrom
antongolub:feat-pipe-rejected
Jul 30, 2025
Merged

feat: let piping of rejected processes#1296
antongolub merged 3 commits into
google:mainfrom
antongolub:feat-pipe-rejected

Conversation

@antongolub

@antongolub antongolub commented Jul 30, 2025

Copy link
Copy Markdown
Collaborator
it('fulfilled piping', async () => {
  const p1 = $`echo foo && sleep 0.1 && echo bar`
  await p1
  const p2 = p1.pipe`cat`
  await p2

  assert.equal(p1.output.toString(), 'foo\nbar\n')
  assert.equal(p2.output.toString(), 'foo\nbar\n')
})

it('rejected piping', async () => {
  const p1 = $({ nothrow: true })`echo foo && exit 1`
  await p1
  const p2 = p1.pipe($({ nothrow: true })`cat`)
  await p2

  assert.equal(p1.output.toString(), 'foo\n')
  assert.equal(p1.output.ok, false)
  assert.equal(p1.output.exitCode, 1)

  assert.equal(p2.output.toString(), 'foo\n')
  assert.equal(p2.output.ok, false)
  assert.equal(p2.output.exitCode, 1)
})
  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub
antongolub requested a review from Copilot July 30, 2025 13:34

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 enables piping of rejected processes, allowing output to flow through pipes even when the source process fails. The implementation includes new error propagation mechanisms and comprehensive test coverage.

  • Adds support for piping from processes that have failed with non-zero exit codes
  • Introduces a new break method for controlled process termination with custom exit codes and signals
  • Updates pipe behavior to handle failed processes gracefully by propagating failure state

Reviewed Changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/core.ts Core implementation of rejected process piping with new break method and updated pipe logic
build/core.cjs Compiled JavaScript version reflecting the TypeScript changes
test/core.test.js Comprehensive test cases for both fulfilled and rejected process piping scenarios
test/log.test.ts Additional test for custom log handling
test/deps.test.js Test for empty dependencies handling with tmpdir import
src/vendor-core.ts Export of TSpawnResult type for type support
.size-limit.json Updated size limits to accommodate new functionality
Comments suppressed due to low confidence (1)

src/core.ts:384

  • [nitpick] The property name '_breakData' is ambiguous. Consider a more descriptive name like '_terminationData' or '_failureState' to better indicate its purpose.
  private _breakData?: Partial<

Comment thread test/core.test.js Outdated
Comment thread src/core.ts
Comment thread test/core.test.js Outdated
Comment thread test/core.test.js Outdated
Comment thread src/core.ts
@antongolub
antongolub merged commit 2a9e46f into google:main Jul 30, 2025
28 checks passed
@antongolub
antongolub deleted the feat-pipe-rejected branch July 30, 2025 13:52
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