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:
Juan Cruz Viotti 2016-04-19 11:07:59 -04:00
parent fdf28cdf5f
commit 975c949fdf

View File

@ -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');