MCPcopy
hub / github.com/loopbackio/loopback-next / git

Function git

packages/cli/generators/copyright/git.js:20–44  ·  view source on GitHub ↗

* Run a git command * @param {string} cwd - Current directory to run the command * @param {...any} args - Args for the git command

(cwd, ...args)

Source from the content-addressed store, hash-verified

18 * @param {...any} args - Args for the git command
19 */
20async 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

Callers 3

getYearsFunction · 0.70

Calls 4

getMethod · 0.65
valueMethod · 0.65
setMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected