diff --git a/lib/elevate.js b/lib/elevate.js index b921ece0..a565f886 100644 --- a/lib/elevate.js +++ b/lib/elevate.js @@ -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');