Update the bundled node-which to v1.0.5.

This commit is contained in:
Nathan Rajlich 2012-03-03 19:10:36 -08:00
parent 473cb0c2d6
commit 05da9f372b
2 changed files with 27 additions and 4 deletions

2
node_modules/which/package.json generated vendored
View file

@ -2,7 +2,7 @@
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)", "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"name": "which", "name": "which",
"description": "Like which(1) unix command. Find the first instance of an executable in the PATH.", "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": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/isaacs/node-which.git" "url": "git://github.com/isaacs/node-which.git"

29
node_modules/which/which.js generated vendored
View file

@ -27,13 +27,16 @@ if (process.platform == "win32") {
} }
} }
function which (cmd, cb) { 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) var pathEnv = (process.env.PATH || "").split(COLON)
, pathExt = [""] , pathExt = [""]
if (process.platform === "win32") { if (process.platform === "win32") {
pathEnv.push(process.cwd()) pathEnv.push(process.cwd())
pathExt = (process.env.PATHEXT || ".EXE").split(COLON) pathExt = (process.env.PATHEXT || ".EXE").split(COLON)
if (cmd.indexOf(".") !== -1) pathExt.unshift("")
} }
//console.error("pathEnv", pathEnv) //console.error("pathEnv", pathEnv)
;(function F (i, l) { ;(function F (i, l) {
@ -57,14 +60,14 @@ function which (cmd, cb) {
})(0, pathEnv.length) })(0, pathEnv.length)
} }
function whichSync (cmd) { function whichSync (cmd) {
if (cmd.charAt(0) === "/") return cmd if (isAbsolute(cmd)) return cmd
var pathEnv = (process.env.PATH || "").split(COLON) var pathEnv = (process.env.PATH || "").split(COLON)
, pathExt = [""] , pathExt = [""]
if (process.platform === "win32") { if (process.platform === "win32") {
pathEnv.push(process.cwd()) pathEnv.push(process.cwd())
pathExt = (process.env.PATHEXT || ".EXE").split(COLON) pathExt = (process.env.PATHEXT || ".EXE").split(COLON)
if (cmd.indexOf(".") !== -1) pathExt.unshift("")
} }
for (var i = 0, l = pathEnv.length; i < l; i ++) { for (var i = 0, l = pathEnv.length; i < l; i ++) {
var p = path.join(pathEnv[i], cmd) var p = path.join(pathEnv[i], cmd)
@ -79,3 +82,23 @@ function whichSync (cmd) {
} }
throw new Error("not found: "+cmd) throw new Error("not found: "+cmd)
} }
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 === ""
}