diff --git a/lib/shared/catalina-sudo/sudo.js b/lib/shared/catalina-sudo/sudo.js index 1ecd983e..a5d6a8df 100644 --- a/lib/shared/catalina-sudo/sudo.js +++ b/lib/shared/catalina-sudo/sudo.js @@ -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') } } ) diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 69e4a387..18bf7b2c 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -14826,4 +14826,4 @@ } } } -} +} \ No newline at end of file