Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-01-13 20:33:27 +0400
committerisaacs <i@izs.me>2012-01-13 20:41:06 +0400
commitc18fe966ddbeb66c8a9b9aa8ab4899166e6986f5 (patch)
tree8650e7575caff9d05e04352b78669dd81d21230d /node_modules/which
parentb7ff884870958221eb52c5a600c101fab4c26781 (diff)
check in node_modules
Diffstat (limited to 'node_modules/which')
-rw-r--r--node_modules/which/LICENSE23
-rw-r--r--node_modules/which/README.md5
-rwxr-xr-xnode_modules/which/bin/which14
-rw-r--r--node_modules/which/package.json17
-rw-r--r--node_modules/which/which.js67
5 files changed, 126 insertions, 0 deletions
diff --git a/node_modules/which/LICENSE b/node_modules/which/LICENSE
new file mode 100644
index 000000000..05a401094
--- /dev/null
+++ b/node_modules/which/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/which/README.md b/node_modules/which/README.md
new file mode 100644
index 000000000..ff1eb531a
--- /dev/null
+++ b/node_modules/which/README.md
@@ -0,0 +1,5 @@
+The "which" util from npm's guts.
+
+Finds the first instance of a specified executable in the PATH
+environment variable. Does not cache the results, so `hash -r` is not
+needed when the PATH changes.
diff --git a/node_modules/which/bin/which b/node_modules/which/bin/which
new file mode 100755
index 000000000..8432ce2f6
--- /dev/null
+++ b/node_modules/which/bin/which
@@ -0,0 +1,14 @@
+#!/usr/bin/env node
+var which = require("../")
+if (process.argv.length < 3) {
+ console.error("Usage: which <thing>")
+ process.exit(1)
+}
+
+which(process.argv[2], function (er, thing) {
+ if (er) {
+ console.error(er.message)
+ process.exit(er.errno || 127)
+ }
+ console.log(thing)
+})
diff --git a/node_modules/which/package.json b/node_modules/which/package.json
new file mode 100644
index 000000000..02990697f
--- /dev/null
+++ b/node_modules/which/package.json
@@ -0,0 +1,17 @@
+{
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "name": "which",
+ "description": "Like which(1) unix command. Find the first instance of an executable in the PATH.",
+ "version": "1.0.2",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/node-which.git"
+ },
+ "main": "which.js",
+ "bin": "./bin/which",
+ "engines": {
+ "node": "*"
+ },
+ "dependencies": {},
+ "devDependencies": {}
+}
diff --git a/node_modules/which/which.js b/node_modules/which/which.js
new file mode 100644
index 000000000..b124ead67
--- /dev/null
+++ b/node_modules/which/which.js
@@ -0,0 +1,67 @@
+module.exports = which
+which.sync = whichSync
+
+var path = require("path")
+ , fs
+ , COLON = process.platform === "win32" ? ";" : ":"
+
+try {
+ fs = require("graceful-fs")
+} catch (ex) {
+ fs = require("fs")
+}
+
+// console.log(process.execPath)
+// console.log(process.argv)
+
+function isExe (mod, uid, gid) {
+ //console.error("isExe?", (mod & 0111).toString(8))
+ var ret = (mod & 0001)
+ || (mod & 0010) && process.getgid && gid === process.getgid()
+ || (mod & 0100) && process.getuid && uid === process.getuid()
+ //console.error("isExe?", ret)
+ return ret
+}
+function which (cmd, cb) {
+ if (cmd.charAt(0) === "/") 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)
+ }
+ //console.error("pathEnv", pathEnv)
+ ;(function F (i, l) {
+ if (i === l) return cb(new Error("not found: "+cmd))
+ var p = path.resolve(pathEnv[i], cmd)
+ ;(function E (ii, ll) {
+ if (ii === ll) return F(i + 1, l)
+ var ext = pathExt[ii]
+ //console.error(p + ext)
+ fs.stat(p + ext, function (er, stat) {
+ if (!er &&
+ stat &&
+ stat.isFile() &&
+ isExe(stat.mode, stat.uid, stat.gid)) {
+ //console.error("yes, exe!", p + ext)
+ return cb(null, p + ext)
+ }
+ return E(ii + 1, ll)
+ })
+ })(0, pathExt.length)
+ })(0, pathEnv.length)
+}
+
+
+function whichSync (cmd) {
+ if (cmd.charAt(0) === "/") return cmd
+ var pathEnv = (process.env.PATH || "").split(COLON)
+ for (var i = 0, l = pathEnv.length; i < l; i ++) {
+ var p = path.join(pathEnv[i], cmd)
+ if (p === process.execPath) return p
+ var stat
+ try { stat = fs.statSync(p) } catch (ex) {}
+ if (stat && isExe(stat.mode, stat.uid, stat.gid)) return p
+ }
+ throw new Error("not found: "+cmd)
+}