| 1 | #!/usr/bin/env node |
| 2 | // Runs the frontend build for one shell. The shell name travels through the |
| 3 | // environment because npm scripts cannot set variables portably on Windows. |
| 4 | import { spawnSync } from "node:child_process"; |
| 5 | import { fileURLToPath } from "node:url"; |
| 6 | import { shellFromEnv } from "./shell-css.mjs"; |
| 7 | |
| 8 | const shell = shellFromEnv({ REASONIX_SHELL: process.argv[2] ?? "" }); |
| 9 | const frontend = fileURLToPath(new URL("..", import.meta.url)); |
| 10 | const bundleOnly = process.argv.includes("--bundle-only"); |
| 11 | const commands = bundleOnly |
| 12 | ? [["exec", "vite", "build"], ["exec", "node", "scripts/check-bundle-budget.mjs"]] |
| 13 | : [["build"]]; |
| 14 | let status = 0; |
| 15 | for (const args of commands) { |
| 16 | const result = spawnSync("pnpm", args, { |
| 17 | cwd: frontend, |
| 18 | stdio: "inherit", |
| 19 | env: { ...process.env, REASONIX_SHELL: shell }, |
| 20 | shell: process.platform === "win32", |
| 21 | }); |
| 22 | status = result.status ?? 1; |
| 23 | if (status !== 0) break; |
| 24 | } |
| 25 | process.exit(status); |
| 26 |