()
| 140 | } |
| 141 | |
| 142 | async start() { |
| 143 | this.log = "" |
| 144 | this.port = await freePort() |
| 145 | const child = spawn( |
| 146 | process.execPath, |
| 147 | [next, "dev", "-p", String(this.port), ...bundlers[this.bundler].flags], |
| 148 | { |
| 149 | cwd: appDir, |
| 150 | detached: process.platform !== "win32", |
| 151 | env: { ...process.env, NEXT_TELEMETRY_DISABLED: "1" } |
| 152 | } |
| 153 | ) |
| 154 | this.child = child |
| 155 | child.stdout!.on("data", data => (this.log += data)) |
| 156 | child.stderr!.on("data", data => (this.log += data)) |
| 157 | for (let waited = 0; !this.log.includes("Ready"); waited += 100) { |
| 158 | if (waited > 60_000 || child.exitCode !== null) { |
| 159 | throw new Error( |
| 160 | `${this.bundler}'s dev server didn't start:\n${this.log}` |
| 161 | ) |
| 162 | } |
| 163 | await sleep(100) |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | stop() { |
| 168 | if (this.child) killTree(this.child) |
no test coverage detected