backdd / src /utils.ts
yamxxx1's picture
Upload 117 files
a2fe16e verified
Raw
History Blame Contribute Delete
521 Bytes
import {execSync, ExecSyncOptions} from 'child_process'
import {als} from './context'
/**
* Executes a shell command using the current context's working directory.
* Thread-safe for Probot.
*/
export const prixExec = (
command: string,
options: ExecSyncOptions = {}
): string => {
const context = als.getStore()
const cwd = options.cwd || context?.workingDir || process.cwd()
const result = execSync(command, {
...options,
cwd,
encoding: 'utf8'
})
return result ? result.toString() : ''
}