mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 07:17:18 +00:00
Allow to bypass elevation with an environment variable (#343)
This is mostly used for debugging purposes, or by power users that know what they're doing. Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
parent
fdf28cdf5f
commit
975c949fdf
@ -29,19 +29,26 @@ exports.require = function(app, applicationName, callback) {
|
||||
}
|
||||
|
||||
return Bluebird.try(function() {
|
||||
if (platform === 'darwin') {
|
||||
|
||||
// Keep parent process hidden
|
||||
app.dock.hide();
|
||||
// This environment variable is usually set
|
||||
// for debugging purposes, or for power users
|
||||
// that really know what they're doing.
|
||||
if (!process.env.ETCHER_BYPASS_ELEVATION) {
|
||||
|
||||
return sudoPrompt.execAsync(process.argv.join(' '), {
|
||||
name: applicationName
|
||||
});
|
||||
}
|
||||
if (platform === 'darwin') {
|
||||
|
||||
if (platform === 'win32') {
|
||||
const elevator = Bluebird.promisifyAll(require('elevator'));
|
||||
return elevator.executeAsync(process.argv, {});
|
||||
// Keep parent process hidden
|
||||
app.dock.hide();
|
||||
|
||||
return sudoPrompt.execAsync(process.argv.join(' '), {
|
||||
name: applicationName
|
||||
});
|
||||
}
|
||||
|
||||
if (platform === 'win32') {
|
||||
const elevator = Bluebird.promisifyAll(require('elevator'));
|
||||
return elevator.executeAsync(process.argv, {});
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Please run this application as root or administrator');
|
||||
|
Loading…
x
Reference in New Issue
Block a user