* Build Windows PATH by combining process.env.PATH with common install locations. * This ensures packaged apps on Windows can find user-installed tools.
()
| 24 | * This ensures packaged apps on Windows can find user-installed tools. |
| 25 | */ |
| 26 | function buildWindowsPath(): string { |
| 27 | const paths: string[] = []; |
| 28 | const pathSeparator = ";"; |
| 29 | |
| 30 | // Start with existing PATH from process.env |
| 31 | if (process.env.PATH) { |
| 32 | paths.push(...process.env.PATH.split(pathSeparator).filter(Boolean)); |
| 33 | } |
| 34 | |
| 35 | // Add Windows-specific common paths |
| 36 | const commonPaths = [ |
| 37 | // User-local installations (where tools like Claude CLI, git-lfs are often installed) |
| 38 | path.join(os.homedir(), ".local", "bin"), |
| 39 | // Git for Windows default location |
| 40 | "C:\\Program Files\\Git\\cmd", |
| 41 | "C:\\Program Files\\Git\\bin", |
| 42 | // System paths (usually already in PATH, but ensure they're present) |
| 43 | path.join(process.env.SystemRoot || "C:\\Windows", "System32"), |
| 44 | path.join(process.env.SystemRoot || "C:\\Windows"), |
| 45 | ]; |
| 46 | |
| 47 | // Add common paths that aren't already in PATH |
| 48 | for (const commonPath of commonPaths) { |
| 49 | const normalizedPath = path.normalize(commonPath); |
| 50 | // Case-insensitive check for Windows |
| 51 | const normalizedLower = normalizedPath.toLowerCase(); |
| 52 | const alreadyExists = paths.some( |
| 53 | (p) => path.normalize(p).toLowerCase() === normalizedLower, |
| 54 | ); |
| 55 | if (!alreadyExists) { |
| 56 | paths.push(normalizedPath); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | return paths.join(pathSeparator); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Gets the full shell environment with proper PATH for all platforms. |
no outgoing calls
no test coverage detected