* Run a git command * @param {string} cwd - Current directory to run the command * @param {...any} args - Args for the git command
(cwd, ...args)
| 18 | * @param {...any} args - Args for the git command |
| 19 | */ |
| 20 | async function git(cwd, ...args) { |
| 21 | const cmd = 'git ' + util.format(...args); |
| 22 | const key = `${cwd}:${cmd}`; |
| 23 | debug('Running %s in directory', cmd, cwd); |
| 24 | if (cache.has(key)) { |
| 25 | return cache.get(key); |
| 26 | } |
| 27 | return new Promise((resolve, reject) => { |
| 28 | cp.exec(cmd, {maxBuffer: 1024 * 1024, cwd}, (err, stdout) => { |
| 29 | stdout = _(stdout || '') |
| 30 | .split(/[\r\n]+/g) |
| 31 | .map(_.trim) |
| 32 | .filter() |
| 33 | .value(); |
| 34 | if (err) { |
| 35 | // reject(err); |
| 36 | resolve([]); |
| 37 | } else { |
| 38 | cache.set(key, stdout); |
| 39 | debug('Stdout', stdout); |
| 40 | resolve(stdout); |
| 41 | } |
| 42 | }); |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Inspect years for a given file based on git history |
no test coverage detected