Comparing version 1.1.2 to 1.2.0
@@ -5,3 +5,3 @@ { | ||
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"repository": { | ||
@@ -20,3 +20,3 @@ "type": "git", | ||
"rimraf": "^2.3.3", | ||
"tap": "^1.0.2" | ||
"tap": "^2.0.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "scripts": { |
@@ -34,2 +34,8 @@ # which | ||
If you pass in options, then `path` and `pathExt` are relevant. | ||
You may pass an options object as the second argument. | ||
- `path`: Use instead of the `PATH` environment variable. | ||
- `pathExt`: Use instead of the `PATHEXT` environment variable. | ||
- `all`: Return all matches, instead of just the first one. Note that | ||
this means the function returns an array of strings instead of a | ||
single string. |
25
which.js
@@ -71,5 +71,11 @@ module.exports = which | ||
var pathExt = info.ext | ||
var found = [] | ||
;(function F (i, l) { | ||
if (i === l) return cb(new Error('not found: '+cmd)) | ||
if (i === l) { | ||
if (opt.all && found.length) | ||
return cb(null, found) | ||
else | ||
return cb(new Error('not found: '+cmd)) | ||
} | ||
var p = path.resolve(pathEnv[i], cmd) | ||
@@ -83,3 +89,6 @@ ;(function E (ii, ll) { | ||
isExe(stat.mode, stat.uid, stat.gid)) { | ||
return cb(null, p + ext) | ||
if (opt.all) | ||
found.push(p + ext) | ||
else | ||
return cb(null, p + ext) | ||
} | ||
@@ -98,2 +107,3 @@ return E(ii + 1, ll) | ||
var pathExt = info.ext | ||
var found = [] | ||
@@ -107,4 +117,8 @@ for (var i = 0, l = pathEnv.length; i < l; i ++) { | ||
stat = fs.statSync(cur) | ||
if (stat.isFile() && isExe(stat.mode, stat.uid, stat.gid)) | ||
return cur | ||
if (stat.isFile() && isExe(stat.mode, stat.uid, stat.gid)) { | ||
if (opt.all) | ||
found.push(cur) | ||
else | ||
return cur | ||
} | ||
} catch (ex) {} | ||
@@ -114,3 +128,6 @@ } | ||
if (opt.all && found.length) | ||
return found | ||
throw new Error('not found: '+cmd) | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
11767
8
299
41
16
1