fix(shared): preserve Windows shell PATH priority (#8748)
This commit is contained in:
1 parent
41adccc83e
commit
929f7e6479
2 files changed
+8
-6
No files matched your search
@@ -460,7 +460,7 @@ effectIt.layer(NodeServices.layer)("resolveSpawnCommand", (it) => {
|
||||
});
|
||||
|
||||
effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
|
||||
it.effect("returns the baseline no-profile PATH patch when node is already available", () =>
|
||||
it.effect("uses known CLI directories as a fallback without changing shell PATH priority", () =>
|
||||
Effect.gen(function* () {
|
||||
const readEnvironment = vi.fn(
|
||||
(_names: ReadonlyArray<string>, options?: { loadProfile?: boolean }) =>
|
||||
@@ -483,6 +483,8 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
|
||||
),
|
||||
).toEqual({
|
||||
PATH: [
|
||||
"C:\\Shell\\Bin",
|
||||
"C:\\Windows\\System32",
|
||||
"C:\\Users\\testuser\\AppData\\Roaming\\npm",
|
||||
"C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
|
||||
"C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
|
||||
@@ -490,8 +492,6 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
|
||||
"C:\\Users\\testuser\\.local\\bin",
|
||||
"C:\\Users\\testuser\\.bun\\bin",
|
||||
"C:\\Users\\testuser\\scoop\\shims",
|
||||
"C:\\Shell\\Bin",
|
||||
"C:\\Windows\\System32",
|
||||
].join(";"),
|
||||
});
|
||||
expect(readEnvironment).toHaveBeenCalledTimes(1);
|
||||
@@ -532,6 +532,7 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
|
||||
PATH: [
|
||||
"C:\\Profile\\Node",
|
||||
"C:\\Windows\\System32",
|
||||
"C:\\Shell\\Bin",
|
||||
"C:\\Users\\testuser\\AppData\\Roaming\\npm",
|
||||
"C:\\Users\\testuser\\AppData\\Local\\Programs\\nodejs",
|
||||
"C:\\Users\\testuser\\AppData\\Local\\Volta\\bin",
|
||||
@@ -539,7 +540,6 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
|
||||
"C:\\Users\\testuser\\.local\\bin",
|
||||
"C:\\Users\\testuser\\.bun\\bin",
|
||||
"C:\\Users\\testuser\\scoop\\shims",
|
||||
"C:\\Shell\\Bin",
|
||||
].join(";"),
|
||||
FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
|
||||
FNM_MULTISHELL_PATH: "C:\\Users\\testuser\\AppData\\Local\\fnm_multishells\\123",
|
||||
@@ -576,11 +576,11 @@ effectIt.layer(NodeServices.layer)("resolveWindowsEnvironment", (it) => {
|
||||
),
|
||||
).toEqual({
|
||||
PATH: [
|
||||
"C:\\Windows\\System32",
|
||||
"C:\\Users\\testuser\\AppData\\Roaming\\npm",
|
||||
"C:\\Users\\testuser\\.local\\bin",
|
||||
"C:\\Users\\testuser\\.bun\\bin",
|
||||
"C:\\Users\\testuser\\scoop\\shims",
|
||||
"C:\\Windows\\System32",
|
||||
].join(";"),
|
||||
FNM_DIR: "C:\\Users\\testuser\\AppData\\Roaming\\fnm",
|
||||
});
|
||||
|
||||
@@ -728,7 +728,9 @@ export const resolveWindowsEnvironment = Effect.fn("shell.resolveWindowsEnvironm
|
||||
}).PATH;
|
||||
const mergedPath = mergePathValues(shellPath, inheritedPath, "win32");
|
||||
const knownCliPath = resolveKnownWindowsCliDirs(env).join(WINDOWS_PATH_DELIMITER);
|
||||
const baselinePath = mergePathValues(knownCliPath, mergedPath, "win32");
|
||||
// Preserve the order a user's shell uses. These directories fill gaps when
|
||||
// desktop apps launch without the full interactive-shell PATH.
|
||||
const baselinePath = mergePathValues(mergedPath, knownCliPath, "win32");
|
||||
const baselinePatch: Partial<NodeJS.ProcessEnv> = baselinePath ? { PATH: baselinePath } : {};
|
||||
const baselineEnv = mergeWindowsEnv(env, baselinePatch);
|
||||
|
||||
|
||||
Reference in new issue
Block a user