mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 04:48:27 +00:00
Fix fallback to source builds
Continue to run build-on-demand.mjs to permit a fallback to a from-source build for users who run `npm install slint-ui` on a platform where we don't provide binaries for (such as linux-armv7/64). However, this is only done when run from the installed package, not from git. From git, the prestart trick remains in use.
This commit is contained in:
parent
0461abfc73
commit
9f7e407eff
8 changed files with 26 additions and 14 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { Worker } from "node:worker_threads";
|
||||
import { spawn } from "node:child_process";
|
||||
import { existsSync } from "node:fs";
|
||||
|
||||
const worker = new Worker("./rust-module.cjs");
|
||||
// Define dummy error handler to prevent node from aborting on errors
|
||||
|
|
@ -14,9 +15,19 @@ worker.on("error", (error) => {
|
|||
});
|
||||
worker.on("exit", (code) => {
|
||||
if (code !== 0) {
|
||||
console.log("slint-ui: loading rust-module.cjs failed, building now");
|
||||
spawn("npm", ["run", "build"], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
// HACK: npm package removes .npmignore. If the file is present, then it means that we're in the Slint git repo,
|
||||
// and we don't want to automatically build (see https://github.com/slint-ui/slint/pull/6780).
|
||||
if (existsSync("./.npmignore")) {
|
||||
console.log(
|
||||
"slint-ui: loading rust-module.cjs failed, please run `npm run build` first.",
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
"slint-ui: loading rust-module.cjs failed, building now",
|
||||
);
|
||||
spawn("npm", ["run", "build"], {
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue