node/deps/npm/node_modules/@npmcli/git/lib/which.js
Ruy Adorno 94405650ae
deps: upgrade npm to 7.10.0
PR-URL: https://github.com/nodejs/node/pull/38254
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2021-04-16 21:03:58 -04:00

17 lines
323 B
JavaScript

const which = require('which')
let gitPath
try {
gitPath = which.sync('git')
} catch (e) {}
module.exports = (opts = {}) => {
if (opts.git) {
return opts.git
}
if (!gitPath || opts.git === false) {
return Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' })
}
return gitPath
}