fix: set shell: true for execRoot

This commit is contained in:
Amin Yahyaabadi 2022-08-07 18:52:03 -07:00
parent 88c2d1ac03
commit f8515dfc8b
2 changed files with 5 additions and 5 deletions

View File

@ -24,13 +24,13 @@ export function prependSudo(command: string) {
* *
* @param program The program to spawn * @param program The program to spawn
* @param args The command arguments * @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 * @returns The execution result
*/ */
export function execRootSync( export function execRootSync(
program: string, program: string,
args: string[] = [], args: string[] = [],
execOptions: execa.SyncOptions = { stdio: "inherit" } execOptions: execa.SyncOptions = { stdio: "inherit", shell: true }
): execa.ExecaSyncReturnValue<string> { ): execa.ExecaSyncReturnValue<string> {
if (isSudo()) { if (isSudo()) {
return execa.commandSync(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions) 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 program The program to spawn
* @param args The command arguments * @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 * @returns A promise to the execution result
*/ */
export function execRoot( export function execRoot(
program: string, program: string,
args: string[] = [], args: string[] = [],
execOptions: execa.Options = { stdio: "inherit" } execOptions: execa.Options = { stdio: "inherit", shell: true }
): execa.ExecaChildProcess<string> { ): execa.ExecaChildProcess<string> {
if (isSudo()) { if (isSudo()) {
return execa.command(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions) return execa.command(`sudo ${[program, ...args].map((arg) => `'${arg}'`).join(" ")}`, execOptions)

View File

@ -8,6 +8,6 @@ export function folderUserAccess(folder: string) {
isSudo() && isSudo() &&
process.env.SUDO_USER !== undefined 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 })
} }
} }