import { Octokit } from 'octokit'
import { env } from './env.js'
import { execFile } from 'child_process'
import { promisify } from 'util'
const pexec = promisify(execFile)
export async function runGit(args: string[], cwd = process.cwd()) {
const { stdout } = await pexec('git', ['--no-pager', ...args], {
cwd,
maxBuffer: 1024 * 1024 * 20,
})
return stdout.trim()
}
export function getOctokit() {
const token = env('GITHUB_TOKEN')
if (!token) {
throw new Error('Missing GITHUB_TOKEN env')
}
return new Octokit({ auth: token })
}