mirror of
https://git.quad4.io/RNS-Things/MeshChatX.git
synced 2026-04-25 06:42:10 +00:00
feat(electron): add script to manage temporary directory for Electron Forge builds
This commit is contained in:
32
scripts/electron-forge-local-tmp.js
Normal file
32
scripts/electron-forge-local-tmp.js
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Staging must live outside the repo: packager copies the project into TMPDIR, which cannot be under the source tree.
|
||||
|
||||
const { spawnSync } = require("child_process");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const root = path.join(__dirname, "..");
|
||||
const defaultTmpDir = path.join(path.dirname(root), `.forge-tmp-${path.basename(root)}`);
|
||||
const tmpDir = path.resolve(process.env.FORGE_TMPDIR || defaultTmpDir);
|
||||
fs.mkdirSync(tmpDir, { recursive: true });
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
TMPDIR: tmpDir,
|
||||
TEMP: tmpDir,
|
||||
TMP: tmpDir,
|
||||
};
|
||||
|
||||
const forgeCli = require.resolve("@electron-forge/cli/dist/electron-forge.js");
|
||||
const args = process.argv.slice(2);
|
||||
const result = spawnSync(process.execPath, [forgeCli, ...args], {
|
||||
cwd: root,
|
||||
env,
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
if (result.signal) {
|
||||
process.exit(1);
|
||||
}
|
||||
process.exit(result.status ?? 1);
|
||||
Reference in New Issue
Block a user