mirror of
https://github.com/fanchenio/DawnLauncher.git
synced 2025-07-13 21:02:10 +08:00
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const path = require("path");
|
|
const child = require("child_process");
|
|
|
|
// If you prefer electron-rebuild:
|
|
// 👉 https://github.com/WiseLibs/better-sqlite3/blob/v8.5.2/docs/troubleshooting.md#electron
|
|
// 👉 https://stackoverflow.com/questions/46384591/node-was-compiled-against-a-different-node-js-version-using-node-module-versio/52796884#52796884
|
|
|
|
const better_sqlite3 = require.resolve("better-sqlite3-multiple-ciphers");
|
|
const better_sqlite3_root = path.posix.join(
|
|
better_sqlite3.slice(0, better_sqlite3.lastIndexOf("node_modules")),
|
|
"node_modules/better-sqlite3-multiple-ciphers"
|
|
);
|
|
const cp = child.spawn(
|
|
process.platform === "win32" ? "npm.cmd" : "npm",
|
|
[
|
|
"run",
|
|
"build-release",
|
|
`--target=${process.versions.electron}`,
|
|
// https://github.com/electron/electron/blob/v26.1.0/docs/tutorial/using-native-node-modules.md#manually-building-for-electron
|
|
"--dist-url=https://electronjs.org/headers",
|
|
],
|
|
{
|
|
cwd: better_sqlite3_root,
|
|
stdio: "inherit",
|
|
}
|
|
);
|
|
|
|
cp.on("exit", (code) => {
|
|
if (code === 0) {
|
|
console.log("Rebuild better-sqlite3 success.");
|
|
}
|
|
process.exit(code);
|
|
});
|