which.js 323 B

12345678910111213141516
  1. const which = require('which')
  2. let gitPath
  3. try {
  4. gitPath = which.sync('git')
  5. } catch (e) {}
  6. module.exports = (opts = {}) => {
  7. if (opts.git) {
  8. return opts.git
  9. }
  10. if (!gitPath || opts.git === false) {
  11. return Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' })
  12. }
  13. return gitPath
  14. }