diff --git a/packages/sudo-tools/src/index.ts b/packages/sudo-tools/src/index.ts index 028d8654..4d919a00 100644 --- a/packages/sudo-tools/src/index.ts +++ b/packages/sudo-tools/src/index.ts @@ -24,13 +24,13 @@ export function prependSudo(command: string) { * * @param program The program to spawn * @param args The command arguments - * @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit" }` + * @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit", shell: true }` * @returns The execution result */ export function execRootSync( program: string, args: string[] = [], - execOptions: execa.SyncOptions = { stdio: "inherit" } + execOptions: execa.SyncOptions = { stdio: "inherit", shell: true } ): execa.ExecaSyncReturnValue { if (isSudo()) { return execa.commandSync(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions) @@ -44,13 +44,13 @@ export function execRootSync( * * @param program The program to spawn * @param args The command arguments - * @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit" }` + * @param execOptions The options passed to `execa`. Defaults to `{ stdio: "inherit", shell: true }` * @returns A promise to the execution result */ export function execRoot( program: string, args: string[] = [], - execOptions: execa.Options = { stdio: "inherit" } + execOptions: execa.Options = { stdio: "inherit", shell: true } ): execa.ExecaChildProcess { if (isSudo()) { return execa.command(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions) diff --git a/src/utils/fs/userAccess.ts b/src/utils/fs/userAccess.ts index cc7e0dab..82d61d14 100644 --- a/src/utils/fs/userAccess.ts +++ b/src/utils/fs/userAccess.ts @@ -8,6 +8,6 @@ export function folderUserAccess(folder: string) { isSudo() && process.env.SUDO_USER !== undefined ) { - execRootSync("chown", ["-R", process.env.SUDO_USER, folder], { cwd: folder, stdio: "inherit" }) + execRootSync("chown", ["-R", process.env.SUDO_USER, folder], { cwd: folder, stdio: "inherit", shell: true }) } }