( shimPath: string, nodeExecPath = process.execPath )
| 626 | const winRunnableExts = new Set([".exe", ".com", ".cmd", ".bat"]) |
| 627 | |
| 628 | export const unwrapWindowsCmdShim = ( |
| 629 | shimPath: string, |
| 630 | nodeExecPath = process.execPath |
| 631 | ): AgentCommand | undefined => { |
| 632 | let text: string |
| 633 | try { |
| 634 | text = readFileSync(shimPath, "utf8") |
| 635 | } catch { |
| 636 | return undefined |
| 637 | } |
| 638 | const dir = dirname(shimPath) |
| 639 | const resolveTarget = (raw: string) => |
| 640 | resolve(dir, ...raw.split(/[/\\]+/).filter(Boolean)) |
| 641 | for (const match of text.matchAll(winShimJsPattern)) { |
| 642 | const target = resolveTarget(match[1]) |
| 643 | if (statSync(target, { throwIfNoEntry: false })?.isFile()) |
| 644 | return { command: nodeExecPath, args: [target] } |
| 645 | } |
| 646 | for (const match of text.matchAll(winShimExePattern)) { |
| 647 | const target = resolveTarget(match[1]) |
| 648 | if (basename(target).toLowerCase() === "node.exe") continue |
| 649 | if (statSync(target, { throwIfNoEntry: false })?.isFile()) |
| 650 | return { command: target, args: [] } |
| 651 | } |
| 652 | return undefined |
| 653 | } |
| 654 | |
| 655 | export const resolveWindowsAgentCandidates = ( |
| 656 | cmd: string, |
no test coverage detected