| 179 | |
| 180 | // Run a command and capture output |
| 181 | async function runCommand(cmd: string[], description: string) { |
| 182 | console.log(`\n${description}`); |
| 183 | |
| 184 | const proc = Bun.spawn(cmd, { |
| 185 | stdout: 'pipe', |
| 186 | stderr: 'pipe' |
| 187 | }); |
| 188 | |
| 189 | // Read stdout using the streaming API |
| 190 | let stdout = ''; |
| 191 | if (proc.stdout) { |
| 192 | const reader = proc.stdout.getReader(); |
| 193 | const decoder = new TextDecoder(); |
| 194 | try { |
| 195 | while (true) { |
| 196 | const { done, value } = await reader.read(); |
| 197 | if (done) break; |
| 198 | stdout += decoder.decode(value); |
| 199 | } |
| 200 | } catch (error) { |
| 201 | // Ignore read errors |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | // Read stderr |
| 206 | let stderr = ''; |
| 207 | if (proc.stderr) { |
| 208 | const reader = proc.stderr.getReader(); |
| 209 | const decoder = new TextDecoder(); |
| 210 | try { |
| 211 | while (true) { |
| 212 | const { done, value } = await reader.read(); |
| 213 | if (done) break; |
| 214 | stderr += decoder.decode(value); |
| 215 | } |
| 216 | } catch (error) { |
| 217 | // Ignore read errors |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | const exitCode = await proc.exited; |
| 222 | |
| 223 | if (stdout) console.log(stdout); |
| 224 | if (stderr) console.error(stderr); |
| 225 | |
| 226 | return { |
| 227 | success: exitCode === 0, |
| 228 | stdout, |
| 229 | stderr, |
| 230 | exitCode |
| 231 | }; |
| 232 | } |
| 233 | |
| 234 | // Main check function |
| 235 | async function runChecks() { |