Comparing version 1.0.3 to 1.0.5
@@ -5,3 +5,3 @@ { | ||
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.", | ||
"version": "1.0.3", | ||
"version": "1.0.5", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
29
which.js
@@ -30,4 +30,6 @@ module.exports = which | ||
function which (cmd, cb) { | ||
if (cmd.charAt(0) === "/") return cb(null, cmd) | ||
if (isAbsolute(cmd)) return cb(null, cmd) | ||
var pathEnv = (process.env.PATH || "").split(COLON) | ||
@@ -38,2 +40,3 @@ , pathExt = [""] | ||
pathExt = (process.env.PATHEXT || ".EXE").split(COLON) | ||
if (cmd.indexOf(".") !== -1) pathExt.unshift("") | ||
} | ||
@@ -62,5 +65,4 @@ //console.error("pathEnv", pathEnv) | ||
function whichSync (cmd) { | ||
if (cmd.charAt(0) === "/") return cmd | ||
if (isAbsolute(cmd)) return cmd | ||
var pathEnv = (process.env.PATH || "").split(COLON) | ||
@@ -71,2 +73,3 @@ , pathExt = [""] | ||
pathExt = (process.env.PATHEXT || ".EXE").split(COLON) | ||
if (cmd.indexOf(".") !== -1) pathExt.unshift("") | ||
} | ||
@@ -86,1 +89,21 @@ for (var i = 0, l = pathEnv.length; i < l; i ++) { | ||
} | ||
var isAbsolute = process.platform === "win32" ? absWin : absUnix | ||
function absWin (p) { | ||
if (absUnix(p)) return true | ||
// pull off the device/UNC bit from a windows path. | ||
// from node's lib/path.js | ||
var splitDeviceRe = | ||
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?/ | ||
, result = splitDeviceRe.exec(p) | ||
, device = result[1] || '' | ||
, isUnc = device && device.charAt(1) !== ':' | ||
, isAbsolute = !!result[2] || isUnc // UNC paths are always absolute | ||
return isAbsolute | ||
} | ||
function absUnix (p) { | ||
return p.charAt(0) === "/" || p === "" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5017
93
0