fstream
Advanced tools
Comparing version 0.1.2 to 0.1.3
var fstream = require("../fstream.js") | ||
var tap = require("tap") | ||
var fs = require("fs") | ||
var path = require("path") | ||
var children = -1 | ||
var dir = path.dirname(__dirname) | ||
@@ -11,3 +13,3 @@ var gotReady = false | ||
var r = fstream.Reader({ path: path.dirname(__dirname) | ||
var r = fstream.Reader({ path: dir | ||
, filter: function () { | ||
@@ -21,3 +23,4 @@ // return this.parent === r | ||
gotReady = true | ||
children = r.props.nlink | ||
children = fs.readdirSync(dir).length | ||
console.error("Setting expected children to "+children) | ||
t.equal(r.type, "Directory", "should be a directory") | ||
@@ -28,2 +31,5 @@ }) | ||
children -- | ||
if (!gotReady) { | ||
t.fail("children before ready!") | ||
} | ||
t.equal(entry.dirname, r.path, "basename is parent dir") | ||
@@ -39,4 +45,3 @@ }) | ||
r.on("end", function () { | ||
// 2 because "." and ".." aren't traversed | ||
t.equal(children, 2, "should have seen all children") | ||
t.equal(children, 0, "should have seen all children") | ||
ended = true | ||
@@ -43,0 +48,0 @@ }) |
@@ -41,2 +41,3 @@ // A thing that emits "entry" events with Reader objects | ||
me._length = entries.length | ||
// console.error("DR %s sort =", me.path, me.props.sort) | ||
if (typeof me.props.sort === "function") { | ||
@@ -64,7 +65,4 @@ me._entries.sort(me.props.sort) | ||
me._ended = true | ||
// console.error(" DR End/close", me._path, new Error("trace").stack) | ||
me.emit("end") | ||
// console.error(" DR emitted end, emitting close", me._path) | ||
me.emit("close") | ||
// console.error(" DR After End/close", me._path) | ||
} | ||
@@ -89,2 +87,3 @@ return | ||
, filter: me.filter | ||
, sort: me.props.sort | ||
}, stat) | ||
@@ -91,0 +90,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Advanced file system stream things", | ||
"version": "0.1.1", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -18,3 +18,3 @@ "type": "git", | ||
"mkdirp": "~0.1.0", | ||
"graceful-fs": "1.1", | ||
"graceful-fs": "~1.1.1", | ||
"inherits": "~1.0.0" | ||
@@ -26,4 +26,4 @@ }, | ||
"scripts": { | ||
"test": "cd examples; tap *.js" | ||
"test": "tap examples/*.js" | ||
} | ||
} |
var fstream = require("../fstream.js") | ||
var tap = require("tap") | ||
var fs = require("fs") | ||
var path = require("path") | ||
var children = -1 | ||
var dir = path.dirname(__dirname) | ||
@@ -11,3 +13,3 @@ var gotReady = false | ||
var r = fstream.Reader({ path: path.dirname(__dirname) | ||
var r = fstream.Reader({ path: dir | ||
, filter: function () { | ||
@@ -21,3 +23,4 @@ // return this.parent === r | ||
gotReady = true | ||
children = r.props.nlink | ||
children = fs.readdirSync(dir).length | ||
console.error("Setting expected children to "+children) | ||
t.equal(r.type, "Directory", "should be a directory") | ||
@@ -28,2 +31,5 @@ }) | ||
children -- | ||
if (!gotReady) { | ||
t.fail("children before ready!") | ||
} | ||
t.equal(entry.dirname, r.path, "basename is parent dir") | ||
@@ -39,4 +45,3 @@ }) | ||
r.on("end", function () { | ||
// 2 because "." and ".." aren't traversed | ||
t.equal(children, 2, "should have seen all children") | ||
t.equal(children, 0, "should have seen all children") | ||
ended = true | ||
@@ -43,0 +48,0 @@ }) |
@@ -41,2 +41,3 @@ // A thing that emits "entry" events with Reader objects | ||
me._length = entries.length | ||
// console.error("DR %s sort =", me.path, me.props.sort) | ||
if (typeof me.props.sort === "function") { | ||
@@ -85,2 +86,3 @@ me._entries.sort(me.props.sort) | ||
, filter: me.filter | ||
, sort: me.props.sort | ||
}, stat) | ||
@@ -87,0 +89,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Advanced file system stream things", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -25,4 +25,4 @@ "type": "git", | ||
"scripts": { | ||
"test": "cd examples; tap *.js" | ||
"test": "tap examples/*.js" | ||
} | ||
} |
105290
3146
6