File size: 706 Bytes
35743bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node

import { spawn } from "node:child_process";

const env = { ...process.env };

await exec("npx", ["next", "build", "--experimental-build-mode", "generate"]);

// launch application
const [command, ...args] = process.argv.slice(2);
if (!command) {
  throw new Error("Missing command to launch after database setup");
}
await exec(command, args);

function exec(command, args = []) {
  const child = spawn(command, args, { stdio: "inherit", env });
  return new Promise((resolve, reject) => {
    child.on("exit", (code) => {
      if (code === 0) {
        resolve();
      } else {
        reject(new Error(`${[command, ...args].join(" ")} failed rc=${code}`));
      }
    });
  });
}