Skip to content

chore: replace which with spawnSync - #1165

Merged
aduh95 merged 1 commit into
nodejs:mainfrom
trivikr:replace-which
Aug 18, 2026
Merged

chore: replace which with spawnSync#1165
aduh95 merged 1 commit into
nodejs:mainfrom
trivikr:replace-which

Conversation

@trivikr

@trivikr trivikr commented Aug 18, 2026

Copy link
Copy Markdown
Member

Use Node.js' built-in child_process API to detect whether the GitHub CLI is available.
This removes the runtime dependency for "which".

Testing

when gh is installed

$> node
Welcome to Node.js v22.23.2.
Type ".help" for more information.
> require("which").sync('gh', { nothrow: true }) !== null
true
> require('node:child_process').spawnSync(
...   'gh', ['--version'], { stdio: 'ignore' }
... ).status === 0
true

when gh is not installed

$> node
Welcome to Node.js v22.23.2.
Type ".help" for more information.
> require("which").sync('gh', { nothrow: true }) !== null
false
> require('node:child_process').spawnSync(
...   'gh', ['--version'], { stdio: 'ignore' }
... ).status === 0
false

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.81%. Comparing base (c53f184) to head (24bf247).

Files with missing lines Patch % Lines
lib/utils.js 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1165      +/-   ##
==========================================
- Coverage   57.82%   57.81%   -0.02%     
==========================================
  Files          53       53              
  Lines       10395    10397       +2     
==========================================
  Hits         6011     6011              
- Misses       4384     4386       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Use Node.js' built-in child_process API to detect whether the GitHub CLI
is available. This removes the runtime dependency for "which".

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
@trivikr trivikr changed the title utils: replace which with spawnSync chore: replace which with spawnSync Aug 18, 2026
@aduh95
aduh95 merged commit 519972d into nodejs:main Aug 18, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants