2026-06-21 15:55:41 -05:00
|
|
|
const fs = require("fs");
|
|
|
|
|
const path = require("path");
|
2026-09-20 14:56:39 -05:00
|
|
|
const { chmodSpawnHelpers } = require("../../scripts/patch-node-pty.cjs");
|
2026-06-21 15:55:41 -05:00
|
|
|
|
|
|
|
|
exports.default = async function afterPack(context) {
|
|
|
|
|
const { targets, appOutDir } = context;
|
|
|
|
|
|
|
|
|
|
const isDir = targets.some((t) => t.name === "dir");
|
2026-09-20 14:56:39 -05:00
|
|
|
if (isDir) {
|
|
|
|
|
const markerPath = path.join(appOutDir, ".portable");
|
|
|
|
|
fs.writeFileSync(markerPath, "");
|
|
|
|
|
}
|
2026-06-21 15:55:41 -05:00
|
|
|
|
2026-09-20 14:56:39 -05:00
|
|
|
if (context.electronPlatformName === "win32") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resourcesDir =
|
|
|
|
|
context.electronPlatformName === "darwin"
|
|
|
|
|
? path.join(
|
|
|
|
|
appOutDir,
|
|
|
|
|
`${context.packager.appInfo.productFilename}.app`,
|
|
|
|
|
"Contents",
|
|
|
|
|
"Resources",
|
|
|
|
|
)
|
|
|
|
|
: path.join(appOutDir, "resources");
|
|
|
|
|
|
|
|
|
|
const nodePtyDir = path.join(
|
|
|
|
|
resourcesDir,
|
|
|
|
|
"app.asar.unpacked",
|
|
|
|
|
"node_modules",
|
|
|
|
|
"node-pty",
|
|
|
|
|
);
|
|
|
|
|
const fixed = chmodSpawnHelpers(nodePtyDir);
|
|
|
|
|
if (fixed > 0) {
|
|
|
|
|
console.log(
|
|
|
|
|
`[afterPack] Restored execute bit on ${fixed} packaged spawn-helper binary(ies)`,
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-06-21 15:55:41 -05:00
|
|
|
};
|