Fix worktree setup scripts losing PATH (#1908)
* fix(worktree): preserve PATH for lifecycle scripts Lifecycle command strings were running through login shells, which could rewrite PATH before setup commands saw the daemon environment. Use the shared stable script-shell helper without login startup files, and route related project-authored command strings through it. * fix(worktree): ignore Bash startup env hook Project command strings should not source shell startup hooks before they see Paseo's supplied environment. Strip BASH_ENV from lifecycle, loop verify, and ACP string-command shells and pin the behavior in setup tests. * fix(worktree): resolve Bash through PATH * fix(worktree): preserve Windows cmd command strings * test(acp): expect Windows cmd terminal strings
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
export interface BuildStringCommandShellInvocationOptions {
|
||||
command: string;
|
||||
platform?: NodeJS.Platform;
|
||||
windowsShell?: "powershell" | "cmd";
|
||||
}
|
||||
|
||||
export interface StringCommandShellInvocation {
|
||||
@@ -8,12 +9,31 @@ export interface StringCommandShellInvocation {
|
||||
args: string[];
|
||||
}
|
||||
|
||||
export function createStringCommandShellEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
||||
const sanitized = { ...env };
|
||||
delete sanitized.BASH_ENV;
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
export function createStringCommandShellEnvOverlay(): Record<string, string | undefined> {
|
||||
return { BASH_ENV: undefined };
|
||||
}
|
||||
|
||||
export function buildStringCommandShellInvocation(
|
||||
options: BuildStringCommandShellInvocationOptions,
|
||||
): StringCommandShellInvocation {
|
||||
const platform = options.platform ?? process.platform;
|
||||
|
||||
// Project-authored command strings use a stable script shell. The caller supplies
|
||||
// the environment; shell startup files should not rewrite it behind our back.
|
||||
if (platform === "win32") {
|
||||
if (options.windowsShell === "cmd") {
|
||||
return {
|
||||
shell: "cmd.exe",
|
||||
args: ["/c", options.command],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
shell: "powershell",
|
||||
args: [
|
||||
@@ -28,7 +48,7 @@ export function buildStringCommandShellInvocation(
|
||||
}
|
||||
|
||||
return {
|
||||
shell: "/bin/bash",
|
||||
args: ["-lc", options.command],
|
||||
shell: "bash",
|
||||
args: ["-c", options.command],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user