mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 00:40:23 +00:00
fix(shell): prefer PowerShell 7 on Windows with tested fallbacks (#25684)
This commit is contained in:
@@ -2,7 +2,27 @@ import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
function resolvePowerShellPath(): string {
|
||||
export function resolvePowerShellPath(): string {
|
||||
// Prefer PowerShell 7 when available; PS 5.1 lacks "&&" support.
|
||||
const programFiles = process.env.ProgramFiles || process.env.PROGRAMFILES || "C:\\Program Files";
|
||||
const pwsh7 = path.join(programFiles, "PowerShell", "7", "pwsh.exe");
|
||||
if (fs.existsSync(pwsh7)) {
|
||||
return pwsh7;
|
||||
}
|
||||
|
||||
const programW6432 = process.env.ProgramW6432;
|
||||
if (programW6432 && programW6432 !== programFiles) {
|
||||
const pwsh7Alt = path.join(programW6432, "PowerShell", "7", "pwsh.exe");
|
||||
if (fs.existsSync(pwsh7Alt)) {
|
||||
return pwsh7Alt;
|
||||
}
|
||||
}
|
||||
|
||||
const pwshInPath = resolveShellFromPath("pwsh");
|
||||
if (pwshInPath) {
|
||||
return pwshInPath;
|
||||
}
|
||||
|
||||
const systemRoot = process.env.SystemRoot || process.env.WINDIR;
|
||||
if (systemRoot) {
|
||||
const candidate = path.join(
|
||||
|
||||
Reference in New Issue
Block a user