mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-19 17:26:34 +00:00
Merge pull request #3000 from balena-io/fix-macos-elevation-in-development
Fix elevation on macos in development
This commit is contained in:
commit
517511e5be
@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const { execFile } = require('child_process')
|
||||
const { env, resourcesPath } = require('process')
|
||||
const { argv, env } = require('process')
|
||||
const { join } = require('path')
|
||||
const { promisify } = require('util')
|
||||
|
||||
@ -10,6 +10,19 @@ const execFileAsync = promisify(execFile)
|
||||
const SUCCESSFUL_AUTH_MARKER = 'AUTHENTICATION SUCCEEDED'
|
||||
const EXPECTED_SUCCESSFUL_AUTH_MARKER = `${SUCCESSFUL_AUTH_MARKER}\n`
|
||||
|
||||
/* eslint-disable-next-line require-jsdoc */
|
||||
const getAppPath = () => {
|
||||
for (const arg of argv) {
|
||||
/* eslint-disable-next-line lodash/prefer-lodash-method */
|
||||
const [ option, value ] = arg.split('=')
|
||||
if (option === '--app-path') {
|
||||
return value
|
||||
}
|
||||
}
|
||||
/* eslint-disable-next-line quotes */
|
||||
throw new Error("Couldn't find --app-path= in argv")
|
||||
}
|
||||
|
||||
exports.sudo = async (command) => {
|
||||
try {
|
||||
const { stdout, stderr } = await execFileAsync(
|
||||
@ -19,7 +32,7 @@ exports.sudo = async (command) => {
|
||||
encoding: 'utf8',
|
||||
env: {
|
||||
PATH: env.PATH,
|
||||
SUDO_ASKPASS: join(resourcesPath, 'app', __dirname, 'sudo-askpass.osascript.js')
|
||||
SUDO_ASKPASS: join(getAppPath(), __dirname, 'sudo-askpass.osascript.js')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user