mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-28 05:36:34 +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 { execFile } from 'child_process';
|
||||||
|
import { app, remote } from 'electron';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { argv, env } from 'process';
|
import { env } from 'process';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
|
|
||||||
const execFileAsync = promisify(execFile);
|
const execFileAsync = promisify(execFile);
|
||||||
@ -24,16 +25,6 @@ const execFileAsync = promisify(execFile);
|
|||||||
const SUCCESSFUL_AUTH_MARKER = 'AUTHENTICATION SUCCEEDED';
|
const SUCCESSFUL_AUTH_MARKER = 'AUTHENTICATION SUCCEEDED';
|
||||||
const EXPECTED_SUCCESSFUL_AUTH_MARKER = `${SUCCESSFUL_AUTH_MARKER}\n`;
|
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(
|
export async function sudo(
|
||||||
command: string,
|
command: string,
|
||||||
): Promise<{ cancelled: boolean; stdout?: string; stderr?: string }> {
|
): Promise<{ cancelled: boolean; stdout?: string; stderr?: string }> {
|
||||||
@ -46,7 +37,7 @@ export async function sudo(
|
|||||||
env: {
|
env: {
|
||||||
PATH: env.PATH,
|
PATH: env.PATH,
|
||||||
SUDO_ASKPASS: join(
|
SUDO_ASKPASS: join(
|
||||||
getAppPath(),
|
(app || remote.app).getAppPath(),
|
||||||
__dirname,
|
__dirname,
|
||||||
'sudo-askpass.osascript.js',
|
'sudo-askpass.osascript.js',
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user