( argv: readonly string[] = process.argv, cwd: string = process.cwd(), execPath: string = process.execPath, isSea: boolean = detectSea(), )
| 30 | } |
| 31 | |
| 32 | export function resolveSupervisorProgram( |
| 33 | argv: readonly string[] = process.argv, |
| 34 | cwd: string = process.cwd(), |
| 35 | execPath: string = process.execPath, |
| 36 | isSea: boolean = detectSea(), |
| 37 | ): string { |
| 38 | // In a SEA binary `argv[1]` is the invoked command name (e.g. `kimi`) or the |
| 39 | // first user argument — never a script path — so the re-exec target is always |
| 40 | // the binary itself. Resolving it against `cwd` would produce a bogus path |
| 41 | // (e.g. `<cwd>/kimi`) and crash the spawn with ENOENT. |
| 42 | if (isSea) return execPath; |
| 43 | const candidate = argv[1] === 'server' ? execPath : (argv[1] ?? execPath); |
| 44 | return isAbsolute(candidate) ? candidate : resolve(cwd, candidate); |
| 45 | } |
no test coverage detected