forked from someone5678/YouTubeTVUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappimage-fix.js
27 lines (23 loc) · 886 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'),
fs = require('fs'),
path = require('path');
const appName = "youtubecouchui";
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),
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;