( argv: readonly string[] = process.argv, cwd: string = process.cwd(), execPath: string = process.execPath, isSea: boolean = detectSea(), )
| 181 | * must re-exec `process.execPath` itself. |
| 182 | */ |
| 183 | export function resolveDaemonProgram( |
| 184 | argv: readonly string[] = process.argv, |
| 185 | cwd: string = process.cwd(), |
| 186 | execPath: string = process.execPath, |
| 187 | isSea: boolean = detectSea(), |
| 188 | ): string { |
| 189 | // In a SEA binary `argv[1]` is not a script path, so resolving it against |
| 190 | // `cwd` would produce a bogus path (e.g. `<cwd>/kimi`) and crash the spawn |
| 191 | // with ENOENT. Always re-exec the binary itself. |
| 192 | if (isSea) return execPath; |
| 193 | const candidate = argv[1] === 'server' ? execPath : (argv[1] ?? execPath); |
| 194 | return isAbsolute(candidate) ? candidate : resolve(cwd, candidate); |
| 195 | } |
| 196 | |
| 197 | interface SpawnDaemonChildOptions { |
| 198 | host?: string; |
no test coverage detected