fix(drivers): check a relative driver folder once in the Windows npm lookup
Issue for this PR
Closes #1832
Type of change
- Bug fix
What does this PR do?
On Windows, after a failed npm run, findOnWindowsPath checks whether cmd.exe could find npm: the current directory first, then each PATH entry. The current-directory entry was cwd itself, and each candidate was resolved against cwd again, so a relative driver folder (a relative ALTIMATE_DRIVER_DIR) was probed as <folder>\<folder>\npm.cmd. An npm in that folder was missed, and a real install failure was reported as "npm is not available". cwd is now resolved once and that folder is probed.
Claims:
- C1: With a relative cwd, the current-directory probe looks only in that folder, once per PATHEXT extension; a relative PATH entry is still read from it.
- C2: The default file probe answers false, without throwing, for a path under a file, a missing path, and a path inside a folder it may not read.
- C3: On Windows, a spawn error, a throwing spawn and a timeout settle as 127, 127 and 124 without looking npm up, even when the shell closes afterwards.
Residuals:
- R1: The Windows-only test of the default probe on real folders, and C2's unreadable-folder case on Windows, don't run in CI (no Windows runner for this package). They were run on Windows 11 by hand (below).
How did you verify your code works?
- Fail on main: the relative-cwd test fails without the fix.
- Real Windows 11: with the process in a folder holding
rel-drivers\npm.cmdand npm not on PATH, the lookup for npm from the relative folderrel-driverscomes back empty on main and finds its npm.cmd with this change. The test file there: every lookup and npm-runner test passes, including the Windows-only one; 3 POSIX-quoting tests fail there on main too. - Local (Linux): the 90 tests in
test/resolve-unit.test.tspass; typecheck clean.
Cost side effects
None.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
- I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"
š¤ Generated with Claude Code
https://claude.ai/code/session_01YNQjkagE4uMJQBGtuEq7oN
Summary by cubic
Fixes Windows npm lookup so a relative driver folder (a relative ALTIMATE_DRIVER_DIR) is probed correctly. Previously, after a failed npm run, findOnWindowsPath resolved the current directory against itself, so an npm in that folder was missed and a real install failure was reported as "npm is not available".
Adds tests for the relative-folder probe, the default file probe, and the Windows paths that skip looking up npm. Closes #1832.
Summary by CodeRabbit
- Bug Fixes
- Improved npm command discovery on Windows when using a relative working directory.
- Invalid or unusable PATH entries are skipped so valid npm locations can still be found.
- Windows launch failures now return a consistent error code, and timeouts retain their timeout result during process shutdown.