feat: add Go migration compatibility foundation
This commit is contained in:
32
scripts/run-go-command.mjs
Normal file
32
scripts/run-go-command.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const [, , command, ...args] = process.argv;
|
||||
if (!command) {
|
||||
console.error("Usage: node scripts/run-go-command.mjs <go-command> [args...]");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const backendDirectory = fileURLToPath(new URL("../backend/", import.meta.url));
|
||||
const child = spawn("go", [command, ...args], {
|
||||
cwd: backendDirectory,
|
||||
env: {
|
||||
...process.env,
|
||||
CGO_ENABLED: process.env.CGO_ENABLED || "0",
|
||||
},
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
child.on("error", (error) => {
|
||||
console.error(`[go:${command}] ${error.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
child.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
console.error(`[go:${command}] terminated by ${signal}`);
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(code ?? 1);
|
||||
});
|
||||
Reference in New Issue
Block a user