1 | 'use strict'
|
2 |
|
3 | const debug = require('debug')('lint-staged:git')
|
4 | const execa = require('execa')
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | const NO_SUBMODULE_RECURSE = ['-c', 'submodule.recurse=false']
|
11 |
|
12 | const GIT_GLOBAL_OPTIONS = [...NO_SUBMODULE_RECURSE]
|
13 |
|
14 | module.exports = async function execGit(cmd, options = {}) {
|
15 | debug('Running git command', cmd)
|
16 | try {
|
17 | const { stdout } = await execa('git', GIT_GLOBAL_OPTIONS.concat(cmd), {
|
18 | ...options,
|
19 | all: true,
|
20 | cwd: options.cwd || process.cwd(),
|
21 | })
|
22 | return stdout
|
23 | } catch ({ all }) {
|
24 | throw new Error(all)
|
25 | }
|
26 | }
|
27 |
|
28 |
|
29 | module.exports.GIT_GLOBAL_OPTIONS = GIT_GLOBAL_OPTIONS
|