( command: string, args: string[] = [] )
| 41 | } |
| 42 | |
| 43 | async function execWithSudo( |
| 44 | command: string, |
| 45 | args: string[] = [] |
| 46 | ): Promise<{ stdout: string; stderr: string }> { |
| 47 | try { |
| 48 | return await runFile(command, args); |
| 49 | } catch (err: any) { |
| 50 | if (!isPermissionError(err)) { |
| 51 | throw err; |
| 52 | } |
| 53 | |
| 54 | logger.info( |
| 55 | `Command requires elevated privileges, retrying with sudo: ${formatCommand(command, args)}` |
| 56 | ); |
| 57 | return await runFile("sudo", ["-n", command, ...args]); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | async function readFileWithSudo(path: string): Promise<string | null> { |
| 62 | try { |
no test coverage detected