MCPcopy
hub / github.com/Koenkk/zigbee2mqtt / build

Function build

index.js:82–112  ·  view source on GitHub ↗

@type {(reason: "initial build" | "hash changed") => Promise }

(reason)

Source from the content-addressed store, hash-verified

80
81/** @type {(reason: "initial build" | "hash changed") => Promise<void>} */
82async function build(reason) {
83 process.stdout.write(`Building Zigbee2MQTT... (${reason})`);
84 const {totalmem} = await import("node:os");
85
86 return await new Promise((resolve, reject) => {
87 const env = {...process.env};
88 const mb600 = 629145600;
89
90 if (mb600 > totalmem() && !env.NODE_OPTIONS) {
91 // Prevent OOM on tsc compile for system with low memory
92 // https://github.com/Koenkk/zigbee2mqtt/issues/12034
93 env.NODE_OPTIONS = "--max_old_space_size=256";
94 }
95
96 // clean build, prevent failures due to tsc incremental building
97 exec("pnpm run prepack", {env, cwd: __dirname}, (err) => {
98 if (err) {
99 process.stdout.write(", failed\n");
100
101 if (err.code === 134) {
102 process.stderr.write("\n\nBuild failed; ran out-of-memory, free some memory (RAM) and start again\n\n");
103 }
104
105 reject(err);
106 } else {
107 process.stdout.write(", finished\n");
108 resolve();
109 }
110 });
111 });
112}
113
114/** @type {() => Promise<void>} */
115async function checkDist() {

Callers 1

checkDistFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected