mirror of
https://github.com/desktop/desktop
synced 2024-10-31 11:07:25 +00:00
16 lines
500 B
TypeScript
16 lines
500 B
TypeScript
|
import { execFile } from 'child_process'
|
||
|
import { promisify } from 'util'
|
||
|
|
||
|
const execFileP = promisify(execFile)
|
||
|
|
||
|
/**
|
||
|
* Helper method for running a shell command and capturing its stdout
|
||
|
*
|
||
|
* Do not pass unsanitized user input to this function! Any input containing
|
||
|
* shell metacharacters may be used to trigger arbitrary command execution.
|
||
|
*/
|
||
|
export const sh = (cmd: string, ...args: string[]) =>
|
||
|
execFileP(cmd, args, { maxBuffer: Infinity, shell: true }).then(
|
||
|
({ stdout }) => stdout
|
||
|
)
|