fix(process): resolve Windows root-relative commands on the selected drive (#11763)

* fix(process): resolve Windows root-relative commands on the selected drive

* test(process): pin drive-less PATH entries and UNC root-relative commands

A Windows PATH entry rooted without a drive now counts as relative, so
programOnPath skips it. Pin that with a Windows case, test a
root-relative command under a UNC working directory, and say in the
relativeEntry and windowsPathCandidates docs that drive-less entries
count as relative.

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
RRFZandmorluto authored and GitHub committed 2026-11-18 10:23:14 -05:00
1 parent 23adfc610f
commit 5aa1fc5737
3 files changed
+68 -11

No files matched your search

+27
View File
@@ -142,6 +142,33 @@ describe("windowsPathCandidates", () => {
expect(paths("npm.cmd", environment, { cwd: "C:\\" })).toEqual([]);
});
it("uses the selected working drive for a root-relative command", () => {
expect(
paths("\\bin\\tool", { PATHEXT: ".EXE" }, { cwd: "Z:\\work" }),
).toEqual(["Z:\\bin\\tool.EXE"]);
// A UNC working directory roots it at the share, as Win32 does.
expect(
paths(
"\\bin\\tool",
{ PATHEXT: ".EXE" },
{ cwd: "\\\\server\\share\\work" },
),
).toEqual(["\\\\server\\share\\bin\\tool.EXE"]);
});
it("marks a PATH entry without a drive as relative to the working drive", () => {
const search = windowsPathCandidates(
"tool.exe",
{ PATH: "\\bin;D:\\tools" },
{ cwd: "Z:\\work" },
);
if (!search.ok) throw new Error(search.error.extension);
expect([...search.value]).toEqual([
{ path: "Z:\\bin\\tool.exe", relativeEntry: true },
{ path: "D:\\tools\\tool.exe", relativeEntry: false },
]);
});
it("tries every launcher name in an entry before the next entry", () => {
expect(
paths(