Merge pull request #2829 from balena-io/dont-elevate-when-root

Don't use sudo-prompt when already elevated
This commit is contained in:
Alexis Svinartchouk 2019-06-13 16:26:48 +02:00 committed by GitHub
commit a58e060138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -179,6 +179,10 @@ const elevateScriptUnix = async (path, name) => {
* });
*/
exports.elevateCommand = async (command, options) => {
if (await exports.isElevated()) {
await childProcess.execFileAsync(command[0], command.slice(1), { env: options.environment })
return { cancelled: false }
}
const isWindows = os.platform() === 'win32'
const launchScript = exports.createLaunchScript(command[0], command.slice(1), options.environment)
return Bluebird.using(tmpFileDisposer({ postfix: '.cmd' }), async ({ path }) => {