codekingpro/portable-devtools
114k
1const which = require('which')
2
3let gitPath
4try {
5 gitPath = which.sync('git')
6} catch {
7 // ignore errors
8}
9
10module.exports = (opts = {}) => {
11 if (opts.git) {
12 return opts.git
13 }
14 if (!gitPath || opts.git === false) {
15 return Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' })
16 }
17 return gitPath
18}
19 