etcher/afterPack.js
Alexis Svinartchouk 1408dd48a1 Don't add --no-sandbox when ELECTRON_RUN_AS_NODE true
Changelog-entry: Don't add --no-sandbox when ELECTRON_RUN_AS_NODE true
Change-type: patch
2019-12-10 11:04:01 +01:00

28 lines
782 B
JavaScript

'use strict'
const cp = require('child_process')
const fs = require('fs')
const outdent = require('outdent')
const path = require('path')
exports.default = function(context) {
if (context.packager.platform.name !== 'linux') {
return
}
const scriptPath = path.join(context.appOutDir, context.packager.executableName)
const binPath = scriptPath + '.bin'
cp.execFileSync('mv', [scriptPath, binPath])
fs.writeFileSync(
scriptPath,
outdent`
#!/bin/bash
if [[ $EUID -ne 0 ]] || [[ $ELECTRON_RUN_AS_NODE ]]; then
"\${BASH_SOURCE%/*}"/${context.packager.executableName}.bin "$@"
else
"\${BASH_SOURCE%/*}"/${context.packager.executableName}.bin "$@" --no-sandbox
fi
`
)
cp.execFileSync('chmod', ['+x', scriptPath])
}