diff options
author | isaacs <i@izs.me> | 2012-03-27 10:43:23 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-03-27 11:17:35 +0400 |
commit | d7ae043d28fffe1532690a860cb47347dd2a3b47 (patch) | |
tree | cb5618041acd831c68efd274913c98d365a4db8c /node_modules/fstream | |
parent | 79f8d5403dbe802404e6faa359e07aacf91522ad (diff) |
Update fstream to 0.1.16
Diffstat (limited to 'node_modules/fstream')
-rw-r--r-- | node_modules/fstream/lib/dir-reader.js | 35 | ||||
-rw-r--r-- | node_modules/fstream/lib/dir-writer.js | 4 | ||||
-rw-r--r-- | node_modules/fstream/lib/link-writer.js | 1 | ||||
-rw-r--r-- | node_modules/fstream/package.json | 6 |
4 files changed, 32 insertions, 14 deletions
diff --git a/node_modules/fstream/lib/dir-reader.js b/node_modules/fstream/lib/dir-reader.js index 08ecf13ac..ef769dd33 100644 --- a/node_modules/fstream/lib/dir-reader.js +++ b/node_modules/fstream/lib/dir-reader.js @@ -30,11 +30,21 @@ function DirReader (props) { 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) @@ -46,9 +56,8 @@ DirReader.prototype._getEntries = function () { function processEntries () { me._length = me.entries.length - // console.error("DR %s sort =", me.path, me.props.sort) - if (typeof me.props.sort === "function") { - me.entries.sort(me.props.sort) + if (typeof me.sort === "function") { + me.entries = me.entries.sort(me.sort.bind(me)) } me._read() } @@ -67,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") @@ -89,8 +98,14 @@ DirReader.prototype._read = function () { if (er) return me.error(er) 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) @@ -135,8 +150,7 @@ DirReader.prototype._read = function () { if (entry.type === "Socket") { me.emit("socket", entry) } else { - me.emit("entry", entry) - me.emit("child", entry) + me.emitEntry(entry) } }) @@ -221,8 +235,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/node_modules/fstream/lib/dir-writer.js b/node_modules/fstream/lib/dir-writer.js index 26338bd99..7073b883e 100644 --- a/node_modules/fstream/lib/dir-writer.js +++ b/node_modules/fstream/lib/dir-writer.js @@ -100,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() diff --git a/node_modules/fstream/lib/link-writer.js b/node_modules/fstream/lib/link-writer.js index 8a9816380..5c8f1e701 100644 --- a/node_modules/fstream/lib/link-writer.js +++ b/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/node_modules/fstream/package.json b/node_modules/fstream/package.json index c6cd205a9..425308ead 100644 --- a/node_modules/fstream/package.json +++ b/node_modules/fstream/package.json @@ -6,7 +6,7 @@ }, "name": "fstream", "description": "Advanced file system stream things", - "version": "0.1.15", + "version": "0.1.16", "repository": { "type": "git", "url": "git://github.com/isaacs/fstream.git" @@ -32,11 +32,11 @@ "name": "isaacs", "email": "i@izs.me" }, - "_id": "fstream@0.1.15", + "_id": "fstream@0.1.16", "optionalDependencies": {}, "_engineSupported": true, "_npmVersion": "1.1.12", "_nodeVersion": "v0.7.7-pre", "_defaultsLoaded": true, - "_from": "fstream@~0.1.13" + "_from": "fstream@~0.1.15" } |