UNPKG

415 BJavaScriptView Raw
1'use strict'
2
3const debug = require('debug')('lint-staged:git')
4const execa = require('execa')
5
6module.exports = async function execGit(cmd, options = {}) {
7 debug('Running git command', cmd)
8 try {
9 const { stdout } = await execa('git', [].concat(cmd), {
10 ...options,
11 all: true,
12 cwd: options.cwd || process.cwd(),
13 })
14 return stdout
15 } catch ({ all }) {
16 throw new Error(all)
17 }
18}