From eac48fe38b4a23f2d8583f60bbaad5801a5ff70c Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 19 Mar 2012 19:09:41 -0700 Subject: [PATCH] Update the bundled fstream to v0.1.14 --- node_modules/fstream/.npmignore | 4 +- node_modules/fstream/LICENCE | 25 ++++ node_modules/fstream/examples/filter-pipe.js | 131 ++++++++++++++++++ node_modules/fstream/lib/dir-writer.js | 3 + node_modules/fstream/lib/proxy-reader.js | 3 + node_modules/fstream/lib/writer.js | 9 ++ .../node_modules/graceful-fs/graceful-fs.js | 3 +- .../node_modules/graceful-fs/package.json | 27 +++- .../node_modules/inherits/package.json | 48 ++++++- node_modules/fstream/package.json | 29 +++- 10 files changed, 262 insertions(+), 20 deletions(-) create mode 100644 node_modules/fstream/LICENCE create mode 100644 node_modules/fstream/examples/filter-pipe.js diff --git a/node_modules/fstream/.npmignore b/node_modules/fstream/.npmignore index 66880db..494272a 100644 --- a/node_modules/fstream/.npmignore +++ b/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/node_modules/fstream/LICENCE b/node_modules/fstream/LICENCE new file mode 100644 index 0000000..74489e2 --- /dev/null +++ b/node_modules/fstream/LICENCE @@ -0,0 +1,25 @@ +Copyright (c) Isaac Z. Schlueter +All rights reserved. + +The BSD License + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/fstream/examples/filter-pipe.js b/node_modules/fstream/examples/filter-pipe.js new file mode 100644 index 0000000..c6b55b3 --- /dev/null +++ b/node_modules/fstream/examples/filter-pipe.js @@ -0,0 +1,131 @@ +var fstream = require("../fstream.js") +var path = require("path") + +var r = fstream.Reader({ path: path.dirname(__dirname) + , filter: function () { + return !this.basename.match(/^\./) && + !this.basename.match(/^node_modules$/) + !this.basename.match(/^deep-copy$/) + !this.basename.match(/^filter-copy$/) + } + }) + +// this writer will only write directories +var w = fstream.Writer({ path: path.resolve(__dirname, "filter-copy") + , type: "Directory" + , filter: function () { + return this.type === "Directory" + } + }) + +var indent = "" +var escape = {} + +r.on("entry", appears) +r.on("ready", function () { + console.error("ready to begin!", r.path) +}) + +function appears (entry) { + console.error(indent + "a %s appears!", entry.type, entry.basename, typeof entry.basename) + if (foggy) { + console.error("FOGGY!") + var p = entry + do { + console.error(p.depth, p.path, p._paused) + } while (p = p.parent) + + throw new Error("\033[mshould not have entries while foggy") + } + indent += "\t" + entry.on("data", missile(entry)) + entry.on("end", runaway(entry)) + entry.on("entry", appears) +} + +var foggy +function missile (entry) { + if (entry.type === "Directory") { + var ended = false + entry.once("end", function () { ended = true }) + return function (c) { + // throw in some pathological pause()/resume() behavior + // just for extra fun. + process.nextTick(function () { + if (!foggy && !ended) { // && Math.random() < 0.3) { + console.error(indent +"%s casts a spell", entry.basename) + console.error("\na slowing fog comes over the battlefield...\n\033[32m") + entry.pause() + entry.once("resume", liftFog) + foggy = setTimeout(liftFog, 1000) + + function liftFog (who) { + if (!foggy) return + if (who) { + console.error("%s breaks the spell!", who && who.path) + } else { + console.error("the spell expires!") + } + console.error("\033[mthe fog lifts!\n") + clearTimeout(foggy) + foggy = null + if (entry._paused) entry.resume() + } + + } + }) + } + } + + return function (c) { + var e = Math.random() < 0.5 + console.error(indent + "%s %s for %d damage!", + entry.basename, + e ? "is struck" : "fires a chunk", + c.length) + } +} + +function runaway (entry) { return function () { + var e = Math.random() < 0.5 + console.error(indent + "%s %s", + entry.basename, + e ? "turns to flee" : "is vanquished!") + indent = indent.slice(0, -1) +}} + + +w.on("entry", attacks) +//w.on("ready", function () { attacks(w) }) +function attacks (entry) { + console.error(indent + "%s %s!", entry.basename, + entry.type === "Directory" ? "calls for backup" : "attacks") + entry.on("entry", attacks) +} + +ended = false +var i = 1 +r.on("end", function () { + if (foggy) clearTimeout(foggy) + console.error("\033[mIT'S OVER!!") + console.error("A WINNAR IS YOU!") + + console.log("ok " + (i ++) + " A WINNAR IS YOU") + ended = true + // now go through and verify that everything in there is a dir. + var p = path.resolve(__dirname, "filter-copy") + var checker = fstream.Reader({ path: p }) + checker.checker = true + checker.on("child", function (e) { + var ok = e.type === "Directory" + console.log((ok ? "" : "not ") + "ok " + (i ++) + + " should be a dir: " + + e.path.substr(checker.path.length + 1)) + }) +}) + +process.on("exit", function () { + console.log((ended ? "" : "not ") + "ok " + (i ++) + " ended") +}) + +r.pipe(w) diff --git a/node_modules/fstream/lib/dir-writer.js b/node_modules/fstream/lib/dir-writer.js index 11b6654..26338bd 100644 --- a/node_modules/fstream/lib/dir-writer.js +++ b/node_modules/fstream/lib/dir-writer.js @@ -123,6 +123,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/node_modules/fstream/lib/proxy-reader.js b/node_modules/fstream/lib/proxy-reader.js index f99b28f..f5ddfc3 100644 --- a/node_modules/fstream/lib/proxy-reader.js +++ b/node_modules/fstream/lib/proxy-reader.js @@ -59,6 +59,9 @@ ProxyReader.prototype._addProxy = function (proxy) { , "close" , "linkpath" , "entry" + , "entryEnd" + , "child" + , "childEnd" , "warn" ].forEach(function (ev) { // console.error("~~ proxy event", ev, me.path) diff --git a/node_modules/fstream/lib/writer.js b/node_modules/fstream/lib/writer.js index dde29fd..b7cd261 100644 --- a/node_modules/fstream/lib/writer.js +++ b/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. @@ -126,6 +128,13 @@ Writer.prototype._stat = function (current) { else fs[stat](me._path, statCb) function statCb (er, current) { + if (me.filter && !me.filter.call(me._proxy || me, 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) { diff --git a/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js b/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js index 8081047..9207378 100644 --- a/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js +++ b/node_modules/fstream/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") diff --git a/node_modules/fstream/node_modules/graceful-fs/package.json b/node_modules/fstream/node_modules/graceful-fs/package.json index 98fc779..05b9c61 100644 --- a/node_modules/fstream/node_modules/graceful-fs/package.json +++ b/node_modules/fstream/node_modules/graceful-fs/package.json @@ -1,8 +1,12 @@ { - "author": "Isaac Z. Schlueter (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.5", + "version": "1.1.6", "repository": { "type": "git", "url": "git://github.com/isaacs/node-graceful-fs.git" @@ -11,8 +15,21 @@ "engines": { "node": ">=0.4.0" }, - "dependencies": { - "fast-list": "1" + "devDependencies": {}, + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" }, - "devDependencies": {} + "_id": "graceful-fs@1.1.6", + "dependencies": {}, + "optionalDependencies": {}, + "_engineSupported": true, + "_npmVersion": "1.1.9", + "_nodeVersion": "v0.6.13", + "_defaultsLoaded": true, + "dist": { + "shasum": "d0d5fb3ff6c6d625a071bc5061a44b0efc4a1f47" + }, + "_from": "graceful-fs@~1.1.2", + "scripts": {} } diff --git a/node_modules/fstream/node_modules/inherits/package.json b/node_modules/fstream/node_modules/inherits/package.json index 5beb005..229144f 100644 --- a/node_modules/fstream/node_modules/inherits/package.json +++ b/node_modules/fstream/node_modules/inherits/package.json @@ -1,7 +1,41 @@ -{ "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" -, "author" : "Isaac Z. Schlueter (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" + }, + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "_id": "inherits@1.0.0", + "dependencies": {}, + "devDependencies": {}, + "optionalDependencies": {}, + "engines": { + "node": "*" + }, + "_engineSupported": true, + "_npmVersion": "1.1.9", + "_nodeVersion": "v0.6.13", + "_defaultsLoaded": true, + "dist": { + "shasum": "662904d1fe699d60dacc7d5c16d1c05debd3c9a1" + }, + "_from": "inherits@1.x" +} diff --git a/node_modules/fstream/package.json b/node_modules/fstream/package.json index 90c687a..be732fd 100644 --- a/node_modules/fstream/package.json +++ b/node_modules/fstream/package.json @@ -1,15 +1,19 @@ { - "author": "Isaac Z. Schlueter (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.13", + "version": "0.1.14", "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": "2", @@ -18,9 +22,24 @@ "inherits": "~1.0.0" }, "devDependencies": { - "tap": "0.1" + "tap": "" }, "scripts": { "test": "tap examples/*.js" - } + }, + "license": "BSD", + "_npmUser": { + "name": "tootallnate", + "email": "nathan@tootallnate.net" + }, + "_id": "fstream@0.1.14", + "optionalDependencies": {}, + "_engineSupported": true, + "_npmVersion": "1.1.9", + "_nodeVersion": "v0.6.13", + "_defaultsLoaded": true, + "dist": { + "shasum": "f5941062531126749ce385aed910e5fbac5edaee" + }, + "_from": "fstream@0.1.14" }