summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-05-05 22:33:06 -0700
committerisaacs <i@izs.me>2012-05-05 22:33:12 -0700
commit33a9ac6087732da48e7d12ea7f7fbb41926fe46c (patch)
treea914e333e80a3401ce8726355b38f1d636500cb5 /deps/npm/node_modules
parent1858d1c340ca2631e28a32eb542c85ee8f725cac (diff)
downloadnode-new-33a9ac6087732da48e7d12ea7f7fbb41926fe46c.tar.gz
Upgrade npm to 1.1.21
Somehow this got downgraded in the last v0.6 merge. Very strange.
Diffstat (limited to 'deps/npm/node_modules')
-rw-r--r--deps/npm/node_modules/block-stream/package.json4
-rw-r--r--deps/npm/node_modules/fast-list/.npmignore1
-rw-r--r--deps/npm/node_modules/fast-list/.travis.yml4
-rw-r--r--deps/npm/node_modules/fast-list/README.md116
-rw-r--r--deps/npm/node_modules/fast-list/fast-list.js144
-rw-r--r--deps/npm/node_modules/fast-list/package.json20
-rw-r--r--deps/npm/node_modules/fstream/.npmignore4
-rw-r--r--deps/npm/node_modules/fstream/lib/abstract.js5
-rw-r--r--deps/npm/node_modules/fstream/lib/dir-reader.js111
-rw-r--r--deps/npm/node_modules/fstream/lib/dir-writer.js8
-rw-r--r--deps/npm/node_modules/fstream/lib/link-writer.js1
-rw-r--r--deps/npm/node_modules/fstream/lib/proxy-reader.js4
-rw-r--r--deps/npm/node_modules/fstream/lib/reader.js31
-rw-r--r--deps/npm/node_modules/fstream/lib/writer.js218
-rw-r--r--deps/npm/node_modules/fstream/package.json30
-rw-r--r--deps/npm/node_modules/graceful-fs/graceful-fs.js67
-rw-r--r--deps/npm/node_modules/graceful-fs/package.json25
-rw-r--r--deps/npm/node_modules/inherits/LICENSE30
-rw-r--r--deps/npm/node_modules/inherits/package.json52
-rw-r--r--deps/npm/node_modules/minimatch/README.md14
-rw-r--r--deps/npm/node_modules/minimatch/minimatch.js67
-rw-r--r--deps/npm/node_modules/minimatch/package.json29
-rw-r--r--deps/npm/node_modules/mkdirp/README.markdown37
-rw-r--r--deps/npm/node_modules/mkdirp/index.js67
-rw-r--r--deps/npm/node_modules/mkdirp/package.json63
-rw-r--r--deps/npm/node_modules/read/lib/read.js16
-rw-r--r--deps/npm/node_modules/read/package.json18
-rw-r--r--deps/npm/node_modules/request/README.md4
-rw-r--r--deps/npm/node_modules/request/forever.js21
-rw-r--r--deps/npm/node_modules/request/main.js947
-rw-r--r--deps/npm/node_modules/request/mimetypes.js10
-rw-r--r--deps/npm/node_modules/request/oauth.js2
-rw-r--r--deps/npm/node_modules/request/package.json58
-rw-r--r--deps/npm/node_modules/request/vendor/cookie/index.js25
-rw-r--r--deps/npm/node_modules/rimraf/AUTHORS1
-rw-r--r--deps/npm/node_modules/rimraf/README.md13
-rw-r--r--deps/npm/node_modules/rimraf/fiber.js86
-rw-r--r--deps/npm/node_modules/rimraf/package.json3
-rw-r--r--deps/npm/node_modules/rimraf/rimraf.js106
-rw-r--r--deps/npm/node_modules/tar/lib/extract.js14
-rw-r--r--deps/npm/node_modules/tar/package.json24
-rw-r--r--deps/npm/node_modules/which/package.json25
-rw-r--r--deps/npm/node_modules/which/which.js71
43 files changed, 1534 insertions, 1062 deletions
diff --git a/deps/npm/node_modules/block-stream/package.json b/deps/npm/node_modules/block-stream/package.json
index 203961a144..1080b6bc9a 100644
--- a/deps/npm/node_modules/block-stream/package.json
+++ b/deps/npm/node_modules/block-stream/package.json
@@ -2,13 +2,13 @@
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"name": "block-stream",
"description": "a stream of blocks",
- "version": "0.0.4",
+ "version": "0.0.5",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/block-stream.git"
},
"engines": {
- "node": "0.4 || ~0.5.8 || 0.6"
+ "node": "0.4 || ~0.5.8 || 0.6 || 0.7"
},
"main": "block-stream.js",
"dependencies": {
diff --git a/deps/npm/node_modules/fast-list/.npmignore b/deps/npm/node_modules/fast-list/.npmignore
deleted file mode 100644
index c2658d7d1b..0000000000
--- a/deps/npm/node_modules/fast-list/.npmignore
+++ /dev/null
@@ -1 +0,0 @@
-node_modules/
diff --git a/deps/npm/node_modules/fast-list/.travis.yml b/deps/npm/node_modules/fast-list/.travis.yml
deleted file mode 100644
index f1d0f13c8a..0000000000
--- a/deps/npm/node_modules/fast-list/.travis.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-language: node_js
-node_js:
- - 0.4
- - 0.6
diff --git a/deps/npm/node_modules/fast-list/README.md b/deps/npm/node_modules/fast-list/README.md
deleted file mode 100644
index 88a842ef0e..0000000000
--- a/deps/npm/node_modules/fast-list/README.md
+++ /dev/null
@@ -1,116 +0,0 @@
-# The Problem
-
-You've got some thing where you need to push a bunch of stuff into a
-queue and then shift it out. Or, maybe it's a stack, and you're just
-pushing and popping it.
-
-Arrays work for this, but are a bit costly performance-wise.
-
-# The Solution
-
-A linked-list implementation that takes advantage of what v8 is good at:
-creating objects with a known shape.
-
-This is faster for this use case. How much faster? About 50%.
-
- $ node bench.js
- benchmarking /Users/isaacs/dev-src/js/fast-list/bench.js
- Please be patient.
- { node: '0.6.2-pre',
- v8: '3.6.6.8',
- ares: '1.7.5-DEV',
- uv: '0.1',
- openssl: '0.9.8l' }
- Scores: (bigger is better)
-
- new FastList()
- Raw:
- > 22556.39097744361
- > 23054.755043227666
- > 22770.398481973436
- > 23414.634146341465
- > 23099.133782483157
- Average (mean) 22979.062486293868
-
- []
- Raw:
- > 12195.121951219513
- > 12184.508268059182
- > 12173.91304347826
- > 12216.404886561955
- > 12184.508268059182
- Average (mean) 12190.891283475617
-
- new Array()
- Raw:
- > 12131.715771230503
- > 12184.508268059182
- > 12216.404886561955
- > 12195.121951219513
- > 11940.298507462687
- Average (mean) 12133.609876906768
-
- Winner: new FastList()
- Compared with next highest ([]), it's:
- 46.95% faster
- 1.88 times as fast
- 0.28 order(s) of magnitude faster
-
- Compared with the slowest (new Array()), it's:
- 47.2% faster
- 1.89 times as fast
- 0.28 order(s) of magnitude faster
-
-This lacks a lot of features that arrays have:
-
-1. You can't specify the size at the outset.
-2. It's not indexable.
-3. There's no join, concat, etc.
-
-If any of this matters for your use case, you're probably better off
-using an Array object.
-
-## Installing
-
-```
-npm install fast-list
-```
-
-## API
-
-```javascript
-var FastList = require("fast-list")
-var list = new FastList()
-list.push("foo")
-list.unshift("bar")
-list.push("baz")
-console.log(list.length) // 2
-console.log(list.pop()) // baz
-console.log(list.shift()) // bar
-console.log(list.shift()) // foo
-```
-
-### Methods
-
-* `push`: Just like Array.push, but only can take a single entry
-* `pop`: Just like Array.pop
-* `shift`: Just like Array.shift
-* `unshift`: Just like Array.unshift, but only can take a single entry
-* `drop`: Drop all entries
-* `item(n)`: Retrieve the nth item in the list. This involves a walk
- every time. It's very slow. If you find yourself using this,
- consider using a normal Array instead.
-* `map(fn, thisp)`: Like `Array.prototype.map`. Returns a new FastList.
-* `reduce(fn, startValue, thisp)`: Like `Array.prototype.reduce`
-* `forEach(fn, this)`: Like `Array.prototype.forEach`
-* `filter(fn, thisp)`: Like `Array.prototype.filter`. Returns a new
- FastList.
-* `slice(start, end)`: Retrieve an array of the items at this position.
- This involves a walk every time. It's very slow. If you find
- yourself using this, consider using a normal Array instead.
-
-### Members
-
-* `length`: The number of things in the list. Note that, unlike
- Array.length, this is not a getter/setter, but rather a counter that
- is internally managed. Setting it can only cause harm.
diff --git a/deps/npm/node_modules/fast-list/fast-list.js b/deps/npm/node_modules/fast-list/fast-list.js
deleted file mode 100644
index 692db0df8f..0000000000
--- a/deps/npm/node_modules/fast-list/fast-list.js
+++ /dev/null
@@ -1,144 +0,0 @@
-;(function() { // closure for web browsers
-
-function Item (data, prev, next) {
- this.next = next
- if (next) next.prev = this
- this.prev = prev
- if (prev) prev.next = this
- this.data = data
-}
-
-function FastList () {
- if (!(this instanceof FastList)) return new FastList
- this._head = null
- this._tail = null
- this.length = 0
-}
-
-FastList.prototype =
-{ push: function (data) {
- this._tail = new Item(data, this._tail, null)
- if (!this._head) this._head = this._tail
- this.length ++
- }
-
-, pop: function () {
- if (this.length === 0) return undefined
- var t = this._tail
- this._tail = t.prev
- if (t.prev) {
- t.prev = this._tail.next = null
- }
- this.length --
- if (this.length === 1) this._head = this._tail
- else if (this.length === 0) this._head = this._tail = null
- return t.data
- }
-
-, unshift: function (data) {
- this._head = new Item(data, null, this._head)
- if (!this._tail) this._tail = this._head
- this.length ++
- }
-
-, shift: function () {
- if (this.length === 0) return undefined
- var h = this._head
- this._head = h.next
- if (h.next) {
- h.next = this._head.prev = null
- }
- this.length --
- if (this.length === 1) this._tail = this._head
- else if (this.length === 0) this._head = this._tail = null
- return h.data
- }
-
-, item: function (n) {
- if (n < 0) n = this.length + n
- var h = this._head
- while (n-- > 0 && h) h = h.next
- return h ? h.data : undefined
- }
-
-, slice: function (n, m) {
- if (!n) n = 0
- if (!m) m = this.length
- if (m < 0) m = this.length + m
- if (n < 0) n = this.length + n
-
- if (m === n) {
- return []
- }
-
- if (m < n) {
- throw new Error("invalid offset: "+n+","+m+" (length="+this.length+")")
- }
-
- var len = m - n
- , ret = new Array(len)
- , i = 0
- , h = this._head
- while (n-- > 0 && h) h = h.next
- while (i < len && h) {
- ret[i++] = h.data
- h = h.next
- }
- return ret
- }
-
-, drop: function () {
- FastList.call(this)
- }
-
-, forEach: function (fn, thisp) {
- var p = this._head
- , i = 0
- , len = this.length
- while (i < len && p) {
- fn.call(thisp || this, p.data, i, this)
- p = p.next
- i ++
- }
- }
-
-, map: function (fn, thisp) {
- var n = new FastList()
- this.forEach(function (v, i, me) {
- n.push(fn.call(thisp || me, v, i, me))
- })
- return n
- }
-
-, filter: function (fn, thisp) {
- var n = new FastList()
- this.forEach(function (v, i, me) {
- if (fn.call(thisp || me, v, i, me)) n.push(v)
- })
- return n
- }
-
-, reduce: function (fn, val, thisp) {
- var i = 0
- , p = this._head
- , len = this.length
- if (!val) {
- i = 1
- val = p && p.data
- p = p && p.next
- }
- while (i < len && p) {
- val = fn.call(thisp || this, val, p.data, this)
- i ++
- p = p.next
- }
- return val
- }
-}
-
-if ("undefined" !== typeof(exports)) module.exports = FastList
-else if ("function" === typeof(define) && define.amd) {
- define("FastList", function() { return FastList })
-} else (function () { return this })().FastList = FastList
-
-})()
diff --git a/deps/npm/node_modules/fast-list/package.json b/deps/npm/node_modules/fast-list/package.json
deleted file mode 100644
index 9bcc6b4133..0000000000
--- a/deps/npm/node_modules/fast-list/package.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
- "name": "fast-list",
- "description": "A fast linked list (good for queues, stacks, etc.)",
- "version": "1.0.2",
- "repository": {
- "type": "git",
- "url": "git://github.com/isaacs/fast-list.git"
- },
- "main": "fast-list.js",
- "dependencies": {},
- "devDependencies": {
- "bench": "~0.3.2",
- "tap": "~0.1.0"
- },
- "scripts": {
- "test": "tap test.js",
- "bench": "node bench.js"
- }
-}
diff --git a/deps/npm/node_modules/fstream/.npmignore b/deps/npm/node_modules/fstream/.npmignore
index 66880db1ab..494272a81a 100644
--- a/deps/npm/node_modules/fstream/.npmignore
+++ b/deps/npm/node_modules/fstream/.npmignore
@@ -1,3 +1,5 @@
.*.swp
-examples/deep-copy
node_modules/
+examples/deep-copy/
+examples/path/
+examples/filter-copy/
diff --git a/deps/npm/node_modules/fstream/lib/abstract.js b/deps/npm/node_modules/fstream/lib/abstract.js
index add48b945d..5675d4a1b1 100644
--- a/deps/npm/node_modules/fstream/lib/abstract.js
+++ b/deps/npm/node_modules/fstream/lib/abstract.js
@@ -20,6 +20,11 @@ Abstract.prototype.on = function (ev, fn) {
return this
}
+Abstract.prototype.abort = function () {
+ this._aborted = true
+ this.emit("abort")
+}
+
Abstract.prototype.destroy = function () {}
Abstract.prototype.warn = function (msg, code) {
diff --git a/deps/npm/node_modules/fstream/lib/dir-reader.js b/deps/npm/node_modules/fstream/lib/dir-reader.js
index ab990d1501..6a418c0bc1 100644
--- a/deps/npm/node_modules/fstream/lib/dir-reader.js
+++ b/deps/npm/node_modules/fstream/lib/dir-reader.js
@@ -11,6 +11,7 @@ var fs = require("graceful-fs")
, mkdir = require("mkdirp")
, path = require("path")
, Reader = require("./reader.js")
+ , assert = require("assert").ok
inherits(DirReader, Reader)
@@ -24,25 +25,42 @@ function DirReader (props) {
throw new Error("Non-directory type "+ props.type)
}
- me._entries = null
+ me.entries = null
me._index = -1
me._paused = false
me._length = -1
+ if (props.sort) {
+ this.sort = props.sort
+ }
+
Reader.call(this, props)
}
DirReader.prototype._getEntries = function () {
var me = this
+
+ // race condition. might pause() before calling _getEntries,
+ // and then resume, and try to get them a second time.
+ if (me._gotEntries) return
+ me._gotEntries = true
+
fs.readdir(me._path, function (er, entries) {
if (er) return me.error(er)
- me._entries = entries
- me._length = entries.length
- // console.error("DR %s sort =", me.path, me.props.sort)
- if (typeof me.props.sort === "function") {
- me._entries.sort(me.props.sort)
+
+ me.entries = entries
+
+ me.emit("entries", entries)
+ if (me._paused) me.once("resume", processEntries)
+ else processEntries()
+
+ function processEntries () {
+ me._length = me.entries.length
+ if (typeof me.sort === "function") {
+ me.entries = me.entries.sort(me.sort.bind(me))
+ }
+ me._read()
}
- me._read()
})
}
@@ -50,7 +68,7 @@ DirReader.prototype._getEntries = function () {
DirReader.prototype._read = function () {
var me = this
- if (!me._entries) return me._getEntries()
+ if (!me.entries) return me._getEntries()
if (me._paused || me._currentEntry || me._aborted) {
// console.error("DR paused=%j, current=%j, aborted=%j", me._paused, !!me._currentEntry, me._aborted)
@@ -58,7 +76,7 @@ DirReader.prototype._read = function () {
}
me._index ++
- if (me._index >= me._length) {
+ if (me._index >= me.entries.length) {
if (!me._ended) {
me._ended = true
me.emit("end")
@@ -70,20 +88,26 @@ DirReader.prototype._read = function () {
// ok, handle this one, then.
// save creating a proxy, by stat'ing the thing now.
- var p = path.resolve(me._path, me._entries[me._index])
+ var p = path.resolve(me._path, me.entries[me._index])
+ assert(p !== me._path)
+ assert(me.entries[me._index])
+
// set this to prevent trying to _read() again in the stat time.
me._currentEntry = p
fs[ me.props.follow ? "stat" : "lstat" ](p, function (er, stat) {
if (er) return me.error(er)
- var entry = Reader({ path: p
- , depth: me.depth + 1
- , root: me.root || me._proxy || me
- , parent: me._proxy || me
- , follow: me.follow
- , filter: me.filter
- , sort: me.props.sort
- }, stat)
+ var who = me._proxy || me
+
+ stat.path = p
+ stat.basename = path.basename(p)
+ stat.dirname = path.dirname(p)
+ var childProps = me.getChildProps.call(who, stat)
+ childProps.path = p
+ childProps.basename = path.basename(p)
+ childProps.dirname = path.dirname(p)
+
+ var entry = Reader(childProps, stat)
// console.error("DR Entry", p, stat.size)
@@ -94,17 +118,25 @@ DirReader.prototype._read = function () {
// This nomenclature is not completely final.
entry.on("pause", function (who) {
- if (!me._paused) {
+ if (!me._paused && !entry._disowned) {
me.pause(who)
}
})
entry.on("resume", function (who) {
- if (me._paused) {
+ if (me._paused && !entry._disowned) {
me.resume(who)
}
})
+ entry.on("stat", function (props) {
+ me.emit("_entryStat", entry, props)
+ if (entry._aborted) return
+ if (entry._paused) entry.once("resume", function () {
+ me.emit("entryStat", entry, props)
+ })
+ })
+
entry.on("ready", function EMITCHILD () {
// console.error("DR emit child", entry._path)
if (me._paused) {
@@ -122,23 +154,25 @@ DirReader.prototype._read = function () {
if (entry.type === "Socket") {
me.emit("socket", entry)
} else {
- me.emit("entry", entry)
- me.emit("child", entry)
+ me.emitEntry(entry)
}
})
var ended = false
entry.on("close", onend)
+ entry.on("disown", onend)
function onend () {
if (ended) return
ended = true
me.emit("childEnd", entry)
me.emit("entryEnd", entry)
me._currentEntry = null
- me._read()
+ if (!me._paused) {
+ me._read()
+ }
}
- // XXX Make this work in node.
+ // XXX Remove this. Works in node as of 0.6.2 or so.
// Long filenames should not break stuff.
entry.on("error", function (er) {
if (entry._swallowErrors) {
@@ -160,6 +194,26 @@ DirReader.prototype._read = function () {
})
}
+DirReader.prototype.disown = function (entry) {
+ entry.emit("beforeDisown")
+ entry._disowned = true
+ entry.parent = entry.root = null
+ if (entry === this._currentEntry) {
+ this._currentEntry = null
+ }
+ entry.emit("disown")
+}
+
+DirReader.prototype.getChildProps = function (stat) {
+ return { depth: this.depth + 1
+ , root: this.root || this
+ , parent: this
+ , follow: this.follow
+ , filter: this.filter
+ , sort: this.props.sort
+ }
+}
+
DirReader.prototype.pause = function (who) {
var me = this
if (me._paused) return
@@ -185,8 +239,11 @@ DirReader.prototype.resume = function (who) {
}
if (me._currentEntry) {
- if (me._currentEntry.resume) {
- me._currentEntry.resume(who)
- }
+ if (me._currentEntry.resume) me._currentEntry.resume(who)
} else me._read()
}
+
+DirReader.prototype.emitEntry = function (entry) {
+ this.emit("entry", entry)
+ this.emit("child", entry)
+}
diff --git a/deps/npm/node_modules/fstream/lib/dir-writer.js b/deps/npm/node_modules/fstream/lib/dir-writer.js
index 01920244c1..7073b883ea 100644
--- a/deps/npm/node_modules/fstream/lib/dir-writer.js
+++ b/deps/npm/node_modules/fstream/lib/dir-writer.js
@@ -37,6 +37,7 @@ DirWriter.prototype._create = function () {
// ready to start getting entries!
me.ready = true
me.emit("ready")
+ me._process()
})
}
@@ -99,7 +100,9 @@ DirWriter.prototype._process = function () {
// don't allow recursive copying
var p = entry
do {
- if (p._path === me.root._path || p._path === me._path) {
+ var pp = p._path || p.path
+ if (pp === me.root._path || pp === me._path ||
+ (pp && pp.indexOf(me._path) === 0)) {
// console.error("DW Exit (recursive)", entry.basename, me._path)
me._processing = false
if (entry._collected) entry.pipe()
@@ -122,6 +125,9 @@ DirWriter.prototype._process = function () {
// get rid of any ../../ shenanigans
props.path = path.join(me.path, path.join("/", p))
+ // if i have a filter, the child should inherit it.
+ props.filter = me.filter
+
// all the rest of the stuff, copy over from the source.
Object.keys(entry.props).forEach(function (k) {
if (!props.hasOwnProperty(k)) {
diff --git a/deps/npm/node_modules/fstream/lib/link-writer.js b/deps/npm/node_modules/fstream/lib/link-writer.js
index 8a98163800..5c8f1e7012 100644
--- a/deps/npm/node_modules/fstream/lib/link-writer.js
+++ b/deps/npm/node_modules/fstream/lib/link-writer.js
@@ -4,7 +4,6 @@ module.exports = LinkWriter
var fs = require("graceful-fs")
, Writer = require("./writer.js")
, inherits = require("inherits")
- , collect = require("./collect.js")
, path = require("path")
, rimraf = require("rimraf")
diff --git a/deps/npm/node_modules/fstream/lib/proxy-reader.js b/deps/npm/node_modules/fstream/lib/proxy-reader.js
index f99b28fe55..a0ece34a26 100644
--- a/deps/npm/node_modules/fstream/lib/proxy-reader.js
+++ b/deps/npm/node_modules/fstream/lib/proxy-reader.js
@@ -59,7 +59,11 @@ ProxyReader.prototype._addProxy = function (proxy) {
, "close"
, "linkpath"
, "entry"
+ , "entryEnd"
+ , "child"
+ , "childEnd"
, "warn"
+ , "stat"
].forEach(function (ev) {
// console.error("~~ proxy event", ev, me.path)
proxy.on(ev, me.emit.bind(me, ev))
diff --git a/deps/npm/node_modules/fstream/lib/reader.js b/deps/npm/node_modules/fstream/lib/reader.js
index 6aa67ada78..e4e1b482cf 100644
--- a/deps/npm/node_modules/fstream/lib/reader.js
+++ b/deps/npm/node_modules/fstream/lib/reader.js
@@ -187,19 +187,38 @@ Reader.prototype._stat = function (currentStat) {
// if the filter doesn't pass, then just skip over this one.
// still have to emit end so that dir-walking can move on.
if (me.filter) {
+ var who = me._proxy || me
// special handling for ProxyReaders
- if (!me.filter.call(me._proxy || me)) {
- me._aborted = true
+ if (!me.filter.call(who, who, props)) {
+ if (!me._disowned) {
+ me.abort()
+ me.emit("end")
+ me.emit("close")
+ }
+ return
+ }
+ }
+
+ // last chance to abort or disown before the flow starts!
+ var events = ["_stat", "stat", "ready"]
+ var e = 0
+ ;(function go () {
+ if (me._aborted) {
me.emit("end")
me.emit("close")
return
}
- }
- me.emit("ready", props)
+ if (me._paused) {
+ me.once("resume", go)
+ return
+ }
- // if it's a directory, then we'll be emitting "entry" events.
- me._read()
+ var ev = events[e ++]
+ if (!ev) return me._read()
+ me.emit(ev, props)
+ go()
+ })()
}
}
diff --git a/deps/npm/node_modules/fstream/lib/writer.js b/deps/npm/node_modules/fstream/lib/writer.js
index dde29fd7b2..243f6b64e8 100644
--- a/deps/npm/node_modules/fstream/lib/writer.js
+++ b/deps/npm/node_modules/fstream/lib/writer.js
@@ -98,6 +98,8 @@ function Writer (props, current) {
me._buffer = []
me.ready = false
+ me.filter = typeof props.filter === "function" ? props.filter: null
+
// start the ball rolling.
// this checks what's there already, and then calls
// me._create() to call the impl-specific creation stuff.
@@ -121,11 +123,19 @@ Writer.prototype._stat = function (current) {
var me = this
, props = me.props
, stat = props.follow ? "stat" : "lstat"
+ , who = me._proxy || me
if (current) statCb(null, current)
else fs[stat](me._path, statCb)
function statCb (er, current) {
+ if (me.filter && !me.filter.call(who, who, current)) {
+ me._aborted = true
+ me.emit("end")
+ me.emit("close")
+ return
+ }
+
// if it's not there, great. We'll just create it.
// if it is there, then we'll need to change whatever differs
if (er || !current) {
@@ -156,13 +166,83 @@ function create (me) {
// XXX Need to clobber non-dirs that are in the way,
// unless { clobber: false } in the props.
- mkdir(path.dirname(me._path), Writer.dirmode, function (er) {
+ mkdir(path.dirname(me._path), Writer.dirmode, function (er, made) {
// console.error("W created", path.dirname(me._path), er)
if (er) return me.error(er)
- me._create()
+
+ // later on, we have to set the mode and owner for these
+ me._madeDir = made
+ return me._create()
})
}
+function endChmod (me, want, current, path, cb) {
+ var wantMode = want.mode
+ , chmod = want.follow || me.type !== "SymbolicLink"
+ ? "chmod" : "lchmod"
+
+ if (!fs[chmod]) return cb()
+ if (typeof wantMode !== "number") return cb()
+
+ var curMode = current.mode & 0777
+ wantMode = wantMode & 0777
+ if (wantMode === curMode) return cb()
+
+ fs[chmod](path, wantMode, cb)
+}
+
+
+function endChown (me, want, current, path, cb) {
+ // Don't even try it unless root. Too easy to EPERM.
+ if (process.platform === "win32") return cb()
+ if (!process.getuid || !process.getuid() === 0) return cb()
+ if (typeof want.uid !== "number" &&
+ typeof want.gid !== "number" ) return cb()
+
+ if (current.uid === want.uid &&
+ current.gid === want.gid) return cb()
+
+ var chown = (me.props.follow || me.type !== "SymbolicLink")
+ ? "chown" : "lchown"
+ if (!fs[chown]) return cb()
+
+ if (typeof want.uid !== "number") want.uid = current.uid
+ if (typeof want.gid !== "number") want.gid = current.gid
+
+ fs[chown](path, want.uid, want.gid, cb)
+}
+
+function endUtimes (me, want, current, path, cb) {
+ if (!fs.utimes || process.platform === "win32") return cb()
+
+ var utimes = (want.follow || me.type !== "SymbolicLink")
+ ? "utimes" : "lutimes"
+
+ if (utimes === "lutimes" && !fs[utimes]) {
+ utimes = "utimes"
+ }
+
+ if (!fs[utimes]) return cb()
+
+ var curA = current.atime
+ , curM = current.mtime
+ , meA = want.atime
+ , meM = want.mtime
+
+ if (meA === undefined) meA = curA
+ if (meM === undefined) meM = curM
+
+ if (!isDate(meA)) meA = new Date(meA)
+ if (!isDate(meM)) meA = new Date(meM)
+
+ if (meA.getTime() === curA.getTime() &&
+ meM.getTime() === curM.getTime()) return cb()
+
+ fs[utimes](path, meA, meM, cb)
+}
+
+
+// XXX This function is beastly. Break it up!
Writer.prototype._finish = function () {
var me = this
@@ -210,88 +290,82 @@ Writer.prototype._finish = function () {
return
function setProps (current) {
- // console.error(" W setprops", me._path)
- // mode
- var wantMode = me.props.mode
- , chmod = me.props.follow || me.type !== "SymbolicLink"
- ? "chmod" : "lchmod"
-
- if (fs[chmod] && typeof wantMode === "number") {
- wantMode = wantMode & 0777
- todo ++
- // console.error(" W chmod", wantMode.toString(8), me.basename, "\r")
- fs[chmod](me._path, wantMode, next(chmod))
- }
+ endChmod(me, me.props, current, me._path, next("chmod"))
+ endChown(me, me.props, current, me._path, next("chown"))
+ endUtimes(me, me.props, current, me._path, next("chown"))
+ }
- // uid, gid
- // Don't even try it unless root. Too easy to EPERM.
- if (process.platform !== "win32" &&
- process.getuid && process.getuid() === 0 &&
- ( typeof me.props.uid === "number" ||
- typeof me.props.gid === "number" )) {
- var chown = (me.props.follow || me.type !== "SymbolicLink")
- ? "chown" : "lchown"
- if (fs[chown]) {
- if (typeof me.props.uid !== "number") me.props.uid = current.uid
- if (typeof me.props.gid !== "number") me.props.gid = current.gid
- if (me.props.uid !== current.uid || me.props.gid !== current.gid) {
- todo ++
- // console.error(" W chown", me.props.uid, me.props.gid, me.basename)
- fs[chown](me._path, me.props.uid, me.props.gid, next("chown"))
+ function next (what) {
+ todo ++
+ return function (er) {
+ // console.error(" W Finish", what, todo)
+ if (errState) return
+ if (er) {
+ er.fstream_finish_call = what
+ return me.error(errState = er)
+ }
+ if (--todo > 0) return
+ if (done) return
+ done = true
+
+ // we may still need to set the mode/etc. on some parent dirs
+ // that were created previously. delay end/close until then.
+ if (!me._madeDir) return end()
+ else endMadeDir(me, me._path, end)
+
+ function end (er) {
+ if (er) {
+ er.fstream_finish_call = "setupMadeDir"
+ return me.error(er)
}
+ // all the props have been set, so we're completely done.
+ me.emit("end")
+ me.emit("close")
}
}
+ }
+}
- // atime, mtime.
- if (fs.utimes && process.platform !== "win32") {
- var utimes = (me.props.follow || me.type !== "SymbolicLink")
- ? "utimes" : "lutimes"
-
- if (utimes === "lutimes" && !fs[utimes]) {
- utimes = "utimes"
- }
-
- var curA = current.atime
- , curM = current.mtime
- , meA = me.props.atime
- , meM = me.props.mtime
+function endMadeDir (me, p, cb) {
+ var made = me._madeDir
+ // everything *between* made and path.dirname(me._path)
+ // needs to be set up. Note that this may just be one dir.
+ var d = path.dirname(p)
- if (meA === undefined) meA = curA
- if (meM === undefined) meM = curM
+ endMadeDir_(me, d, function (er) {
+ if (er) return cb(er)
+ if (d === made) {
+ return cb()
+ }
+ endMadeDir(me, d, cb)
+ })
+}
- if (!isDate(meA)) meA = new Date(meA)
- if (!isDate(meM)) meA = new Date(meM)
+function endMadeDir_ (me, p, cb) {
+ var dirProps = {}
+ Object.keys(me.props).forEach(function (k) {
+ dirProps[k] = me.props[k]
- if (meA.getTime() !== curA.getTime() ||
- meM.getTime() !== curM.getTime()) {
- todo ++
- // console.error(" W utimes", meA, meM, me.basename)
- fs[utimes](me._path, meA, meM, next("utimes"))
- }
+ // only make non-readable dirs if explicitly requested.
+ if (k === "mode" && me.type !== "Directory") {
+ dirProps[k] = dirProps[k] | 0111
}
+ })
- // finally, handle the case if there was nothing to do.
- if (todo === 0) {
- // console.error(" W nothing to do", me.basename)
- next("nothing to do")()
- }
- }
+ var todo = 3
+ , errState = null
+ fs.stat(p, function (er, current) {
+ if (er) return cb(errState = er)
+ endChmod(me, dirProps, current, p, next)
+ endChown(me, dirProps, current, p, next)
+ endUtimes(me, dirProps, current, p, next)
+ })
- function next (what) { return function (er) {
- // console.error(" W Finish", what, todo)
+ function next (er) {
if (errState) return
- if (er) {
- er.fstream_finish_call = what
- return me.error(errState = er)
- }
- if (--todo > 0) return
- if (done) return
- done = true
-
- // all the props have been set, so we're completely done.
- me.emit("end")
- me.emit("close")
- }}
+ if (er) return cb(errState = er)
+ if (-- todo === 0) return cb()
+ }
}
Writer.prototype.pipe = function () {
diff --git a/deps/npm/node_modules/fstream/package.json b/deps/npm/node_modules/fstream/package.json
index eb8561532c..2be498e095 100644
--- a/deps/npm/node_modules/fstream/package.json
+++ b/deps/npm/node_modules/fstream/package.json
@@ -1,26 +1,42 @@
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
"name": "fstream",
"description": "Advanced file system stream things",
- "version": "0.1.11",
+ "version": "0.1.18",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/fstream.git"
},
"main": "fstream.js",
"engines": {
- "node": "0.5 || 0.6 || 0.7"
+ "node": ">=0.6"
},
"dependencies": {
- "rimraf": "~1.0.8",
- "mkdirp": "~0.1.0",
+ "rimraf": "2",
+ "mkdirp": "0.3",
"graceful-fs": "~1.1.2",
"inherits": "~1.0.0"
},
"devDependencies": {
- "tap": "0.1"
+ "tap": ""
},
"scripts": {
"test": "tap examples/*.js"
- }
+ },
+ "license": "BSD",
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "fstream@0.1.18",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.13",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "fstream@~0.1.17"
}
diff --git a/deps/npm/node_modules/graceful-fs/graceful-fs.js b/deps/npm/node_modules/graceful-fs/graceful-fs.js
index 7467f304a2..ecbda31a5a 100644
--- a/deps/npm/node_modules/graceful-fs/graceful-fs.js
+++ b/deps/npm/node_modules/graceful-fs/graceful-fs.js
@@ -6,8 +6,7 @@ var fs = require("fs")
// there is such a thing as TOO graceful.
if (fs.open === gracefulOpen) return
-var FastList = require("fast-list")
- , queue = new FastList()
+var queue = []
, curOpen = 0
, constants = require("constants")
@@ -210,3 +209,67 @@ if (!fs.lutimes) {
fs.lutimesSync = function () {}
}
}
+
+
+// https://github.com/isaacs/node-graceful-fs/issues/4
+// Chown should not fail on einval or eperm if non-root.
+
+fs.chown = chownFix(fs.chown)
+fs.fchown = chownFix(fs.fchown)
+fs.lchown = chownFix(fs.lchown)
+
+fs.chownSync = chownFixSync(fs.chownSync)
+fs.fchownSync = chownFixSync(fs.fchownSync)
+fs.lchownSync = chownFixSync(fs.lchownSync)
+
+function chownFix (orig) {
+ if (!orig) return orig
+ return function (target, uid, gid, cb) {
+ return orig.call(fs, target, uid, gid, function (er, res) {
+ if (chownErOk(er)) er = null
+ cb(er, res)
+ })
+ }
+}
+
+function chownFixSync (orig) {
+ if (!orig) return orig
+ return function (target, uid, gid) {
+ try {
+ return orig.call(fs, target, uid, gid)
+ } catch (er) {
+ if (!chownErOk(er)) throw er
+ }
+ }
+}
+
+function chownErOk (er) {
+ // if there's no getuid, or if getuid() is something other than 0,
+ // and the error is EINVAL or EPERM, then just ignore it.
+ // This specific case is a silent failure in cp, install, tar,
+ // and most other unix tools that manage permissions.
+ // When running as root, or if other types of errors are encountered,
+ // then it's strict.
+ if (!er || (!process.getuid || process.getuid() !== 0)
+ && (er.code === "EINVAL" || er.code === "EPERM")) return true
+}
+
+
+
+// on Windows, A/V software can lock the directory, causing this
+// to fail with an EACCES or EPERM if the directory contains newly
+// created files. Try again on failure, for up to 1 second.
+if (process.platform === "win32") {
+ var rename_ = fs.rename
+ fs.rename = function rename (from, to, cb) {
+ var start = Date.now()
+ rename_(from, to, function CB (er) {
+ if (er
+ && (er.code === "EACCES" || er.code === "EPERM")
+ && Date.now() - start < 1000) {
+ return rename_(from, to, CB)
+ }
+ cb(er)
+ })
+ }
+}
diff --git a/deps/npm/node_modules/graceful-fs/package.json b/deps/npm/node_modules/graceful-fs/package.json
index ec72affa13..757d3014c8 100644
--- a/deps/npm/node_modules/graceful-fs/package.json
+++ b/deps/npm/node_modules/graceful-fs/package.json
@@ -1,18 +1,31 @@
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me"
+ },
"name": "graceful-fs",
"description": "fs monkey-patching to avoid EMFILE and other problems",
- "version": "1.1.2",
+ "version": "1.1.8",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-graceful-fs.git"
},
"main": "graceful-fs.js",
"engines": {
- "node": "0.4 || 0.5 || 0.6"
+ "node": ">=0.4.0"
},
- "dependencies": {
- "fast-list": "1"
+ "devDependencies": {},
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
},
- "devDependencies": {}
+ "_id": "graceful-fs@1.1.8",
+ "dependencies": {},
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.10",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "graceful-fs@~1.1.1"
}
diff --git a/deps/npm/node_modules/inherits/LICENSE b/deps/npm/node_modules/inherits/LICENSE
index c78c4f6618..5a8e332545 100644
--- a/deps/npm/node_modules/inherits/LICENSE
+++ b/deps/npm/node_modules/inherits/LICENSE
@@ -1,26 +1,14 @@
-Copyright 2011 Isaac Z. Schlueter (the "Author")
-All rights reserved.
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
-General Public Obviousness License
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
-The Author asserts that this software and associated documentation
-files (the "Software"), while the Author's original creation, is
-nonetheless obvious, trivial, unpatentable, and implied by the
-context in which the software was created. If you sat down and
-thought about the problem for an hour or less, you'd probably
-come up with exactly this solution.
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
-Permission is granted to use this software in any way
-whatsoever, with the following restriction:
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-You may not release the Software under a more restrictive license
-than this one.
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
-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/deps/npm/node_modules/inherits/package.json b/deps/npm/node_modules/inherits/package.json
index 7dc32771b9..b5499c1ec8 100644
--- a/deps/npm/node_modules/inherits/package.json
+++ b/deps/npm/node_modules/inherits/package.json
@@ -1,8 +1,44 @@
-{ "name" : "inherits"
-, "description": "A tiny simple way to do classic inheritance in js"
-, "version" : "1.0.0"
-, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"]
-, "main" : "./inherits.js"
-, "repository" : "https://github.com/isaacs/inherits"
-, "license": { "type": "GPOL", "url": "https://raw.github.com/isaacs/inherits/master/LICENSE" }
-, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" }
+{
+ "name": "inherits",
+ "description": "A tiny simple way to do classic inheritance in js",
+ "version": "1.0.0",
+ "keywords": [
+ "inheritance",
+ "class",
+ "klass",
+ "oop",
+ "object-oriented"
+ ],
+ "main": "./inherits.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/inherits.git"
+ },
+ "license": {
+ "type": "WTFPL2"
+ },
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "inherits@1.0.0",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.1.10",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "12dbc03c9f7c203289234b214a7d05a311d71450"
+ },
+ "_from": "git://github.com/isaacs/inherits"
+}
diff --git a/deps/npm/node_modules/minimatch/README.md b/deps/npm/node_modules/minimatch/README.md
index d5f97234cd..6fd07d2e97 100644
--- a/deps/npm/node_modules/minimatch/README.md
+++ b/deps/npm/node_modules/minimatch/README.md
@@ -60,11 +60,12 @@ thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
`a/**b` will not. **Note that this is different from the way that `**` is
handled by ruby's `Dir` class.**
-If an escaped pattern has no matches, and the `null` flag is not set,
+If an escaped pattern has no matches, and the `nonull` flag is set,
then minimatch.match returns the pattern as-provided, rather than
interpreting the character escapes. For example,
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
-`"*a?"`.
+`"*a?"`. This is akin to setting the `nullglob` option in bash, except
+that it does not resolve escaped pattern characters.
If brace expansion is not disabled, then it is performed before any
other interpretation of the glob pattern. Thus, a pattern like
@@ -147,8 +148,8 @@ var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true}))
### minimatch.match(list, pattern, options)
Match against the list of
-files, in the style of fnmatch or glob. If nothing is matched, then
-return the pattern (unless `{ null: true }` in the options.)
+files, in the style of fnmatch or glob. If nothing is matched, and
+options.nonull is set, then return a list containing the pattern itself.
```javascript
var javascripts = minimatch.match(fileList, "*.js", {matchBase: true}))
@@ -210,3 +211,8 @@ comment.
### nonegate
Suppress the behavior of treating a leading `!` character as negation.
+
+### flipNegate
+
+Returns from negate expressions the same as if they were not negated.
+(Ie, true on a hit, false on a miss.)
diff --git a/deps/npm/node_modules/minimatch/minimatch.js b/deps/npm/node_modules/minimatch/minimatch.js
index 768c8ebac7..1ca08104ee 100644
--- a/deps/npm/node_modules/minimatch/minimatch.js
+++ b/deps/npm/node_modules/minimatch/minimatch.js
@@ -4,7 +4,6 @@ minimatch.Minimatch = Minimatch
var LRU = require("lru-cache")
, cache = minimatch.cache = new LRU(100)
, GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
- , pathSplit = process.platform === "win32" ? /\\|\// : "/"
var path = require("path")
// any single thing other than /
@@ -130,7 +129,7 @@ function make () {
this.parseNegate()
// step 2: expand braces
- var set = this.braceExpand()
+ var set = this.globSet = this.braceExpand()
if (options.debug) console.error(this.pattern, set)
@@ -139,36 +138,10 @@ function make () {
// These will be regexps, except in the case of "**", which is
// set to the GLOBSTAR object for globstar behavior,
// and will not contain any / characters
- set = set.map(function (s) {
+ set = this.globParts = set.map(function (s) {
return s.split(slashSplit)
})
- // step 4: if we have a defined root, then patterns starting with ""
- // get attached to that. If we have a defined cwd, then patterns
- // *not* starting with "" get attached to that.
- // Exception 1: on windows, a pattern like //\?/c:/ or c:/ will
- // not get anything prefixed to it.
- // Exception 2: If matchBase is set, and it's just a filename,
- // then don't prefix anything onto it, since it'll only match
- // files with that basename anyhow.
- set = set.map(function (p) {
- if (process.platform === "win32" &&
- ( (p[0] === "" && p[1] === "" && p[2] === "\\?") // unc
- || (p[0].match(/^[a-zA-Z]:$/)) )) {
- return p
- }
- if (options.matchBase && p.length === 1) return p
- // do prefixing.
- if (options.root && p[0] === "") {
- return options.root.split(pathSplit).concat(p)
- }
- if (options.cwd && p[0] !== "") {
- return options.cwd.split(pathSplit).concat(p)
- }
- return p
- })
-
-
if (options.debug) console.error(this.pattern, set)
// glob --> regexps
@@ -545,7 +518,8 @@ function parse (pattern, isSub) {
patternListStack.push({ type: plType
, start: i - 1
, reStart: re.length })
- re += stateChar === "!" ? "(?!" : "(?:"
+ // negation is (?:(?!js)[^/]*)
+ re += stateChar === "!" ? "(?:(?!" : "(?:"
stateChar = false
continue
@@ -558,11 +532,15 @@ function parse (pattern, isSub) {
hasMagic = true
re += ")"
plType = patternListStack.pop().type
+ // negation is (?:(?!js)[^/]*)
+ // The others are (?:<pattern>)<type>
switch (plType) {
+ case "!":
+ re += "[^/]*?)"
+ break
case "?":
case "+":
case "*": re += plType
- case "!": // already handled by the start
case "@": break // the default anyway
}
continue
@@ -786,13 +764,12 @@ function match (f, partial) {
if (this.comment) return false
if (this.empty) return f === ""
+ if (f === "/" && partial) return true
+
var options = this.options
// first, normalize any slash-separated path parts.
// f = path.normalize(f)
- var absolute = isAbsolute(f)
-
- // console.error(this.pattern, f, absolute)
// windows: need to use /, not \
// On other platforms, \ is a valid (albeit bad) filename char.
@@ -802,7 +779,9 @@ function match (f, partial) {
// treat the test path as a set of pathparts.
f = f.split(slashSplit)
- // console.error(this.pattern, "split", f)
+ if (options.debug) {
+ console.error(this.pattern, "split", f)
+ }
// just ONE of the pattern sets in this.set needs to match
// in order for it to be valid. If negating, then just one
@@ -816,12 +795,14 @@ function match (f, partial) {
var pattern = set[i]
var hit = this.matchOne(f, pattern, partial)
if (hit) {
+ if (options.flipNegate) return true
return !this.negate
}
}
// didn't get any hits. this is success if it's a negative
// pattern, failure otherwise.
+ if (options.flipNegate) return false
return this.negate
}
@@ -1003,19 +984,3 @@ function globUnescape (s) {
function regExpEscape (s) {
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
}
-
-
-function isAbsolute (p) {
- if (process.platform !== "win32") return p.charAt(0) === "/"
-
- // yanked from node/lib/path.js
- var splitDeviceRe =
- /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/
-
- var result = p.match(splitDeviceRe)
- , device = result[1] || ""
- , isUnc = device && device.charAt(1) !== ":"
- , isAbs = !!result[2] || isUnc // UNC always absolute
-
- return isAbs
-}
diff --git a/deps/npm/node_modules/minimatch/package.json b/deps/npm/node_modules/minimatch/package.json
index 92ccac5fb9..1bcb3d43e6 100644
--- a/deps/npm/node_modules/minimatch/package.json
+++ b/deps/npm/node_modules/minimatch/package.json
@@ -1,8 +1,12 @@
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me"
+ },
"name": "minimatch",
"description": "a glob matcher in javascript",
- "version": "0.1.3",
+ "version": "0.2.2",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/minimatch.git"
@@ -18,12 +22,23 @@
"lru-cache": "~1.0.5"
},
"devDependencies": {
- "tap": "~0.1.3"
+ "tap": ""
},
- "licenses" : [
+ "licenses": [
{
- "type" : "MIT",
- "url" : "http://github.com/isaacs/minimatch/raw/master/LICENSE"
+ "type": "MIT",
+ "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE"
}
- ]
+ ],
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "minimatch@0.2.2",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.12",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "_from": "minimatch@0"
}
diff --git a/deps/npm/node_modules/mkdirp/README.markdown b/deps/npm/node_modules/mkdirp/README.markdown
index 0393c4ea53..b4dd75fdc6 100644
--- a/deps/npm/node_modules/mkdirp/README.markdown
+++ b/deps/npm/node_modules/mkdirp/README.markdown
@@ -3,14 +3,14 @@ mkdirp
Like `mkdir -p`, but in node.js!
-Example
+example
=======
pow.js
------
var mkdirp = require('mkdirp');
- mkdirp('/tmp/foo/bar/baz', 0755, function (err) {
+ mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) console.error(err)
else console.log('pow!')
});
@@ -19,3 +19,36 @@ Output
pow!
And now /tmp/foo/bar/baz exists, huzzah!
+
+methods
+=======
+
+var mkdirp = require('mkdirp');
+
+mkdirp(dir, mode, cb)
+---------------------
+
+Create a new directory and any necessary subdirectories at `dir` with octal
+permission string `mode`.
+
+If `mode` isn't specified, it defaults to `0777 & (~process.umask())`.
+
+mkdirp.sync(dir, mode)
+----------------------
+
+Synchronously create a new directory and any necessary subdirectories at `dir`
+with octal permission string `mode`.
+
+If `mode` isn't specified, it defaults to `0777 & (~process.umask())`.
+
+install
+=======
+
+With [npm](http://npmjs.org) do:
+
+ npm install mkdirp
+
+license
+=======
+
+MIT/X11
diff --git a/deps/npm/node_modules/mkdirp/index.js b/deps/npm/node_modules/mkdirp/index.js
index 6602801463..871488f63f 100644
--- a/deps/npm/node_modules/mkdirp/index.js
+++ b/deps/npm/node_modules/mkdirp/index.js
@@ -4,17 +4,28 @@ var fs = require('fs');
module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
function mkdirP (p, mode, f) {
+ if (typeof mode === 'function' || mode === undefined) {
+ f = mode;
+ mode = 0777 & (~process.umask());
+ }
+
+ // secret passalong argument.
+ var made = arguments[3] || null;
+
var cb = f || function () {};
if (typeof mode === 'string') mode = parseInt(mode, 8);
p = path.resolve(p);
fs.mkdir(p, mode, function (er) {
- if (!er) return cb();
+ if (!er) {
+ made = made || p;
+ return cb(null, made);
+ }
switch (er.code) {
case 'ENOENT':
- mkdirP(path.dirname(p), mode, function (er) {
- if (er) cb(er);
- else mkdirP(p, mode, cb);
+ mkdirP(path.dirname(p), mode, function (er, made) {
+ if (er) cb(er, made);
+ else mkdirP(p, mode, cb, made);
});
break;
@@ -22,15 +33,55 @@ function mkdirP (p, mode, f) {
fs.stat(p, function (er2, stat) {
// if the stat fails, then that's super weird.
// let the original EEXIST be the failure reason.
- if (er2 || !stat.isDirectory()) cb(er)
- else if ((stat.mode & 0777) !== mode) fs.chmod(p, mode, cb);
- else cb();
+ if (er2 || !stat.isDirectory()) cb(er, made)
+ else cb(null, made);
});
break;
default:
- cb(er);
+ cb(er, made);
break;
}
});
}
+
+mkdirP.sync = function sync (p, mode) {
+ if (mode === undefined) {
+ mode = 0777 & (~process.umask());
+ }
+
+ // secret passalong argument
+ var made = arguments[2] || null;
+
+ if (typeof mode === 'string') mode = parseInt(mode, 8);
+ p = path.resolve(p);
+
+ try {
+ fs.mkdirSync(p, mode);
+ made = made || p;
+ }
+ catch (err0) {
+ switch (err0.code) {
+ case 'ENOENT' :
+ made = sync(path.dirname(p), mode, made);
+ sync(p, mode, made);
+ break;
+
+ case 'EEXIST' :
+ var stat;
+ try {
+ stat = fs.statSync(p);
+ }
+ catch (err1) {
+ throw err0;
+ }
+ if (!stat.isDirectory()) throw err0;
+ break;
+ default :
+ throw err0
+ break;
+ }
+ }
+
+ return made;
+};
diff --git a/deps/npm/node_modules/mkdirp/package.json b/deps/npm/node_modules/mkdirp/package.json
index 99149f747d..2a40503c5f 100644
--- a/deps/npm/node_modules/mkdirp/package.json
+++ b/deps/npm/node_modules/mkdirp/package.json
@@ -1,23 +1,44 @@
{
- "name" : "mkdirp",
- "description" : "Recursively mkdir, like `mkdir -p`",
- "version" : "0.1.0",
- "author" : "James Halliday <mail@substack.net> (http://substack.net)",
- "main" : "./index",
- "keywords" : [
- "mkdir",
- "directory"
- ],
- "repository" : {
- "type" : "git",
- "url" : "http://github.com/substack/node-mkdirp.git"
- },
- "scripts" : {
- "test" : "tap test/*.js"
- },
- "devDependencies" : {
- "tap" : "0.0.x"
- },
- "license" : "MIT/X11",
- "engines": { "node": "*" }
+ "name": "mkdirp",
+ "description": "Recursively mkdir, like `mkdir -p`",
+ "version": "0.3.0",
+ "author": {
+ "name": "James Halliday",
+ "email": "mail@substack.net",
+ "url": "http://substack.net"
+ },
+ "main": "./index",
+ "keywords": [
+ "mkdir",
+ "directory"
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/node-mkdirp.git"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "devDependencies": {
+ "tap": "0.2"
+ },
+ "license": "MIT/X11",
+ "engines": {
+ "node": "*"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "mkdirp@0.3.0",
+ "dependencies": {},
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.13",
+ "_nodeVersion": "v0.7.7-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "a3cc6816e78b84f570caf9d95cb7368dc5d0bab8"
+ },
+ "_from": "../mkdirp"
}
diff --git a/deps/npm/node_modules/read/lib/read.js b/deps/npm/node_modules/read/lib/read.js
index 246044bcd9..ba2ef0ae78 100644
--- a/deps/npm/node_modules/read/lib/read.js
+++ b/deps/npm/node_modules/read/lib/read.js
@@ -5,6 +5,14 @@ var buffer = ""
, tty = require("tty")
, StringDecoder = require("string_decoder").StringDecoder
+function raw (mode) {
+ try {
+ process.stdin.setRawMode(mode)
+ } catch (e) {
+ tty.setRawMode(mode)
+ }
+}
+
function read (opts, cb) {
if (!cb) cb = opts, opts = {}
@@ -25,7 +33,7 @@ function read (opts, cb) {
cb = (function (cb) {
var called = false
var t = setTimeout(function () {
- tty.setRawMode(false)
+ raw(false)
process.stdout.write("\n")
if (def) done(null, def)
else done(new Error("timeout"))
@@ -109,7 +117,7 @@ function rawRead (def, timeout, delim, silent, num, cb) {
, val = ""
, decoder = new StringDecoder
- tty.setRawMode(true)
+ raw(true)
stdin.resume()
stdin.on("error", cb)
stdin.on("data", function D (c) {
@@ -122,7 +130,7 @@ function rawRead (def, timeout, delim, silent, num, cb) {
case "\u0004": // EOF
case delim:
- tty.setRawMode(false)
+ raw(false)
stdin.removeListener("data", D)
stdin.removeListener("error", cb)
val = val.trim() || def
@@ -131,7 +139,7 @@ function rawRead (def, timeout, delim, silent, num, cb) {
return cb(null, val)
case "\u0003": case "\0": // ^C or other signal abort
- tty.setRawMode(false)
+ raw(false)
stdin.removeListener("data", D)
stdin.removeListener("error", cb)
stdin.pause()
diff --git a/deps/npm/node_modules/read/package.json b/deps/npm/node_modules/read/package.json
index bc05577aac..f206a719b3 100644
--- a/deps/npm/node_modules/read/package.json
+++ b/deps/npm/node_modules/read/package.json
@@ -1,16 +1,28 @@
{
"name": "read",
- "version": "0.0.1",
+ "version": "0.0.2",
"main": "lib/read.js",
"dependencies": {},
"devDependencies": {},
"engines": {
"node": ">=0.6"
},
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
"description": "read(1) for node programs",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/read.git"
- }
+ },
+ "license": "BSD",
+ "_id": "read@0.0.2",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.15",
+ "_nodeVersion": "v0.7.7",
+ "_defaultsLoaded": true,
+ "_from": "read@0"
}
diff --git a/deps/npm/node_modules/request/README.md b/deps/npm/node_modules/request/README.md
index 4ea89f794a..e5839b50e6 100644
--- a/deps/npm/node_modules/request/README.md
+++ b/deps/npm/node_modules/request/README.md
@@ -38,7 +38,7 @@ request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))
You can also stream a file to a PUT or POST request. This method will also check the file extension against a mapping of file extensions to content-types, in this case `application/json`, and use the proper content-type in the PUT request if one is not already provided in the headers.
```javascript
-fs.readStream('file.json').pipe(request.put('http://mysite.com/obj.json'))
+fs.createReadStream('file.json').pipe(request.put('http://mysite.com/obj.json'))
```
Request can also pipe to itself. When doing so the content-type and content-length will be preserved in the PUT headers.
@@ -146,6 +146,7 @@ request.post({url:url, oauth:oauth}, function (e, r, body) {
The first argument can be either a url or an options object. The only required option is uri, all others are optional.
* `uri` || `url` - fully qualified uri or a parsed url object from url.parse()
+* `qs` - object containing querystring values to be appended to the uri
* `method` - http method, defaults to GET
* `headers` - http headers, defaults to {}
* `body` - entity body for POST and PUT requests. Must be buffer or string.
@@ -153,6 +154,7 @@ The first argument can be either a url or an options object. The only required o
* `json` - sets `body` but to JSON representation of value and adds `Content-type: application/json` header.
* `multipart` - (experimental) array of objects which contains their own headers and `body` attribute. Sends `multipart/related` request. See example below.
* `followRedirect` - follow HTTP 3xx responses as redirects. defaults to true.
+* `followAllRedirects` - follow non-GET HTTP 3xx responses as redirects. defaults to false.
* `maxRedirects` - the maximum number of redirects to follow, defaults to 10.
* `onResponse` - If true the callback will be fired on the "response" event instead of "end". If a function it will be called on "response" and not effect the regular semantics of the main callback on "end".
* `encoding` - Encoding to be used on `setEncoding` of response data. If set to `null`, the body is returned as a Buffer.
diff --git a/deps/npm/node_modules/request/forever.js b/deps/npm/node_modules/request/forever.js
index e6531a21b3..ac853c0d28 100644
--- a/deps/npm/node_modules/request/forever.js
+++ b/deps/npm/node_modules/request/forever.js
@@ -1,8 +1,11 @@
module.exports = ForeverAgent
+ForeverAgent.SSL = ForeverAgentSSL
var util = require('util')
, Agent = require('http').Agent
, net = require('net')
+ , tls = require('tls')
+ , AgentSSL = require('https').Agent
function ForeverAgent(options) {
var self = this
@@ -34,12 +37,14 @@ function ForeverAgent(options) {
socket.destroy();
}
})
- self.createConnection = net.createConnection
+
}
util.inherits(ForeverAgent, Agent)
ForeverAgent.defaultMinSockets = 5
+
+ForeverAgent.prototype.createConnection = net.createConnection
ForeverAgent.prototype.addRequestNoreuse = Agent.prototype.addRequest
ForeverAgent.prototype.addRequest = function(req, host, port) {
var name = host + ':' + port
@@ -82,3 +87,17 @@ ForeverAgent.prototype.removeSocket = function(s, name, host, port) {
this.createSocket(name, host, port).emit('free');
}
}
+
+function ForeverAgentSSL (options) {
+ ForeverAgent.call(this, options)
+}
+util.inherits(ForeverAgentSSL, ForeverAgent)
+
+ForeverAgentSSL.prototype.createConnection = createConnectionSSL
+ForeverAgentSSL.prototype.addRequestNoreuse = AgentSSL.prototype.addRequest
+
+function createConnectionSSL (port, host, options) {
+ options.port = port
+ options.host = host
+ return tls.connect(options)
+}
diff --git a/deps/npm/node_modules/request/main.js b/deps/npm/node_modules/request/main.js
index a25393ec3e..5a6bd9eb04 100644
--- a/deps/npm/node_modules/request/main.js
+++ b/deps/npm/node_modules/request/main.js
@@ -1,4 +1,4 @@
-// Copyright 2010-2011 Mikeal Rogers
+// Copyright 2010-2012 Mikeal Rogers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ var http = require('http')
, Cookie = require('./vendor/cookie')
, CookieJar = require('./vendor/cookie/jar')
, cookieJar = new CookieJar
+ , tunnel = require('./tunnel')
;
if (process.logging) {
@@ -67,7 +68,9 @@ function isReadStream (rs) {
function copy (obj) {
var o = {}
- for (var i in obj) o[i] = obj[i]
+ Object.keys(obj).forEach(function (i) {
+ o[i] = obj[i]
+ })
return o
}
@@ -83,24 +86,31 @@ function Request (options) {
if (typeof options === 'string') {
options = {uri:options}
}
-
+
+ var reserved = Object.keys(Request.prototype)
for (var i in options) {
- this[i] = options[i]
+ if (reserved.indexOf(i) === -1) {
+ this[i] = options[i]
+ } else {
+ if (typeof options[i] === 'function') {
+ delete options[i]
+ }
+ }
}
- if (!this.pool) this.pool = globalPool
- this.dests = []
- this.__isRequestRequest = true
+ options = copy(options)
+
+ this.init(options)
}
util.inherits(Request, stream.Stream)
-Request.prototype.getAgent = function (host, port) {
- if (!this.pool[host+':'+port]) {
- this.pool[host+':'+port] = new this.httpModule.Agent({host:host, port:port})
- }
- return this.pool[host+':'+port]
-}
-Request.prototype.request = function () {
+Request.prototype.init = function (options) {
var self = this
-
+
+ if (!options) options = {}
+
+ if (!self.pool) self.pool = globalPool
+ self.dests = []
+ self.__isRequestRequest = true
+
// Protect against double callback
if (!self._callback && self.callback) {
self._callback = self.callback
@@ -124,17 +134,32 @@ Request.prototype.request = function () {
}
if (self.proxy) {
if (typeof self.proxy == 'string') self.proxy = url.parse(self.proxy)
+
+ // do the HTTP CONNECT dance using koichik/node-tunnel
+ if (http.globalAgent && self.uri.protocol === "https:") {
+ var tunnelFn = self.proxy.protocol === "http:"
+ ? tunnel.httpsOverHttp : tunnel.httpsOverHttps
+
+ var tunnelOptions = { proxy: { host: self.proxy.hostname
+ , port: +self.proxy.port
+ , proxyAuth: self.proxy.auth }
+ , ca: this.ca }
+
+ self.agent = tunnelFn(tunnelOptions)
+ self.tunnel = true
+ }
}
self._redirectsFollowed = self._redirectsFollowed || 0
self.maxRedirects = (self.maxRedirects !== undefined) ? self.maxRedirects : 10
self.followRedirect = (self.followRedirect !== undefined) ? self.followRedirect : true
- if (self.followRedirect)
+ self.followAllRedirects = (self.followAllRedirects !== undefined) ? self.followAllRedirects : false;
+ if (self.followRedirect || self.followAllRedirects)
self.redirects = self.redirects || []
self.headers = self.headers ? copy(self.headers) : {}
- var setHost = false
+ self.setHost = false
if (!self.headers.host) {
self.headers.host = self.uri.hostname
if (self.uri.port) {
@@ -142,27 +167,10 @@ Request.prototype.request = function () {
!(self.uri.port === 443 && self.uri.protocol === 'https:') )
self.headers.host += (':'+self.uri.port)
}
- setHost = true
- }
-
- if (self.jar === false) {
- // disable cookies
- var cookies = false;
- self._disableCookies = true;
- } else if (self.jar) {
- // fetch cookie from the user defined cookie jar
- var cookies = self.jar.get({ url: self.uri.href })
- } else {
- // fetch cookie from the global cookie jar
- var cookies = cookieJar.get({ url: self.uri.href })
- }
- if (cookies) {
- var cookieString = cookies.map(function (c) {
- return c.name + "=" + c.value;
- }).join("; ");
-
- self.headers.Cookie = cookieString;
+ self.setHost = true
}
+
+ self.jar(self._jar || options.jar)
if (!self.uri.pathname) {self.uri.pathname = '/'}
if (!self.uri.port) {
@@ -170,7 +178,7 @@ Request.prototype.request = function () {
else if (self.uri.protocol == 'https:') {self.uri.port = 443}
}
- if (self.proxy) {
+ if (self.proxy && !self.tunnel) {
self.port = self.proxy.port
self.host = self.proxy.hostname
} else {
@@ -183,74 +191,43 @@ Request.prototype.request = function () {
delete self.callback
}
- var clientErrorHandler = function (error) {
- if (setHost) delete self.headers.host
- if (self.req._reusedSocket && error.code === 'ECONNRESET') {
- self.agent = {addRequest: ForeverAgent.prototype.addRequestNoreuse.bind(self.agent)}
+ self.clientErrorHandler = function (error) {
+ if (self._aborted) return
+
+ if (self.setHost) delete self.headers.host
+ if (self.req._reusedSocket && error.code === 'ECONNRESET'
+ && self.agent.addRequestNoreuse) {
+ self.agent = { addRequest: self.agent.addRequestNoreuse.bind(self.agent) }
self.start()
self.req.end()
return
}
- if (self.timeout && self.timeoutTimer) clearTimeout(self.timeoutTimer)
+ if (self.timeout && self.timeoutTimer) {
+ clearTimeout(self.timeoutTimer);
+ self.timeoutTimer = null;
+ }
self.emit('error', error)
}
if (self.onResponse) self.on('error', function (e) {self.onResponse(e)})
if (self.callback) self.on('error', function (e) {self.callback(e)})
- if (self.form) {
- self.headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
- self.body = qs.stringify(self.form).toString('utf8')
- }
-
- if (self.oauth) {
- var form
- if (self.headers['content-type'] &&
- self.headers['content-type'].slice(0, 'application/x-www-form-urlencoded'.length) ===
- 'application/x-www-form-urlencoded'
- ) {
- form = qs.parse(self.body)
- }
- if (self.uri.query) {
- form = qs.parse(self.uri.query)
- }
- if (!form) form = {}
- var oa = {}
- for (var i in form) oa[i] = form[i]
- for (var i in self.oauth) oa['oauth_'+i] = self.oauth[i]
- if (!oa.oauth_version) oa.oauth_version = '1.0'
- if (!oa.oauth_timestamp) oa.oauth_timestamp = Math.floor( (new Date()).getTime() / 1000 ).toString()
- if (!oa.oauth_nonce) oa.oauth_nonce = uuid().replace(/-/g, '')
-
- oa.oauth_signature_method = 'HMAC-SHA1'
-
- var consumer_secret = oa.oauth_consumer_secret
- delete oa.oauth_consumer_secret
- var token_secret = oa.oauth_token_secret
- delete oa.oauth_token_secret
-
- var baseurl = self.uri.protocol + '//' + self.uri.host + self.uri.pathname
- var signature = oauth.hmacsign(self.method, baseurl, oa, consumer_secret, token_secret)
-
- // oa.oauth_signature = signature
- for (var i in form) {
- if ( i.slice(0, 'oauth_') in self.oauth) {
- // skip
- } else {
- delete oa['oauth_'+i]
- }
- }
- self.headers.authorization =
- 'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+oauth.rfc3986(oa[i])+'"'}).join(',')
- self.headers.authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"'
+ if (options.form) {
+ self.form(options.form)
+ }
+
+ if (options.oauth) {
+ self.oauth(options.oauth)
}
if (self.uri.auth && !self.headers.authorization) {
self.headers.authorization = "Basic " + toBase64(self.uri.auth.split(':').map(function(item){ return qs.unescape(item)}).join(':'))
}
- if (self.proxy && self.proxy.auth && !self.headers['proxy-authorization']) {
+ if (self.proxy && self.proxy.auth && !self.headers['proxy-authorization'] && !self.tunnel) {
self.headers['proxy-authorization'] = "Basic " + toBase64(self.proxy.auth.split(':').map(function(item){ return qs.unescape(item)}).join(':'))
}
+ if (options.qs) self.qs(options.qs)
+
if (self.uri.path) {
self.path = self.uri.path
} else {
@@ -259,41 +236,12 @@ Request.prototype.request = function () {
if (self.path.length === 0) self.path = '/'
- if (self.proxy) self.path = (self.uri.protocol + '//' + self.uri.host + self.path)
-
- if (self.json) {
- self.headers['content-type'] = 'application/json'
- if (typeof self.json === 'boolean') {
- if (typeof self.body === 'object') self.body = JSON.stringify(self.body)
- } else {
- self.body = JSON.stringify(self.json)
- }
-
- } else if (self.multipart) {
- self.body = []
-
- if (!self.headers['content-type']) {
- self.headers['content-type'] = 'multipart/related;boundary="frontier"';
- } else {
- self.headers['content-type'] = self.headers['content-type'].split(';')[0] + ';boundary="frontier"';
- }
-
- if (!self.multipart.forEach) throw new Error('Argument error, options.multipart.')
+ if (self.proxy && !self.tunnel) self.path = (self.uri.protocol + '//' + self.uri.host + self.path)
- self.multipart.forEach(function (part) {
- var body = part.body
- if(!body) throw Error('Body attribute missing in multipart.')
- delete part.body
- var preamble = '--frontier\r\n'
- Object.keys(part).forEach(function(key){
- preamble += key + ': ' + part[key] + '\r\n'
- })
- preamble += '\r\n'
- self.body.push(new Buffer(preamble))
- self.body.push(new Buffer(body))
- self.body.push(new Buffer('\r\n'))
- })
- self.body.push(new Buffer('--frontier--'))
+ if (options.json) {
+ self.json(options.json)
+ } else if (options.multipart) {
+ self.multipart(options.multipart)
}
if (self.body) {
@@ -317,7 +265,7 @@ Request.prototype.request = function () {
}
}
- var protocol = self.proxy ? self.proxy.protocol : self.uri.protocol
+ var protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol
, defaultModules = {'http:':http, 'https:':https}
, httpModules = self.httpModules || {}
;
@@ -325,177 +273,34 @@ Request.prototype.request = function () {
if (!self.httpModule) throw new Error("Invalid protocol")
+ if (options.ca) self.ca = options.ca
+
+ if (!self.agent) {
+ if (options.agentOptions) self.agentOptions = options.agentOptions
+
+ if (options.agentClass) {
+ self.agentClass = options.agentClass
+ } else if (options.forever) {
+ self.agentClass = protocol === 'http:' ? ForeverAgent : ForeverAgent.SSL
+ } else {
+ self.agentClass = self.httpModule.Agent
+ }
+ }
+
if (self.pool === false) {
self.agent = false
} else {
+ self.agent = self.agent || self.getAgent()
if (self.maxSockets) {
// Don't use our pooling if node has the refactored client
- self.agent = self.agent || self.httpModule.globalAgent || self.getAgent(self.host, self.port)
self.agent.maxSockets = self.maxSockets
}
if (self.pool.maxSockets) {
// Don't use our pooling if node has the refactored client
- self.agent = self.agent || self.httpModule.globalAgent || self.getAgent(self.host, self.port)
self.agent.maxSockets = self.pool.maxSockets
}
}
- self.start = function () {
- self._started = true
- self.method = self.method || 'GET'
- self.href = self.uri.href
- if (log) log('%method %href', self)
- self.req = self.httpModule.request(self, function (response) {
- self.response = response
- response.request = self
-
- if (self.httpModule === https &&
- self.strictSSL &&
- !response.client.authorized) {
- var sslErr = response.client.authorizationError
- self.emit('error', new Error('SSL Error: '+ sslErr))
- return
- }
-
- if (setHost) delete self.headers.host
- if (self.timeout && self.timeoutTimer) clearTimeout(self.timeoutTimer)
-
- if (response.headers['set-cookie'] && (!self._disableCookies)) {
- response.headers['set-cookie'].forEach(function(cookie) {
- if (self.jar) self.jar.add(new Cookie(cookie))
- else cookieJar.add(new Cookie(cookie))
- })
- }
-
- if (response.statusCode >= 300 &&
- response.statusCode < 400 &&
- self.followRedirect &&
- self.method !== 'PUT' &&
- self.method !== 'POST' &&
- response.headers.location) {
- if (self._redirectsFollowed >= self.maxRedirects) {
- self.emit('error', new Error("Exceeded maxRedirects. Probably stuck in a redirect loop."))
- return
- }
- self._redirectsFollowed += 1
-
- if (!isUrl.test(response.headers.location)) {
- response.headers.location = url.resolve(self.uri.href, response.headers.location)
- }
- self.uri = response.headers.location
- self.redirects.push(
- { statusCode : response.statusCode
- , redirectUri: response.headers.location
- }
- )
- delete self.req
- delete self.agent
- delete self._started
- if (self.headers) {
- delete self.headers.host
- }
- if (log) log('Redirect to %uri', self)
- request(self, self.callback)
- return // Ignore the rest of the response
- } else {
- self._redirectsFollowed = self._redirectsFollowed || 0
- // Be a good stream and emit end when the response is finished.
- // Hack to emit end on close because of a core bug that never fires end
- response.on('close', function () {
- if (!self._ended) self.response.emit('end')
- })
-
- if (self.encoding) {
- if (self.dests.length !== 0) {
- console.error("Ingoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.")
- } else {
- response.setEncoding(self.encoding)
- }
- }
-
- self.pipeDest = function (dest) {
- if (dest.headers) {
- dest.headers['content-type'] = response.headers['content-type']
- if (response.headers['content-length']) {
- dest.headers['content-length'] = response.headers['content-length']
- }
- }
- if (dest.setHeader) {
- for (var i in response.headers) {
- dest.setHeader(i, response.headers[i])
- }
- dest.statusCode = response.statusCode
- }
- if (self.pipefilter) self.pipefilter(response, dest)
- }
-
- self.dests.forEach(function (dest) {
- self.pipeDest(dest)
- })
-
- response.on("data", function (chunk) {
- self._destdata = true
- self.emit("data", chunk)
- })
- response.on("end", function (chunk) {
- self._ended = true
- self.emit("end", chunk)
- })
- response.on("close", function () {self.emit("close")})
-
- self.emit('response', response)
-
- if (self.onResponse) {
- self.onResponse(null, response)
- }
- if (self.callback) {
- var buffer = []
- var bodyLen = 0
- self.on("data", function (chunk) {
- buffer.push(chunk)
- bodyLen += chunk.length
- })
- self.on("end", function () {
- if (buffer.length && Buffer.isBuffer(buffer[0])) {
- var body = new Buffer(bodyLen)
- var i = 0
- buffer.forEach(function (chunk) {
- chunk.copy(body, i, 0, chunk.length)
- i += chunk.length
- })
- if (self.encoding === null) {
- response.body = body
- } else {
- response.body = body.toString()
- }
- } else if (buffer.length) {
- response.body = buffer.join('')
- }
-
- if (self.json) {
- try {
- response.body = JSON.parse(response.body)
- } catch (e) {}
- }
-
- self.callback(null, response, response.body)
- })
- }
- }
- })
-
- if (self.timeout && !self.timeoutTimer) {
- self.timeoutTimer = setTimeout(function() {
- self.req.abort()
- var e = new Error("ETIMEDOUT")
- e.code = "ETIMEDOUT"
- self.emit("error", e)
- }, self.timeout)
- }
-
- self.req.on('error', clientErrorHandler)
- }
-
self.once('pipe', function (src) {
if (self.ntick) throw new Error("You cannot pipe to this stream after the first nextTick() after creation of the request stream.")
self.src = src
@@ -521,6 +326,8 @@ Request.prototype.request = function () {
})
process.nextTick(function () {
+ if (self._aborted) return
+
if (self.body) {
if (Array.isArray(self.body)) {
self.body.forEach(function(part) {
@@ -540,47 +347,538 @@ Request.prototype.request = function () {
self.ntick = true
})
}
-Request.prototype.pipe = function (dest) {
+
+// Must call this when following a redirect from https to http or vice versa
+// Attempts to keep everything as identical as possible, but update the
+// httpModule, Tunneling agent, and/or Forever Agent in use.
+Request.prototype._updateProtocol = function () {
+ var self = this
+ var protocol = self.uri.protocol
+
+ if (protocol === 'https:') {
+ // previously was doing http, now doing https
+ // if it's https, then we might need to tunnel now.
+ if (self.proxy) {
+ self.tunnel = true
+ var tunnelFn = self.proxy.protocol === 'http:'
+ ? tunnel.httpsOverHttp : tunnel.httpsOverHttps
+ var tunnelOptions = { proxy: { host: self.proxy.hostname
+ , post: +self.proxy.port
+ , proxyAuth: self.proxy.auth }
+ , ca: self.ca }
+ self.agent = tunnelFn(tunnelOptions)
+ return
+ }
+
+ self.httpModule = https
+ switch (self.agentClass) {
+ case ForeverAgent:
+ self.agentClass = ForeverAgent.SSL
+ break
+ case http.Agent:
+ self.agentClass = https.Agent
+ break
+ default:
+ // nothing we can do. Just hope for the best.
+ return
+ }
+
+ // if there's an agent, we need to get a new one.
+ if (self.agent) self.agent = self.getAgent()
+
+ } else {
+ if (log) log('previously https, now http')
+ // previously was doing https, now doing http
+ // stop any tunneling.
+ if (self.tunnel) self.tunnel = false
+ self.httpModule = http
+ switch (self.agentClass) {
+ case ForeverAgent.SSL:
+ self.agentClass = ForeverAgent
+ break
+ case https.Agent:
+ self.agentClass = http.Agent
+ break
+ default:
+ // nothing we can do. just hope for the best
+ return
+ }
+
+ // if there's an agent, then get a new one.
+ if (self.agent) {
+ self.agent = null
+ self.agent = self.getAgent()
+ }
+ }
+}
+
+Request.prototype.getAgent = function () {
+ var Agent = this.agentClass
+ var options = {}
+ if (this.agentOptions) {
+ for (var i in this.agentOptions) {
+ options[i] = this.agentOptions[i]
+ }
+ }
+ if (this.ca) options.ca = this.ca
+
+ var poolKey = ''
+
+ // different types of agents are in different pools
+ if (Agent !== this.httpModule.Agent) {
+ poolKey += Agent.name
+ }
+
+ if (!this.httpModule.globalAgent) {
+ // node 0.4.x
+ options.host = this.host
+ options.port = this.port
+ if (poolKey) poolKey += ':'
+ poolKey += this.host + ':' + this.port
+ }
+
+ // ca option is only relevant if proxy or destination are https
+ var proxy = this.proxy
+ if (typeof proxy === 'string') proxy = url.parse(proxy)
+ var caRelevant = (proxy && proxy.protocol === 'https:') || this.uri.protocol === 'https:'
+ if (options.ca && caRelevant) {
+ if (poolKey) poolKey += ':'
+ poolKey += options.ca
+ }
+
+ if (!poolKey && Agent === this.httpModule.Agent && this.httpModule.globalAgent) {
+ // not doing anything special. Use the globalAgent
+ return this.httpModule.globalAgent
+ }
+
+ // we're using a stored agent. Make sure it's protocol-specific
+ poolKey = this.uri.protocol + poolKey
+
+ // already generated an agent for this setting
+ if (this.pool[poolKey]) return this.pool[poolKey]
+
+ return this.pool[poolKey] = new Agent(options)
+}
+
+Request.prototype.start = function () {
+ var self = this
+
+ if (self._aborted) return
+
+ self._started = true
+ self.method = self.method || 'GET'
+ self.href = self.uri.href
+ if (log) log('%method %href', self)
+ self.req = self.httpModule.request(self, function (response) {
+ if (self._aborted) return
+ if (self._paused) response.pause()
+
+ self.response = response
+ response.request = self
+
+ if (self.httpModule === https &&
+ self.strictSSL &&
+ !response.client.authorized) {
+ var sslErr = response.client.authorizationError
+ self.emit('error', new Error('SSL Error: '+ sslErr))
+ return
+ }
+
+ if (self.setHost) delete self.headers.host
+ if (self.timeout && self.timeoutTimer) {
+ clearTimeout(self.timeoutTimer);
+ self.timeoutTimer = null;
+ }
+
+ if (response.headers['set-cookie'] && (!self._disableCookies)) {
+ response.headers['set-cookie'].forEach(function(cookie) {
+ if (self._jar) self._jar.add(new Cookie(cookie))
+ else cookieJar.add(new Cookie(cookie))
+ })
+ }
+
+ if (response.statusCode >= 300 && response.statusCode < 400 &&
+ (self.followAllRedirects ||
+ (self.followRedirect && (self.method !== 'PUT' && self.method !== 'POST' && self.method !== 'DELETE'))) &&
+ response.headers.location) {
+ if (self._redirectsFollowed >= self.maxRedirects) {
+ self.emit('error', new Error("Exceeded maxRedirects. Probably stuck in a redirect loop."))
+ return
+ }
+ self._redirectsFollowed += 1
+
+ if (!isUrl.test(response.headers.location)) {
+ response.headers.location = url.resolve(self.uri.href, response.headers.location)
+ }
+
+ var uriPrev = self.uri
+ self.uri = url.parse(response.headers.location)
+
+ // handle the case where we change protocol from https to http or vice versa
+ if (self.uri.protocol !== uriPrev.protocol) {
+ self._updateProtocol()
+ }
+
+ self.redirects.push(
+ { statusCode : response.statusCode
+ , redirectUri: response.headers.location
+ }
+ )
+ self.method = 'GET'; // Force all redirects to use GET
+ delete self.req
+ delete self.agent
+ delete self._started
+ delete self.body
+ if (self.headers) {
+ delete self.headers.host
+ }
+ if (log) log('Redirect to %uri', self)
+ self.init()
+ return // Ignore the rest of the response
+ } else {
+ self._redirectsFollowed = self._redirectsFollowed || 0
+ // Be a good stream and emit end when the response is finished.
+ // Hack to emit end on close because of a core bug that never fires end
+ response.on('close', function () {
+ if (!self._ended) self.response.emit('end')
+ })
+
+ if (self.encoding) {
+ if (self.dests.length !== 0) {
+ console.error("Ingoring encoding parameter as this stream is being piped to another stream which makes the encoding option invalid.")
+ } else {
+ response.setEncoding(self.encoding)
+ }
+ }
+
+ self.dests.forEach(function (dest) {
+ self.pipeDest(dest)
+ })
+
+ response.on("data", function (chunk) {
+ self._destdata = true
+ self.emit("data", chunk)
+ })
+ response.on("end", function (chunk) {
+ self._ended = true
+ self.emit("end", chunk)
+ })
+ response.on("close", function () {self.emit("close")})
+
+ self.emit('response', response)
+
+ if (self.onResponse) {
+ self.onResponse(null, response)
+ }
+ if (self.callback) {
+ var buffer = []
+ var bodyLen = 0
+ self.on("data", function (chunk) {
+ buffer.push(chunk)
+ bodyLen += chunk.length
+ })
+ self.on("end", function () {
+ if (self._aborted) return
+
+ if (buffer.length && Buffer.isBuffer(buffer[0])) {
+ var body = new Buffer(bodyLen)
+ var i = 0
+ buffer.forEach(function (chunk) {
+ chunk.copy(body, i, 0, chunk.length)
+ i += chunk.length
+ })
+ if (self.encoding === null) {
+ response.body = body
+ } else {
+ response.body = body.toString()
+ }
+ } else if (buffer.length) {
+ response.body = buffer.join('')
+ }
+
+ if (self._json) {
+ try {
+ response.body = JSON.parse(response.body)
+ } catch (e) {}
+ }
+
+ self.callback(null, response, response.body)
+ })
+ }
+ }
+ })
+
+ if (self.timeout && !self.timeoutTimer) {
+ self.timeoutTimer = setTimeout(function() {
+ self.req.abort()
+ var e = new Error("ETIMEDOUT")
+ e.code = "ETIMEDOUT"
+ self.emit("error", e)
+ }, self.timeout)
+
+ // Set additional timeout on socket - in case if remote
+ // server freeze after sending headers
+ if (self.req.setTimeout) { // only works on node 0.6+
+ self.req.setTimeout(self.timeout, function(){
+ if (self.req) {
+ self.req.abort()
+ var e = new Error("ESOCKETTIMEDOUT")
+ e.code = "ESOCKETTIMEDOUT"
+ self.emit("error", e)
+ }
+ })
+ }
+ }
+
+ self.req.on('error', self.clientErrorHandler)
+
+ self.emit('request', self.req)
+}
+
+Request.prototype.abort = function() {
+ this._aborted = true;
+
+ if (this.req) {
+ this.req.abort()
+ }
+ else if (this.response) {
+ this.response.abort()
+ }
+
+ this.emit("abort")
+}
+
+Request.prototype.pipeDest = function (dest) {
+ var response = this.response
+ // Called after the response is received
+ if (dest.headers) {
+ dest.headers['content-type'] = response.headers['content-type']
+ if (response.headers['content-length']) {
+ dest.headers['content-length'] = response.headers['content-length']
+ }
+ }
+ if (dest.setHeader) {
+ for (var i in response.headers) {
+ dest.setHeader(i, response.headers[i])
+ }
+ dest.statusCode = response.statusCode
+ }
+ if (this.pipefilter) this.pipefilter(response, dest)
+}
+
+// Composable API
+Request.prototype.setHeader = function (name, value, clobber) {
+ if (clobber === undefined) clobber = true
+ if (clobber || !this.headers.hasOwnProperty(name)) this.headers[name] = value
+ else this.headers[name] += ',' + value
+ return this
+}
+Request.prototype.setHeaders = function (headers) {
+ for (i in headers) {this.setHeader(i, headers[i])}
+ return this
+}
+Request.prototype.qs = function (q, clobber) {
+ var base
+ if (!clobber && this.uri.query) base = qs.parse(this.uri.query)
+ else base = {}
+
+ for (var i in q) {
+ base[i] = q[i]
+ }
+
+ this.uri = url.parse(this.uri.href.split('?')[0] + '?' + qs.stringify(base))
+ this.url = this.uri
+
+ return this
+}
+Request.prototype.form = function (form) {
+ this.headers['content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
+ this.body = qs.stringify(form).toString('utf8')
+ return this
+}
+Request.prototype.multipart = function (multipart) {
+ var self = this
+ self.body = []
+
+ if (!self.headers['content-type']) {
+ self.headers['content-type'] = 'multipart/related;boundary="frontier"';
+ } else {
+ self.headers['content-type'] = self.headers['content-type'].split(';')[0] + ';boundary="frontier"';
+ }
+
+ if (!multipart.forEach) throw new Error('Argument error, options.multipart.')
+
+ multipart.forEach(function (part) {
+ var body = part.body
+ if(!body) throw Error('Body attribute missing in multipart.')
+ delete part.body
+ var preamble = '--frontier\r\n'
+ Object.keys(part).forEach(function(key){
+ preamble += key + ': ' + part[key] + '\r\n'
+ })
+ preamble += '\r\n'
+ self.body.push(new Buffer(preamble))
+ self.body.push(new Buffer(body))
+ self.body.push(new Buffer('\r\n'))
+ })
+ self.body.push(new Buffer('--frontier--'))
+ return self
+}
+Request.prototype.json = function (val) {
+ this.setHeader('content-type', 'application/json')
+ this.setHeader('accept', 'application/json')
+ this._json = true
+ if (typeof val === 'boolean') {
+ if (typeof this.body === 'object') this.body = JSON.stringify(this.body)
+ } else {
+ this.body = JSON.stringify(val)
+ }
+ return this
+}
+Request.prototype.oauth = function (_oauth) {
+ var form
+ if (this.headers['content-type'] &&
+ this.headers['content-type'].slice(0, 'application/x-www-form-urlencoded'.length) ===
+ 'application/x-www-form-urlencoded'
+ ) {
+ form = qs.parse(this.body)
+ }
+ if (this.uri.query) {
+ form = qs.parse(this.uri.query)
+ }
+ if (!form) form = {}
+ var oa = {}
+ for (var i in form) oa[i] = form[i]
+ for (var i in _oauth) oa['oauth_'+i] = _oauth[i]
+ if (!oa.oauth_version) oa.oauth_version = '1.0'
+ if (!oa.oauth_timestamp) oa.oauth_timestamp = Math.floor( (new Date()).getTime() / 1000 ).toString()
+ if (!oa.oauth_nonce) oa.oauth_nonce = uuid().replace(/-/g, '')
+
+ oa.oauth_signature_method = 'HMAC-SHA1'
+
+ var consumer_secret = oa.oauth_consumer_secret
+ delete oa.oauth_consumer_secret
+ var token_secret = oa.oauth_token_secret
+ delete oa.oauth_token_secret
+
+ var baseurl = this.uri.protocol + '//' + this.uri.host + this.uri.pathname
+ var signature = oauth.hmacsign(this.method, baseurl, oa, consumer_secret, token_secret)
+
+ // oa.oauth_signature = signature
+ for (var i in form) {
+ if ( i.slice(0, 'oauth_') in _oauth) {
+ // skip
+ } else {
+ delete oa['oauth_'+i]
+ }
+ }
+ this.headers.authorization =
+ 'OAuth '+Object.keys(oa).sort().map(function (i) {return i+'="'+oauth.rfc3986(oa[i])+'"'}).join(',')
+ this.headers.authorization += ',oauth_signature="'+oauth.rfc3986(signature)+'"'
+ return this
+}
+Request.prototype.jar = function (jar) {
+ var cookies
+
+ if (this._redirectsFollowed === 0) {
+ this.originalCookieHeader = this.headers.cookie
+ }
+
+ if (jar === false) {
+ // disable cookies
+ cookies = false;
+ this._disableCookies = true;
+ } else if (jar) {
+ // fetch cookie from the user defined cookie jar
+ cookies = jar.get({ url: this.uri.href })
+ } else {
+ // fetch cookie from the global cookie jar
+ cookies = cookieJar.get({ url: this.uri.href })
+ }
+
+ if (cookies && cookies.length) {
+ var cookieString = cookies.map(function (c) {
+ return c.name + "=" + c.value
+ }).join("; ")
+
+ if (this.originalCookieHeader) {
+ // Don't overwrite existing Cookie header
+ this.headers.cookie = this.originalCookieHeader + '; ' + cookieString
+ } else {
+ this.headers.cookie = cookieString
+ }
+ }
+ this._jar = jar
+ return this
+}
+
+
+// Stream API
+Request.prototype.pipe = function (dest, opts) {
if (this.response) {
if (this._destdata) {
throw new Error("You cannot pipe after data has been emitted from the response.")
} else if (this._ended) {
throw new Error("You cannot pipe after the response has been ended.")
} else {
- stream.Stream.prototype.pipe.call(this, dest)
+ stream.Stream.prototype.pipe.call(this, dest, opts)
this.pipeDest(dest)
return dest
}
} else {
this.dests.push(dest)
- stream.Stream.prototype.pipe.call(this, dest)
+ stream.Stream.prototype.pipe.call(this, dest, opts)
return dest
}
}
Request.prototype.write = function () {
if (!this._started) this.start()
- if (!this.req) throw new Error("This request has been piped before http.request() was called.")
this.req.write.apply(this.req, arguments)
}
-Request.prototype.end = function () {
+Request.prototype.end = function (chunk) {
+ if (chunk) this.write(chunk)
if (!this._started) this.start()
- if (!this.req) throw new Error("This request has been piped before http.request() was called.")
- this.req.end.apply(this.req, arguments)
+ this.req.end()
}
Request.prototype.pause = function () {
- if (!this.response) throw new Error("This request has been piped before http.request() was called.")
- this.response.pause.apply(this.response, arguments)
+ if (!this.response) this._paused = true
+ else this.response.pause.apply(this.response, arguments)
}
Request.prototype.resume = function () {
- if (!this.response) throw new Error("This request has been piped before http.request() was called.")
- this.response.resume.apply(this.response, arguments)
+ if (!this.response) this._paused = false
+ else this.response.resume.apply(this.response, arguments)
+}
+Request.prototype.destroy = function () {
+ if (!this._ended) this.end()
}
-function request (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- if (callback) options.callback = callback
+// organize params for post, put, head, del
+function initParams(uri, options, callback) {
+ if ((typeof options === 'function') && !callback) callback = options;
+ if (typeof options === 'object') {
+ options.uri = uri;
+ } else if (typeof uri === 'string') {
+ options = {uri:uri};
+ } else {
+ options = uri;
+ uri = options.uri;
+ }
+ return { uri: uri, options: options, callback: callback };
+}
+
+function request (uri, options, callback) {
+ if (typeof uri === 'undefined') throw new Error('undefined is not a valid uri or options object.')
+ if ((typeof options === 'function') && !callback) callback = options;
+ if (typeof options === 'object') {
+ options.uri = uri;
+ } else if (typeof uri === 'string') {
+ options = {uri:uri};
+ } else {
+ options = uri;
+ }
+
+ if (callback) options.callback = callback;
var r = new Request(options)
- r.request()
return r
}
@@ -588,12 +886,12 @@ module.exports = request
request.defaults = function (options) {
var def = function (method) {
- var d = function (opts, callback) {
- if (typeof opts === 'string') opts = {uri:opts}
+ var d = function (uri, opts, callback) {
+ var params = initParams(uri, opts, callback);
for (var i in options) {
- if (opts[i] === undefined) opts[i] = options[i]
+ if (params.options[i] === undefined) params.options[i] = options[i]
}
- return method(opts, callback)
+ return method(params.uri, params.options, params.callback)
}
return d
}
@@ -610,43 +908,48 @@ request.defaults = function (options) {
request.forever = function (agentOptions, optionsArg) {
var options = {}
- if (agentOptions) {
+ if (optionsArg) {
for (option in optionsArg) {
options[option] = optionsArg[option]
}
}
- options.agent = new ForeverAgent(agentOptions)
+ if (agentOptions) options.agentOptions = agentOptions
+ options.forever = true
return request.defaults(options)
}
request.get = request
-request.post = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'POST'
- return request(options, callback)
-}
-request.put = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'PUT'
- return request(options, callback)
-}
-request.head = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'HEAD'
- if (options.body || options.requestBodyStream || options.json || options.multipart) {
+request.post = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'POST';
+ return request(params.uri || null, params.options, params.callback)
+}
+request.put = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'PUT'
+ return request(params.uri || null, params.options, params.callback)
+}
+request.head = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'HEAD'
+ if (params.options.body ||
+ params.options.requestBodyStream ||
+ (params.options.json && typeof params.options.json !== 'boolean') ||
+ params.options.multipart) {
throw new Error("HTTP HEAD requests MUST NOT include a request body.")
}
- return request(options, callback)
+ return request(params.uri || null, params.options, params.callback)
}
-request.del = function (options, callback) {
- if (typeof options === 'string') options = {uri:options}
- options.method = 'DELETE'
- return request(options, callback)
+request.del = function (uri, options, callback) {
+ var params = initParams(uri, options, callback);
+ params.options.method = 'DELETE'
+ return request(params.uri || null, params.options, params.callback)
}
request.jar = function () {
return new CookieJar
}
request.cookie = function (str) {
+ if (str && str.uri) str = str.uri
if (typeof str !== 'string') throw new Error("The cookie function only accepts STRING as param")
return new Cookie(str)
}
diff --git a/deps/npm/node_modules/request/mimetypes.js b/deps/npm/node_modules/request/mimetypes.js
index 86910064c9..59b21b419c 100644
--- a/deps/npm/node_modules/request/mimetypes.js
+++ b/deps/npm/node_modules/request/mimetypes.js
@@ -1,5 +1,6 @@
// from http://github.com/felixge/node-paperboy
exports.types = {
+ "3gp":"video/3gpp",
"aiff":"audio/x-aiff",
"arj":"application/x-arj-compressed",
"asf":"video/x-ms-asf",
@@ -50,17 +51,21 @@ exports.types = {
"lzh":"application/octet-stream",
"m":"text/plain",
"m3u":"audio/x-mpegurl",
+ "m4v":"video/mp4",
"man":"application/x-troff-man",
"me":"application/x-troff-me",
"midi":"audio/midi",
"mif":"application/x-mif",
"mime":"www/mime",
+ "mkv":" video/x-matrosk",
"movie":"video/x-sgi-movie",
- "mustache":"text/plain",
"mp4":"video/mp4",
+ "mp41":"video/mp4",
+ "mp42":"video/mp4",
"mpg":"video/mpeg",
"mpga":"audio/mpeg",
"ms":"application/x-troff-ms",
+ "mustache":"text/plain",
"nc":"application/x-netcdf",
"oda":"application/oda",
"ogm":"application/ogg",
@@ -123,6 +128,7 @@ exports.types = {
"vrm":"x-world/x-vrml",
"wav":"audio/x-wav",
"wax":"audio/x-ms-wax",
+ "webm":"video/webm",
"wma":"audio/x-ms-wma",
"wmv":"video/x-ms-wmv",
"wmx":"video/x-ms-wmx",
@@ -134,7 +140,7 @@ exports.types = {
"xpm":"image/x-xpixmap",
"xwd":"image/x-xwindowdump",
"xyz":"chemical/x-pdb",
- "zip":"application/zip",
+ "zip":"application/zip"
};
exports.lookup = function(ext, defaultType) {
diff --git a/deps/npm/node_modules/request/oauth.js b/deps/npm/node_modules/request/oauth.js
index 25db669775..31b9dc65fe 100644
--- a/deps/npm/node_modules/request/oauth.js
+++ b/deps/npm/node_modules/request/oauth.js
@@ -19,7 +19,7 @@ function rfc3986 (str) {
function hmacsign (httpMethod, base_uri, params, consumer_secret, token_secret, body) {
// adapted from https://dev.twitter.com/docs/auth/oauth
var base =
- httpMethod + "&" +
+ (httpMethod || 'GET') + "&" +
encodeURIComponent( base_uri ) + "&" +
Object.keys(params).sort().map(function (i) {
// big WTF here with the escape + encoding but it's what twitter wants
diff --git a/deps/npm/node_modules/request/package.json b/deps/npm/node_modules/request/package.json
index e7b899a8b1..0e6ddc5d85 100644
--- a/deps/npm/node_modules/request/package.json
+++ b/deps/npm/node_modules/request/package.json
@@ -1,15 +1,45 @@
-{ "name" : "request"
-, "description" : "Simplified HTTP request client."
-, "tags" : ["http", "simple", "util", "utility"]
-, "version" : "2.9.3"
-, "author" : "Mikeal Rogers <mikeal.rogers@gmail.com>"
-, "repository" :
- { "type" : "git"
- , "url" : "http://github.com/mikeal/request.git"
- }
-, "bugs" :
- { "url" : "http://github.com/mikeal/request/issues" }
-, "engines" : ["node >= 0.3.6"]
-, "main" : "./main"
-, "scripts": { "test": "bash tests/run.sh" }
+{
+ "name": "request",
+ "description": "Simplified HTTP request client.",
+ "tags": [
+ "http",
+ "simple",
+ "util",
+ "utility"
+ ],
+ "version": "2.9.153",
+ "author": {
+ "name": "Mikeal Rogers",
+ "email": "mikeal.rogers@gmail.com"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/mikeal/request.git"
+ },
+ "bugs": {
+ "url": "http://github.com/mikeal/request/issues"
+ },
+ "engines": [
+ "node >= 0.3.6"
+ ],
+ "main": "./main",
+ "scripts": {
+ "test": "node tests/run.js"
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "request@2.9.153",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.8",
+ "_nodeVersion": "v0.6.12",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "6f07c2ba3acfbe0cfe941f43647102740f05ff73"
+ },
+ "_from": "../request"
}
diff --git a/deps/npm/node_modules/request/vendor/cookie/index.js b/deps/npm/node_modules/request/vendor/cookie/index.js
index 1eb2eaa220..ff44b3e629 100644
--- a/deps/npm/node_modules/request/vendor/cookie/index.js
+++ b/deps/npm/node_modules/request/vendor/cookie/index.js
@@ -21,22 +21,27 @@ var url = require('url');
var Cookie = exports = module.exports = function Cookie(str, req) {
this.str = str;
- // First key is the name
- this.name = str.substr(0, str.indexOf('=')).trim();
-
// Map the key/val pairs
str.split(/ *; */).reduce(function(obj, pair){
var p = pair.indexOf('=');
- if(p > 0)
- obj[pair.substring(0, p).trim()] = pair.substring(p + 1).trim();
- else
- obj[pair.trim()] = true;
+ var key = p > 0 ? pair.substring(0, p).trim() : pair.trim();
+ var lowerCasedKey = key.toLowerCase();
+ var value = p > 0 ? pair.substring(p + 1).trim() : true;
+
+ if (!obj.name) {
+ // First key is the name
+ obj.name = key;
+ obj.value = value;
+ }
+ else if (lowerCasedKey === 'httponly') {
+ obj.httpOnly = value;
+ }
+ else {
+ obj[lowerCasedKey] = value;
+ }
return obj;
}, this);
- // Assign value
- this.value = this[this.name];
-
// Expires
this.expires = this.expires
? new Date(this.expires)
diff --git a/deps/npm/node_modules/rimraf/AUTHORS b/deps/npm/node_modules/rimraf/AUTHORS
index 008cbe7dd9..247b754373 100644
--- a/deps/npm/node_modules/rimraf/AUTHORS
+++ b/deps/npm/node_modules/rimraf/AUTHORS
@@ -3,3 +3,4 @@ Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)
Wayne Larsen <wayne@larsen.st> (http://github.com/wvl)
ritch <skawful@gmail.com>
Marcel Laverdet
+Yosef Dinerstein <yosefd@microsoft.com>
diff --git a/deps/npm/node_modules/rimraf/README.md b/deps/npm/node_modules/rimraf/README.md
index 99983dc437..96ce9b2a0b 100644
--- a/deps/npm/node_modules/rimraf/README.md
+++ b/deps/npm/node_modules/rimraf/README.md
@@ -4,7 +4,7 @@ Install with `npm install rimraf`, or just drop rimraf.js somewhere.
## API
-`rimraf(f, [options,] callback)`
+`rimraf(f, callback)`
The callback will be called with an error if there is one. Certain
errors are handled for you:
@@ -14,17 +14,6 @@ errors are handled for you:
* `EMFILE` - If too many file descriptors get opened, rimraf will
patiently wait until more become available.
-## Options
-
-The options object is optional. These fields are respected:
-
-* `maxBusyTries` - The number of times to retry a file or folder in the
- event of an `EBUSY` error. The default is 3.
-* `gently` - If provided a `gently` path, then rimraf will only delete
- files and folders that are beneath this path, and only delete symbolic
- links that point to a place within this path. (This is very important
- to npm's use-case, and shows rimraf's pedigree.)
-
## rimraf.sync
diff --git a/deps/npm/node_modules/rimraf/fiber.js b/deps/npm/node_modules/rimraf/fiber.js
deleted file mode 100644
index 8812a6b449..0000000000
--- a/deps/npm/node_modules/rimraf/fiber.js
+++ /dev/null
@@ -1,86 +0,0 @@
-// fiber/future port originally written by Marcel Laverdet
-// https://gist.github.com/1131093
-// I updated it to bring to feature parity with cb version.
-// The bugs are probably mine, not Marcel's.
-// -- isaacs
-
-var path = require('path')
- , fs = require('fs')
- , Future = require('fibers/future')
-
-// Create future-returning fs functions
-var fs2 = {}
-for (var ii in fs) {
- fs2[ii] = Future.wrap(fs[ii])
-}
-
-// Return a future which just pauses for a certain amount of time
-
-function timer (ms) {
- var future = new Future
- setTimeout(function () {
- future.return()
- }, ms)
- return future
-}
-
-function realish (p) {
- return path.resolve(path.dirname(fs2.readlink(p)))
-}
-
-// for EMFILE backoff.
-var timeout = 0
- , EMFILE_MAX = 1000
-
-function rimraf_ (p, opts) {
- opts = opts || {}
- opts.maxBusyTries = opts.maxBusyTries || 3
- if (opts.gently) opts.gently = path.resolve(opts.gently)
- var busyTries = 0
-
- // exits by throwing or returning.
- // loops on handled errors.
- while (true) {
- try {
- var stat = fs2.lstat(p).wait()
-
- // check to make sure that symlinks are ours.
- if (opts.gently) {
- var rp = stat.isSymbolicLink() ? realish(p) : path.resolve(p)
- if (rp.indexOf(opts.gently) !== 0) {
- var er = new Error("Refusing to delete: "+p+" not in "+opts.gently)
- er.errno = require("constants").EEXIST
- er.code = "EEXIST"
- er.path = p
- throw er
- }
- }
-
- if (!stat.isDirectory()) return fs2.unlink(p).wait()
-
- var rimrafs = fs2.readdir(p).wait().map(function (file) {
- return rimraf(path.join(p, file), opts)
- })
-
- Future.wait(rimrafs)
- fs2.rmdir(p).wait()
- timeout = 0
- return
-
- } catch (er) {
- if (er.message.match(/^EMFILE/) && timeout < EMFILE_MAX) {
- timer(timeout++).wait()
- } else if (er.message.match(/^EBUSY/)
- && busyTries < opt.maxBusyTries) {
- timer(++busyTries * 100).wait()
- } else if (er.message.match(/^ENOENT/)) {
- // already gone
- return
- } else {
- throw er
- }
- }
- }
-}
-
-var rimraf = module.exports = rimraf_.future()
diff --git a/deps/npm/node_modules/rimraf/package.json b/deps/npm/node_modules/rimraf/package.json
index 2b69536ef9..952bc8af9f 100644
--- a/deps/npm/node_modules/rimraf/package.json
+++ b/deps/npm/node_modules/rimraf/package.json
@@ -1,9 +1,10 @@
{"name":"rimraf"
-,"version":"1.0.9"
+,"version":"2.0.1"
,"main":"rimraf.js"
,"description":"A deep deletion module for node (like `rm -rf`)"
,"author":"Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)"
,"license":
{"type":"MIT", "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE"}
+,"optionalDependencies":{"graceful-fs":"~1.1"}
,"repository":"git://github.com/isaacs/rimraf.git"
,"scripts":{"test":"cd test && bash run.sh"}}
diff --git a/deps/npm/node_modules/rimraf/rimraf.js b/deps/npm/node_modules/rimraf/rimraf.js
index e8104e9e4b..67d018ab4a 100644
--- a/deps/npm/node_modules/rimraf/rimraf.js
+++ b/deps/npm/node_modules/rimraf/rimraf.js
@@ -16,34 +16,30 @@ var lstat = process.platform === "win32" ? "stat" : "lstat"
// for EMFILE handling
var timeout = 0
- , EMFILE_MAX = 1000
+exports.EMFILE_MAX = 1000
+exports.BUSYTRIES_MAX = 3
-function rimraf (p, opts, cb) {
- if (typeof opts === "function") cb = opts, opts = {}
+function rimraf (p, cb) {
if (!cb) throw new Error("No callback passed to rimraf()")
- if (!opts) opts = {}
var busyTries = 0
- opts.maxBusyTries = opts.maxBusyTries || 3
- if (opts.gently) opts.gently = path.resolve(opts.gently)
-
- rimraf_(p, opts, function CB (er) {
+ rimraf_(p, function CB (er) {
if (er) {
- if (er.code === "EBUSY" && busyTries < opts.maxBusyTries) {
- var time = (opts.maxBusyTries - busyTries) * 100
+ if (er.code === "EBUSY" && busyTries < exports.BUSYTRIES_MAX) {
+ var time = (exports.BUSYTRIES_MAX - busyTries) * 100
busyTries ++
// try again, with the same exact callback as this one.
return setTimeout(function () {
- rimraf_(p, opts, CB)
+ rimraf_(p, CB)
})
}
// this one won't happen if graceful-fs is used.
- if (er.code === "EMFILE" && timeout < EMFILE_MAX) {
+ if (er.code === "EMFILE" && timeout < exports.EMFILE_MAX) {
return setTimeout(function () {
- rimraf_(p, opts, CB)
+ rimraf_(p, CB)
}, timeout ++)
}
@@ -56,9 +52,8 @@ function rimraf (p, opts, cb) {
})
}
-function rimraf_ (p, opts, cb) {
+function rimraf_ (p, cb) {
fs[lstat](p, function (er, s) {
- // if the stat fails, then assume it's already gone.
if (er) {
// already gone
if (er.code === "ENOENT") return cb()
@@ -66,20 +61,55 @@ function rimraf_ (p, opts, cb) {
return cb(er)
}
- // don't delete that don't point actually live in the "gently" path
- if (opts.gently) return clobberTest(p, s, opts, cb)
- return rm_(p, s, opts, cb)
+ return rm_(p, s, false, cb)
})
}
-function rm_ (p, s, opts, cb) {
- if (!s.isDirectory()) return fs.unlink(p, cb)
+
+var myGid = function myGid () {
+ var g = process.getuid && process.getgid()
+ myGid = function myGid () { return g }
+ return g
+}
+
+var myUid = function myUid () {
+ var u = process.getuid && process.getuid()
+ myUid = function myUid () { return u }
+ return u
+}
+
+
+function writable (s) {
+ var mode = s.mode || 0777
+ , uid = myUid()
+ , gid = myGid()
+ return (mode & 0002)
+ || (gid === s.gid && (mode & 0020))
+ || (uid === s.uid && (mode & 0200))
+}
+
+function rm_ (p, s, didWritableCheck, cb) {
+ if (!didWritableCheck && !writable(s)) {
+ // make file writable
+ // user/group/world, doesn't matter at this point
+ // since it's about to get nuked.
+ return fs.chmod(p, s.mode | 0222, function (er) {
+ if (er) return cb(er)
+ rm_(p, s, true, cb)
+ })
+ }
+
+ if (!s.isDirectory()) {
+ return fs.unlink(p, cb)
+ }
+
+ // directory
fs.readdir(p, function (er, files) {
if (er) return cb(er)
asyncForEach(files.map(function (f) {
return path.join(p, f)
}), function (file, cb) {
- rimraf(file, opts, cb)
+ rimraf(file, cb)
}, function (er) {
if (er) return cb(er)
fs.rmdir(p, cb)
@@ -87,34 +117,6 @@ function rm_ (p, s, opts, cb) {
})
}
-function clobberTest (p, s, opts, cb) {
- var gently = opts.gently
- if (!s.isSymbolicLink()) next(null, path.resolve(p))
- else realish(p, next)
-
- function next (er, rp) {
- if (er) return rm_(p, s, cb)
- if (rp.indexOf(gently) !== 0) return clobberFail(p, gently, cb)
- else return rm_(p, s, opts, cb)
- }
-}
-
-function realish (p, cb) {
- fs.readlink(p, function (er, r) {
- if (er) return cb(er)
- return cb(null, path.resolve(path.dirname(p), r))
- })
-}
-
-function clobberFail (p, g, cb) {
- var er = new Error("Refusing to delete: "+p+" not in "+g)
- , constants = require("constants")
- er.errno = constants.EEXIST
- er.code = "EEXIST"
- er.path = p
- return cb(er)
-}
-
function asyncForEach (list, fn, cb) {
if (!list.length) cb()
var c = list.length
@@ -137,7 +139,13 @@ function rimrafSync (p) {
if (er.code === "ENOENT") return
throw er
}
+
+ if (!writable(s)) {
+ fs.chmodSync(p, s.mode | 0222)
+ }
+
if (!s.isDirectory()) return fs.unlinkSync(p)
+
fs.readdirSync(p).forEach(function (f) {
rimrafSync(path.join(p, f))
})
diff --git a/deps/npm/node_modules/tar/lib/extract.js b/deps/npm/node_modules/tar/lib/extract.js
index e45974c723..c34a81e21f 100644
--- a/deps/npm/node_modules/tar/lib/extract.js
+++ b/deps/npm/node_modules/tar/lib/extract.js
@@ -24,6 +24,10 @@ function Extract (opts) {
opts.type = "Directory"
opts.Directory = true
+ // similar to --strip or --strip-components
+ opts.strip = +opts.strip
+ if (!opts.strip || opts.strip <= 0) opts.strip = 0
+
this._fst = fstream.Writer(opts)
this.pause()
@@ -33,6 +37,16 @@ function Extract (opts) {
// of the tarball. So, they need to be resolved against
// the target directory in order to be created properly.
me.on("entry", function (entry) {
+ // if there's a "strip" argument, then strip off that many
+ // path components.
+ if (opts.strip) {
+ var p = entry.path.split("/").slice(opts.strip).join("/")
+ entry.path = entry.props.path = p
+ if (entry.linkpath) {
+ var lp = entry.linkpath.split("/").slice(opts.strip).join("/")
+ entry.linkpath = entry.props.linkpath = lp
+ }
+ }
if (entry.type !== "Link") return
entry.linkpath = entry.props.linkpath =
path.join(opts.path, path.join("/", entry.props.linkpath))
diff --git a/deps/npm/node_modules/tar/package.json b/deps/npm/node_modules/tar/package.json
index aa53022c64..849d0d6918 100644
--- a/deps/npm/node_modules/tar/package.json
+++ b/deps/npm/node_modules/tar/package.json
@@ -1,8 +1,12 @@
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
"name": "tar",
"description": "tar for node",
- "version": "0.1.12",
+ "version": "0.1.13",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-tar.git"
@@ -22,5 +26,19 @@
"devDependencies": {
"tap": "0.x",
"rimraf": "1.x"
- }
+ },
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "tar@0.1.13",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.4",
+ "_nodeVersion": "v0.7.6-pre",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "804bdaaacaab928ec1c9bbd8b848a042c3adacb2"
+ },
+ "_from": "tar@0.1.13"
}
diff --git a/deps/npm/node_modules/which/package.json b/deps/npm/node_modules/which/package.json
index 02990697f7..c45dafee92 100644
--- a/deps/npm/node_modules/which/package.json
+++ b/deps/npm/node_modules/which/package.json
@@ -1,17 +1,34 @@
{
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "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",
+ "version": "1.0.5",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-which.git"
},
"main": "which.js",
- "bin": "./bin/which",
+ "bin": {
+ "which": "./bin/which"
+ },
"engines": {
"node": "*"
},
"dependencies": {},
- "devDependencies": {}
+ "devDependencies": {},
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "_id": "which@1.0.5",
+ "optionalDependencies": {},
+ "_engineSupported": true,
+ "_npmVersion": "1.1.2",
+ "_nodeVersion": "v0.7.6-pre",
+ "_defaultsLoaded": true,
+ "_from": "which@1"
}
diff --git a/deps/npm/node_modules/which/which.js b/deps/npm/node_modules/which/which.js
index b124ead672..db7e8f74dc 100644
--- a/deps/npm/node_modules/which/which.js
+++ b/deps/npm/node_modules/which/which.js
@@ -4,6 +4,7 @@ which.sync = whichSync
var path = require("path")
, fs
, COLON = process.platform === "win32" ? ";" : ":"
+ , isExe
try {
fs = require("graceful-fs")
@@ -11,24 +12,31 @@ try {
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
+if (process.platform == "win32") {
+ // On windows, there is no good way to check that a file is executable
+ isExe = function isExe () { return true }
+} else {
+ isExe = function isExe (mod, uid, gid) {
+ //console.error(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)
+ 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) {
@@ -52,16 +60,45 @@ 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)
- 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
+ for (var j = 0, ll = pathExt.length; j < ll; j ++) {
+ var cur = p + pathExt[j]
+ var stat
+ try { stat = fs.statSync(cur) } catch (ex) {}
+ if (stat &&
+ stat.isFile() &&
+ isExe(stat.mode, stat.uid, stat.gid)) return cur
+ }
}
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 === ""
+}