MCPcopy Create free account
hub / github.com/WebMCP-org/chrome-devtools-quickstart / startDevServer

Function startDevServer

benchmark/simple-benchmark.ts:56–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54let devServerProcess: ChildProcess | null = null;
55
56async function startDevServer(): Promise<void> {
57 return new Promise((resolve, reject) => {
58 cli.info("Starting Vite dev server...");
59
60 devServerProcess = spawn("npm", ["run", "dev"], {
61 cwd: projectRoot,
62 stdio: ["ignore", "pipe", "pipe"],
63 shell: true,
64 });
65
66 let started = false;
67 const timeout = setTimeout(() => {
68 if (!started) {
69 reject(new Error("Dev server startup timeout"));
70 }
71 }, 30000);
72
73 devServerProcess.stdout?.on("data", (data: Buffer) => {
74 const output = data.toString();
75 if (output.includes("localhost:5173") || output.includes("Local:")) {
76 if (!started) {
77 started = true;
78 clearTimeout(timeout);
79 cli.success("Dev server ready at http://localhost:5173");
80 setTimeout(resolve, 1000);
81 }
82 }
83 });
84
85 devServerProcess.stderr?.on("data", (data: Buffer) => {
86 const output = data.toString();
87 if (output.includes("localhost:5173") || output.includes("Local:")) {
88 if (!started) {
89 started = true;
90 clearTimeout(timeout);
91 cli.success("Dev server ready at http://localhost:5173");
92 setTimeout(resolve, 1000);
93 }
94 }
95 });
96
97 devServerProcess.on("error", (err) => {
98 clearTimeout(timeout);
99 reject(err);
100 });
101
102 devServerProcess.on("exit", (code) => {
103 if (!started && code !== 0) {
104 clearTimeout(timeout);
105 reject(new Error(`Dev server exited with code ${code}`));
106 }
107 });
108 });
109}
110
111function stopDevServer(): void {
112 if (devServerProcess) {

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected