Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

which

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

which - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

test/bin.js

4

package.json

@@ -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.

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc