feat(server): pick free port if none specified (#1274)

This commit is contained in:
Marvin Hagemeister
2023-06-12 13:18:52 +02:00
committed by GitHub
parent 69f4fecf5a
commit 36d56a9878
10 changed files with 107 additions and 61 deletions
+6 -5
View File
@@ -15,16 +15,17 @@ export async function startFreshServer(options: Deno.CommandOptions) {
preventCancel: true,
});
let started = false;
let address = "";
for await (const line of lines) {
if (line.includes("Fresh ready")) {
started = true;
const match = line.match(/https?:\/\/localhost:\d+/g);
if (match) {
address = match[0];
break;
}
}
if (!started) {
if (!address) {
throw new Error("Server didn't start up");
}
return { serverProcess, lines };
return { serverProcess, lines, address };
}