Skip to content

fix: propagate subcommand exit code in CLI wrapper (#11293) - #15315

Open
SIDDARTHAREDDY8 wants to merge 1 commit into
stdlib-js:developfrom
SIDDARTHAREDDY8:oss-bhai-2026-09-17e
Open

SIDDARTHAREDDY8 wants to merge 1 commit into
stdlib-js:developfrom
SIDDARTHAREDDY8:oss-bhai-2026-09-17e

Conversation

@SIDDARTHAREDDY8

Copy link
Copy Markdown

Resolves #11293.

Description

What is the purpose of this pull request?

This pull request:

  • Fixes the root bin/cli wrapper so it propagates a subcommand's exit code instead of always exiting with code 0. The wrapper previously only listened for the spawned process 'error' event (which fires only when the process fails to start); a subcommand which ran but exited non-zero was therefore reported as success. The wrapper now also listens for 'exit' and sets process.exitCode accordingly (exit code 1 if the sub-process was terminated by a signal).

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Test evidence (wrapper run locally against a subcommand which exits with code 3):

  • Before fix: subcommand direct exit 3, wrapped exit 0 (bug reproduced).
  • After fix: subcommand direct exit 3, wrapped exit 3.
  • Unchanged behavior: --help exits 0, unrecognized command exits 1, succeeding subcommand exits 0 (verified before/after).
  • node --check bin/cli passes. The existing test/test.cli.js tests cover only --help/--version output paths, which are untouched by this change (they return before the spawn call).

Fixes #11293.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was authored with AI assistance (Claude): the AI researched the issue, reproduced the exit-code bug locally, generated the onExit handler fix and the local verification harness, and drafted this PR description. The change itself is minimal and was verified by running the actual bin/cli wrapper before and after the fix.


@SIDDARTHAREDDY8
SIDDARTHAREDDY8 requested a review from a team September 18, 2026 03:41
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. labels Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI wrapper swallows subcommand exit codes

2 participants