36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { spawn } from "bun"
|
|
|
|
console.log("\n\n----------------------------------")
|
|
console.log(`Node Environment: ${process.env.NODE_ENV || "development"}`)
|
|
console.log(`Bun Version: ${Bun.version}`)
|
|
console.log("----------------------------------\n\n")
|
|
|
|
const run = async (cmd: string[]) => {
|
|
// Filter gets rid of empty strings because it FREAKS Bun out
|
|
const proc = spawn(cmd.filter(Boolean), { stdout: "inherit", stderr: "inherit" })
|
|
const status = await proc.exited
|
|
|
|
const commandText = cmd.join(" ")
|
|
if (status !== 0) {
|
|
throw new Error(`Process "${commandText}" failed with exit code ${status}`)
|
|
} else {
|
|
console.log(`👋 Process ${commandText}(PID ${proc.pid}) exited with code ${status}`)
|
|
}
|
|
|
|
return status
|
|
}
|
|
|
|
try {
|
|
const isDev = process.env.NODE_ENV !== "production"
|
|
const noElide = isDev ? "--elide-lines=0" : ""
|
|
|
|
await Promise.all([
|
|
run(["bun", "run", noElide, "--filter=@workshop/http", "start"]),
|
|
run(["bun", "run", noElide, "--filter=@workshop/spike", "bot:discord"]),
|
|
])
|
|
console.log("✅ All processes completed successfully")
|
|
} catch (error) {
|
|
console.error("❌ One or more processes failed:", error)
|
|
process.exit(1)
|
|
}
|