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

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

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