From 3acd6c7b38ca4d95c7dbf4d9f20d8f61a3a44e64 Mon Sep 17 00:00:00 2001 From: Andrey Okonetchnikov Date: Fri, 10 Mar 2017 16:20:04 +0100 Subject: [PATCH] fix: Remove unnecessary `which` dependency and code block in findBin.js Apparently, `npm-which` already covers this for us so no need to implement $PATH lookup --- package.json | 3 +-- src/findBin.js | 11 +++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 2b72c131a..8c1f06dce 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/findBin.js b/src/findBin.js index 1d4b59fb6..f08389cfe 100644 --- a/src/findBin.js +++ b/src/findBin.js @@ -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) @@ -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 {