30 lines
789 B
JavaScript
30 lines
789 B
JavaScript
const path = require("path");
|
|
const { spawn } = require("child_process");
|
|
|
|
const run = (command, args) =>
|
|
new Promise((resolve, reject) => {
|
|
const child = spawn(command, args, { stdio: "inherit" });
|
|
child.on("close", (code) => {
|
|
if (code === 0) {
|
|
resolve();
|
|
return;
|
|
}
|
|
reject(new Error(`Command failed: ${command} ${args.join(" ")}`));
|
|
});
|
|
});
|
|
|
|
const start = async () => {
|
|
const seedPath = path.join(__dirname, "seed.js");
|
|
const serverPath = path.join(__dirname, "..", "server.js");
|
|
|
|
await run("node", [seedPath]);
|
|
|
|
const server = spawn("node", [serverPath], { stdio: "inherit" });
|
|
server.on("close", (code) => process.exit(code ?? 0));
|
|
};
|
|
|
|
start().catch((error) => {
|
|
console.error("Demo failed", error);
|
|
process.exit(1);
|
|
});
|