-
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathafterPackHook.js
More file actions
31 lines (26 loc) · 1.12 KB
/
Copy pathafterPackHook.js
File metadata and controls
31 lines (26 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { setFuses } = require('./setFuses');
const path = require('path');
const fs = require('fs');
exports.default = async function(context) {
// Get the Electron binary path based on platform
const { appOutDir, packager, electronPlatformName } = context;
const { productFilename } = packager.appInfo;
let electronBinaryPath;
if (electronPlatformName === 'darwin') {
// macOS
electronBinaryPath = path.join(appOutDir, `${productFilename}.app`, 'Contents', 'MacOS', productFilename);
} else if (electronPlatformName === 'win32') {
// Windows
electronBinaryPath = path.join(appOutDir, `${productFilename}.exe`);
} else {
// Linux
electronBinaryPath = path.join(appOutDir, productFilename);
}
// Check if the binary exists
if (!fs.existsSync(electronBinaryPath)) {
const contents = fs.existsSync(appOutDir) ? fs.readdirSync(appOutDir) : [];
throw new Error(`Electron binary not found at: ${electronBinaryPath}. appOutDir contains: ${contents.join(', ')}`);
}
// Fuse failures are security failures and must stop the package build.
await setFuses(appOutDir, electronBinaryPath);
};