aboutsummaryrefslogtreecommitdiff
path: root/linux-sandbox-fix.js
blob: 53c25069d902a13041ff0b6776ba2fc0e51a9827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs').promises;
const path = require('path');

/**
 * Workaround for https://github.com/electron-userland/electron-builder/issues/5371
 *
 * use as "afterPack": "./linux-sandbox-fix.js" in build section of package.json
 */
async function afterPack({ appOutDir, electronPlatformName, packager }) {
    if (electronPlatformName !== 'linux') {
        return;
    }

    const appName = packager.appInfo.productFilename;
    const script = `#!/bin/bash\n"\${BASH_SOURCE%/*}"/${appName}.bin --no-sandbox "$@"`;
    const scriptPath = path.join(appOutDir, appName);

    await fs.rename(scriptPath, `${scriptPath}.bin`);
    await fs.writeFile(scriptPath, script);
    await fs.chmod(scriptPath, 0o755);
}

module.exports = afterPack;