import { spawnSync } from 'child_process'; import path from 'path'; import { fileURLToPath } from 'url'; const root = path.join(path.dirname(fileURLToPath(import.meta.url)), '..'); const department = process.argv[2]; if (!department) { console.error('Usage: npm run deploy -- '); process.exit(1); } function run(command, args) { const result = spawnSync(command, args, { cwd: root, stdio: 'inherit', shell: true, }); if ((result.status ?? 1) !== 0) { process.exit(result.status ?? 1); } } run('npm', ['test']); run('node', ['tools/build.mjs', department]); run('node', ['tools/push.mjs', department]);