mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-23 19:26:33 +00:00
Use electron.app.getAppPath() instead of reading it from argv in catalina-sudo
Changelog-entry: Use electron.app.getAppPath() instead of reading it from argv in catalina-sudo Change-type: patch
This commit is contained in:
parent
2692104ccd
commit
09a6a340c9
@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
import { execFile } from 'child_process';
|
||||
import { app, remote } from 'electron';
|
||||
import { join } from 'path';
|
||||
import { argv, env } from 'process';
|
||||
import { env } from 'process';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
@ -24,16 +25,6 @@ const execFileAsync = promisify(execFile);
|
||||
const SUCCESSFUL_AUTH_MARKER = 'AUTHENTICATION SUCCEEDED';
|
||||
const EXPECTED_SUCCESSFUL_AUTH_MARKER = `${SUCCESSFUL_AUTH_MARKER}\n`;
|
||||
|
||||
function getAppPath() {
|
||||
for (const arg of argv) {
|
||||
const [option, value] = arg.split('=');
|
||||
if (option === '--app-path') {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
throw new Error("Couldn't find --app-path= in argv");
|
||||
}
|
||||
|
||||
export async function sudo(
|
||||
command: string,
|
||||
): Promise<{ cancelled: boolean; stdout?: string; stderr?: string }> {
|
||||
@ -46,7 +37,7 @@ export async function sudo(
|
||||
env: {
|
||||
PATH: env.PATH,
|
||||
SUDO_ASKPASS: join(
|
||||
getAppPath(),
|
||||
(app || remote.app).getAppPath(),
|
||||
__dirname,
|
||||
'sudo-askpass.osascript.js',
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user