Skip to content

fix(which)!: preserve explicitly supplied executable paths - #1289

Open
sergioperezcheco wants to merge 2 commits into
shelljs:mainfrom
sergioperezcheco:fix/which-preserve-explicit-path
Open

sergioperezcheco wants to merge 2 commits into
shelljs:mainfrom
sergioperezcheco:fix/which-preserve-explicit-path

Conversation

@sergioperezcheco

Copy link
Copy Markdown
Contributor

When which() is given an executable path containing /, preserve that path rather than converting it to an absolute path. This implements the behavior requested in #658, including -a, while leaving PATH lookup unchanged. Add explicit-path coverage and update the generated documentation.

This intentionally changes the documented always-absolute behavior for explicit relative paths; #658 is labeled breaking, so this should be released with the appropriate breaking-change version rather than backported as a patch. Absolute paths and PATH search retain their existing behavior.

Validated on macOS with Node 22: the new regressions fail against the original implementation and pass with this change; npm test including lint, coverage, Node-support checks, and independently exercised package/public API checks pass. Windows/Linux and the other supported Node versions were not run locally.

Fixes #658.

AI-assisted implementation and automated independent review; no human review is claimed.

Preserve lexical relative paths as requested in shelljs#658 and cover explicit paths without changing PATH lookup.

Assisted-by: Hermes Agent
Signed-off-by: sergioperezcheco <checo520@outlook.com>
@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.30%. Comparing base (beb2b1f) to head (3e6b945).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1289      +/-   ##
==========================================
+ Coverage   97.17%   97.30%   +0.13%     
==========================================
  Files          36       36              
  Lines        1523     1523              
==========================================
+ Hits         1480     1482       +2     
+ Misses         43       41       -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.

Assisted-by: Hermes Agent (gpt-6.1-sol)
Signed-off-by: sergioperezcheco <checo520@outlook.com>
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.

which() should not call path.resolve()

1 participant