forked from scanoss/sbom-workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appimage-fix.js
27 lines (23 loc) · 847 Bytes
/
appimage-fix.js
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
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const appName = 'scanoss-workbench';
function isLinux(targets) {
const re = /AppImage|snap|deb|rpm|freebsd|pacman/i;
return !!targets.find((target) => re.test(target.name));
}
async function afterPack({ targets, appOutDir }) {
if (!isLinux(targets)) return;
const scriptPath = path.join(appOutDir, appName);
const script = `#!/bin/bash\n"\${BASH_SOURCE%/*}"/${appName}.bin "$@" --no-sandbox`;
new Promise((resolve) => {
const child = child_process.exec(`mv ${appName} ${appName}.bin`, { cwd: appOutDir });
child.on('exit', () => {
resolve();
});
}).then(() => {
fs.writeFileSync(scriptPath, script);
child_process.exec(`chmod +x ${appName}`, { cwd: appOutDir });
});
}
module.exports = afterPack;