From 9ca9b6144a95a91a6a0db23eef542b6f2fa2bb81 Mon Sep 17 00:00:00 2001 From: Tingluo Huang Date: Mon, 5 Oct 2015 14:52:26 -0400 Subject: [PATCH] Make sure Which() on Windows platform always return the command with extension. --- src/which.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/which.js b/src/which.js index 6d82151..4ea7d03 100644 --- a/src/which.js +++ b/src/which.js @@ -44,10 +44,6 @@ function _which(options, cmd) { return; // already found it var attempt = path.resolve(dir + '/' + cmd); - if (checkPath(attempt)) { - where = attempt; - return; - } if (common.platform === 'win') { var baseAttempt = attempt; @@ -56,17 +52,22 @@ function _which(options, cmd) { where = attempt; return; } - attempt = baseAttempt + '.cmd'; - if (checkPath(attempt)) { - where = attempt; - return; - } attempt = baseAttempt + '.bat'; if (checkPath(attempt)) { where = attempt; return; } - } // if 'win' + attempt = baseAttempt + '.cmd'; + if (checkPath(attempt)) { + where = attempt; + return; + } + } else { + if (checkPath(attempt)) { + where = attempt; + return; + } + } }); }