(command, cwd, packageName)
| 6 | const npmInstallCmd = process.env.CI === "true" ? "npm ci" : "npm install"; |
| 7 | |
| 8 | function runCommand(command, cwd, packageName) { |
| 9 | return new Promise((resolve, reject) => { |
| 10 | console.log(`Starting ${packageName}: ${command}`); |
| 11 | |
| 12 | const [cmd, ...args] = command.split(" "); |
| 13 | const child = spawn(cmd, args, { |
| 14 | cwd, |
| 15 | stdio: "pipe", |
| 16 | shell: true, |
| 17 | }); |
| 18 | |
| 19 | let stdout = ""; |
| 20 | let stderr = ""; |
| 21 | |
| 22 | child.stdout.on("data", (data) => { |
| 23 | stdout += data.toString(); |
| 24 | }); |
| 25 | |
| 26 | child.stderr.on("data", (data) => { |
| 27 | stderr += data.toString(); |
| 28 | }); |
| 29 | |
| 30 | child.on("close", (code) => { |
| 31 | if (code === 0) { |
| 32 | console.log(`✅ ${packageName}: ${command} completed successfully`); |
| 33 | resolve({ packageName, command, stdout, stderr }); |
| 34 | } else { |
| 35 | console.error(`❌ ${packageName}: ${command} failed with code ${code}`); |
| 36 | console.error(`stderr: ${stderr}`); |
| 37 | console.error(`stdout: ${stdout}`); |
| 38 | reject( |
| 39 | new Error(`${packageName} failed: ${command} (exit code ${code})`), |
| 40 | ); |
| 41 | } |
| 42 | }); |
| 43 | |
| 44 | child.on("error", (error) => { |
| 45 | console.error(`❌ ${packageName}: Failed to start ${command}:`, error); |
| 46 | reject(error); |
| 47 | }); |
| 48 | }); |
| 49 | } |
| 50 | |
| 51 | // Helper function to build a package (install + build) |
| 52 | async function buildPackage(packageName, cleanNodeModules = false) { |
no test coverage detected