Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update fstream to 0.1.16

  • Loading branch information...
commit d7ae043d28fffe1532690a860cb47347dd2a3b47 1 parent 79f8d54
isaacs isaacs authored
35 node_modules/fstream/lib/dir-reader.js
View
@@ -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)
+}
4 node_modules/fstream/lib/dir-writer.js
View
@@ -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()
1  node_modules/fstream/lib/link-writer.js
View
@@ -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")
6 node_modules/fstream/package.json
View
@@ -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"
}
Please sign in to comment.
Something went wrong with that request. Please try again.