20 lines
795 B
JavaScript
20 lines
795 B
JavaScript
const fs = require("node:fs/promises");
|
|
const path = require("node:path");
|
|
|
|
// Resource editing can leave an abandoned atomic-write file next to the EXE.
|
|
// Run after resource editing/signing and before NSIS compresses the app directory.
|
|
module.exports = async function cleanup(context) {
|
|
if (context.electronPlatformName !== "win32") return;
|
|
const executable = context.packager.appInfo.productFilename + ".exe";
|
|
for (const entry of await fs.readdir(context.appOutDir, { withFileTypes: true })) {
|
|
if (
|
|
entry.isFile() &&
|
|
entry.name !== executable &&
|
|
/^\.electron\.exe\.[A-Za-z0-9]{6}$/.test(entry.name)
|
|
) {
|
|
await fs.unlink(path.join(context.appOutDir, entry.name));
|
|
console.log("Removed abandoned Electron packaging file: " + entry.name);
|
|
}
|
|
}
|
|
};
|