initial commit
This commit is contained in:
commit
18255ce4cd
21 changed files with 1244 additions and 0 deletions
31
scripts/install.js
Normal file
31
scripts/install.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { execSync } from "node:child_process"
|
||||
import { createRequire } from "node:module";
|
||||
import { download } from "./download";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const forceBuild = process.env["npm_config_build_from_source"] == "true";
|
||||
|
||||
function hasPrebuilt() {
|
||||
let prebuilt = false;
|
||||
|
||||
try {
|
||||
require("node-gyp-build")("..");
|
||||
prebuilt = true;
|
||||
} catch (error) {
|
||||
prebuilt = false;
|
||||
}
|
||||
|
||||
return prebuilt;
|
||||
}
|
||||
|
||||
async function install() {
|
||||
console.log("[Mw] Downloading Milsko library...");
|
||||
await download();
|
||||
|
||||
console.log("[Mw] Building from source...");
|
||||
execSync("npx node-gyp rebuild", { stdio: "inherit" });
|
||||
}
|
||||
|
||||
if (forceBuild || !hasPrebuilt()) {
|
||||
install();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue