(input: {
readonly port: number;
readonly hostname: string;
readonly isDevMode: boolean;
readonly scriptPath: string | undefined;
readonly executablePath: string;
readonly allowedHosts?: ReadonlyArray<string>;
})
| 102 | // --------------------------------------------------------------------------- |
| 103 | |
| 104 | export const buildDaemonSpawnSpec = (input: { |
| 105 | readonly port: number; |
| 106 | readonly hostname: string; |
| 107 | readonly isDevMode: boolean; |
| 108 | readonly scriptPath: string | undefined; |
| 109 | readonly executablePath: string; |
| 110 | readonly allowedHosts?: ReadonlyArray<string>; |
| 111 | }): DaemonSpawnSpec => { |
| 112 | const daemonArgs = [ |
| 113 | "daemon", |
| 114 | "run", |
| 115 | "--port", |
| 116 | String(input.port), |
| 117 | "--hostname", |
| 118 | input.hostname, |
| 119 | "--foreground", |
| 120 | ...(input.allowedHosts ?? []).flatMap((h) => ["--allowed-host", h]), |
| 121 | ]; |
| 122 | |
| 123 | if (input.isDevMode) { |
| 124 | if (!input.scriptPath) { |
| 125 | throw new Error("Cannot auto-start daemon in dev mode without a CLI script path"); |
| 126 | } |
| 127 | return { |
| 128 | command: "bun", |
| 129 | args: ["run", input.scriptPath, ...daemonArgs], |
| 130 | }; |
| 131 | } |
| 132 | |
| 133 | return { |
| 134 | command: input.executablePath, |
| 135 | args: daemonArgs, |
| 136 | }; |
| 137 | }; |
| 138 | |
| 139 | // --------------------------------------------------------------------------- |
| 140 | // Spawn + wait |
no outgoing calls
no test coverage detected