Files
2025-03-02 20:36:05 +08:00

25 lines
757 B
JavaScript

import { spawn } from "node:child_process";
import fs from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";
import { fileURLToPath } from "node:url";
const pkg = createRequire(import.meta.url)("../package.json");
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// write .debug.env
const envContent = Object.entries(pkg.debug.env).map(([key, val]) => `${key}=${val}`);
fs.writeFileSync(path.join(__dirname, ".debug.env"), envContent.join("\n"));
// bootstrap
spawn(
// TODO: terminate `npm run dev` when Debug exits.
process.platform === "win32" ? "npm.cmd" : "npm",
["run", "dev"],
{
stdio: "inherit",
shell: true,
env: Object.assign(process.env, { VSCODE_DEBUG: "true" }),
}
);