1 |
|
2 |
|
3 | const debug = require('debug')('lint-staged:git')
|
4 | const execa = require('execa')
|
5 |
|
6 | module.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 | }
|