Skip to content

Commit

Permalink
fix: Remove unnecessary which dependency and code block in findBin.js
Browse files Browse the repository at this point in the history
Apparently, `npm-which` already covers this for us so no need to implement $PATH lookup
  • Loading branch information
okonet committed Mar 13, 2017
1 parent 56a8562 commit 3acd6c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
"listr": "^0.11.0",
"minimatch": "^3.0.0",
"npm-which": "^3.0.1",
"staged-git-files": "0.0.4",
"which": "^1.2.11"
"staged-git-files": "0.0.4"
},
"devDependencies": {
"babel-core": "^6.10.4",
Expand Down
11 changes: 3 additions & 8 deletions src/findBin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

const npmWhich = require('npm-which')(process.cwd())
const which = require('which')

module.exports = function findBin(cmd, paths, packageJson, options) {
const defaultArgs = ['--'].concat(paths)
Expand Down Expand Up @@ -46,15 +45,11 @@ module.exports = function findBin(cmd, paths, packageJson, options) {
const args = parts.splice(1)

try {
/* Firstly, try to resolve the bin in local node_modules/.bin */
/* npm-which tries to resolve the bin in local node_modules/.bin */
/* and if this fails it look in $PATH */
bin = npmWhich.sync(bin)
} catch (err) {
/* If this fails, try to resolve binary in $PATH */
try {
bin = which.sync(bin)
} catch (error) {
throw new Error(`${ bin } could not be found. Try \`npm install ${ bin }\`.`)
}
throw new Error(`${ bin } could not be found. Try \`npm install ${ bin }\`.`)
}

return {
Expand Down

0 comments on commit 3acd6c7

Please sign in to comment.