slint/api/node/build-on-demand.mjs
FloVanGH e79dcc4bec
Use same vscode-ext lint and format also for api/node (#6039)
* Use vscode ext lint and format also for api/node
* Re-use biome config file from VS code instead of duplicating it
* Remove package-lock.json again
* Don't bother running the biome formatter on Windows

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-09-09 09:22:33 +02:00

22 lines
818 B
JavaScript

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
// This file checks if a binary package was installed (through architecture dependencies), and
// builds slint if no binary was found.
import { Worker } from "node:worker_threads";
import { spawn } from "child_process";
const worker = new Worker("./rust-module.cjs");
// Define dummy error handler to prevent node from aborting on errors
worker.on("error", (error) => {
console.log(`Error loading rust-module.cjs: {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",
});
}
});