mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-08-07 05:19:15 -04:00

# Conflicts: # package.json Former-commit-id: db20644154051f805d9df2c330757f121df32409 [formerly 31e6f10ff7adbf502d9558dbe7010fd923355806 [formerly 518cb603c66ecd0325db61aabd7f5332159e4713]] Former-commit-id: 060a8c1558d66161d982535070b05008d4d598ec Former-commit-id: 45efb7473fcf576c45475f862907c53c967cee31
27 lines
902 B
JavaScript
27 lines
902 B
JavaScript
const child_process = require('child_process'),
|
|
fs = require('fs'),
|
|
path = require('path');
|
|
|
|
const appName = "kiwix-js-wikimed";
|
|
|
|
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; |