| 27 | // under one of PATHEXT's runnable extensions. Only a .cmd or .bat needs the |
| 28 | // shell; an .exe or .com is found by the plain call below on its own. |
| 29 | function findWindowsShim() { |
| 30 | const runnable = ['.com', '.exe', '.bat', '.cmd']; |
| 31 | const exts = (process.env.PATHEXT || runnable.join(';')).toLowerCase().split(';').filter((e) => runnable.includes(e)); |
| 32 | for (const dir of (process.env.PATH || '').split(path.delimiter)) { |
| 33 | if (!dir) continue; |
| 34 | for (const ext of exts) { |
| 35 | const file = path.join(dir, `codegraph${ext}`); |
| 36 | if (existsSync(file)) return ext === '.bat' || ext === '.cmd' ? file : null; |
| 37 | } |
| 38 | } |
| 39 | return null; |
| 40 | } |
| 41 | |
| 42 | // One token of a command line for cmd.exe, which hands it on to node.exe |
| 43 | // through the shim's %*. Double quotes keep it one argument for the C runtime |