Something went wrong. Try again.
All-in-one editor for Paper Mario (N64) mods diorama64.starhaven.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#!/usr/bin/env node// SPDX-FileCopyrightText: 2026 Alexander Bates <alex@bates64.com>//// SPDX-License-Identifier: 0BSD
// Lets electron-builder package Windows and macOS releases on Linux, by// editing node_modules in place. Run it after `yarn install`. It fails if// electron-builder has changed the code it edits, rather than leave a build// that quietly does the wrong thing.
import { readFile, writeFile } from "node:fs/promises";import { dirname, join } from "node:path";import { fileURLToPath } from "node:url";
const modules = join( dirname(fileURLToPath(import.meta.url)), "..", "..", "node_modules",);
const PATCHES = [ { // The NSIS installer embeds an uninstaller it can only get by running a // first build of the installer, which electron-builder does under Wine // everywhere but macOS. Its macOS path reads it out of the installer // instead, and works anywhere. file: "app-builder-lib/dist/targets/win/nsis/NsisTarget.js", from: "if (isMacOsCatalina()) {", to: 'if (isMacOsCatalina() || process.platform === "linux") {', }, { // Merging the two architectures' apps only needs lipo, which the cross // devshell provides, but @electron/universal refuses to try off macOS. file: "@electron/universal/dist/index.js", from: "if (process.platform !== 'darwin')\n throw", to: "if (false)\n throw", },];
for (const { file, from, to } of PATCHES) { const path = join(modules, file); const source = await readFile(path, "utf8"); if (source.includes(to)) continue; if (!source.includes(from)) { console.error( `${file} has changed, so it can't be patched for Linux; update this script.`, ); process.exit(1); } await writeFile(path, source.replace(from, to)); console.log(`Patched ${file}.`);}