Add 'fstream' as a dependency.

This commit is contained in:
Nathan Rajlich 2012-02-27 13:00:27 -08:00
parent 301f8b82ec
commit 72fa76e585
88 changed files with 156 additions and 708 deletions

View file

@ -12,8 +12,8 @@
"node": "0.5 || 0.6 || 0.7" "node": "0.5 || 0.6 || 0.7"
}, },
"dependencies": { "dependencies": {
"rimraf": "~1.0.8", "rimraf": "2",
"mkdirp": "~0.1.0", "mkdirp": "0.3",
"graceful-fs": "~1.1.2", "graceful-fs": "~1.1.2",
"inherits": "~1.0.0" "inherits": "~1.0.0"
}, },

View file

@ -115,8 +115,16 @@ DirReader.prototype._read = function () {
return me.once("resume", EMITCHILD) return me.once("resume", EMITCHILD)
} }
// skip over sockets. they can't be piped around properly,
// so there's really no sense even acknowledging them.
// if someone really wants to see them, they can listen to
// the "socket" events.
if (entry.type === "Socket") {
me.emit("socket", entry)
} else {
me.emit("entry", entry) me.emit("entry", entry)
me.emit("child", entry) me.emit("child", entry)
}
}) })
var ended = false var ended = false

View file

@ -21,6 +21,7 @@ function LinkWriter (props) {
throw new Error("Non-link type "+ props.type) throw new Error("Non-link type "+ props.type)
} }
if (props.linkpath === "") props.linkpath = "."
if (!props.linkpath) { if (!props.linkpath) {
me.error("Need linkpath property to create " + props.type) me.error("Need linkpath property to create " + props.type)
} }
@ -60,8 +61,14 @@ function create (me, lp, link) {
// directory, it's very possible that the thing we're linking to // directory, it's very possible that the thing we're linking to
// doesn't exist yet (especially if it was intended as a symlink), // doesn't exist yet (especially if it was intended as a symlink),
// so swallow ENOENT errors here and just soldier in. // so swallow ENOENT errors here and just soldier in.
// Additionally, an EPERM or EACCES can happen on win32 if it's trying
// to make a link to a directory. Again, just skip it.
// A better solution would be to have fs.symlink be supported on
// windows in some nice fashion.
if (er) { if (er) {
if (er.code === "ENOENT" && process.platform === "win32") { if ((er.code === "ENOENT" ||
er.code === "EACCES" ||
er.code === "EPERM" ) && process.platform === "win32") {
me.ready = true me.ready = true
me.emit("ready") me.emit("ready")
me.emit("end") me.emit("end")

View file

@ -15,6 +15,7 @@ inherits(Reader, Abstract)
var DirReader = require("./dir-reader.js") var DirReader = require("./dir-reader.js")
, FileReader = require("./file-reader.js") , FileReader = require("./file-reader.js")
, LinkReader = require("./link-reader.js") , LinkReader = require("./link-reader.js")
, SocketReader = require("./socket-reader.js")
, ProxyReader = require("./proxy-reader.js") , ProxyReader = require("./proxy-reader.js")
function Reader (props, currentStat) { function Reader (props, currentStat) {
@ -75,6 +76,10 @@ function Reader (props, currentStat) {
ClassType = LinkReader ClassType = LinkReader
break break
case "Socket":
ClassType = SocketReader
break
case null: case null:
ClassType = ProxyReader ClassType = ProxyReader
break break
@ -230,6 +235,6 @@ Reader.prototype.resume = function (who) {
} }
Reader.prototype._read = function () { Reader.prototype._read = function () {
me.warn("Cannot read unknown type: "+me.type) this.error("Cannot read unknown type: "+this.type)
} }

38
node_modules/fstream/lib/socket-reader.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
// Just get the stats, and then don't do anything.
// You can't really "read" from a socket. You "connect" to it.
// Mostly, this is here so that reading a dir with a socket in it
// doesn't blow up.
module.exports = SocketReader
var fs = require("graceful-fs")
, fstream = require("../fstream.js")
, inherits = require("inherits")
, mkdir = require("mkdirp")
, Reader = require("./reader.js")
inherits(SocketReader, Reader)
function SocketReader (props) {
var me = this
if (!(me instanceof SocketReader)) throw new Error(
"SocketReader must be called as constructor.")
if (!(props.type === "Socket" && props.Socket)) {
throw new Error("Non-socket type "+ props.type)
}
Reader.call(me, props)
}
SocketReader.prototype._read = function () {
var me = this
if (me._paused) return
// basically just a no-op, since we got all the info we have
// from the _stat method
if (!me._ended) {
me.emit("end")
me.emit("close")
me._ended = true
}
}

51
node_modules/fstream/node_modules/inherits/README.md generated vendored Normal file
View file

@ -0,0 +1,51 @@
A dead simple way to do inheritance in JS.
var inherits = require("inherits")
function Animal () {
this.alive = true
}
Animal.prototype.say = function (what) {
console.log(what)
}
inherits(Dog, Animal)
function Dog () {
Dog.super.apply(this)
}
Dog.prototype.sniff = function () {
this.say("sniff sniff")
}
Dog.prototype.bark = function () {
this.say("woof woof")
}
inherits(Chihuahua, Dog)
function Chihuahua () {
Chihuahua.super.apply(this)
}
Chihuahua.prototype.bark = function () {
this.say("yip yip")
}
// also works
function Cat () {
Cat.super.apply(this)
}
Cat.prototype.hiss = function () {
this.say("CHSKKSS!!")
}
inherits(Cat, Animal, {
meow: function () { this.say("miao miao") }
})
Cat.prototype.purr = function () {
this.say("purr purr")
}
var c = new Chihuahua
assert(c instanceof Chihuahua)
assert(c instanceof Dog)
assert(c instanceof Animal)
The actual function is laughably small. 10-lines small.

29
node_modules/fstream/node_modules/inherits/inherits.js generated vendored Normal file
View file

@ -0,0 +1,29 @@
module.exports = inherits
function inherits (c, p, proto) {
proto = proto || {}
var e = {}
;[c.prototype, proto].forEach(function (s) {
Object.getOwnPropertyNames(s).forEach(function (k) {
e[k] = Object.getOwnPropertyDescriptor(s, k)
})
})
c.prototype = Object.create(p.prototype, e)
c.super = p
}
//function Child () {
// Child.super.call(this)
// console.error([this
// ,this.constructor
// ,this.constructor === Child
// ,this.constructor.super === Parent
// ,Object.getPrototypeOf(this) === Child.prototype
// ,Object.getPrototypeOf(Object.getPrototypeOf(this))
// === Parent.prototype
// ,this instanceof Child
// ,this instanceof Parent])
//}
//function Parent () {}
//inherits(Child, Parent)
//new Child

View file

@ -0,0 +1,7 @@
{ "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 <i@izs.me> (http://blog.izs.me/)" }

View file

@ -2,7 +2,7 @@
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"name": "fstream", "name": "fstream",
"description": "Advanced file system stream things", "description": "Advanced file system stream things",
"version": "0.1.4", "version": "0.1.12",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/isaacs/fstream.git" "url": "git://github.com/isaacs/fstream.git"
@ -12,9 +12,9 @@
"node": "0.5 || 0.6 || 0.7" "node": "0.5 || 0.6 || 0.7"
}, },
"dependencies": { "dependencies": {
"rimraf": "~1.0.8", "rimraf": "2",
"mkdirp": "~0.1.0", "mkdirp": "0.3",
"graceful-fs": "~1.1.1", "graceful-fs": "~1.1.2",
"inherits": "~1.0.0" "inherits": "~1.0.0"
}, },
"devDependencies": { "devDependencies": {

View file

@ -1,2 +0,0 @@
node_modules/
npm-debug.log

View file

@ -1,5 +0,0 @@
--- /dev/null
+++ .gitignore
@@ -0,0 +1,2 @@
+node_modules/
+npm-debug.log

View file

@ -1,2 +0,0 @@
node_modules/
npm-debug.log

View file

@ -1,21 +0,0 @@
Copyright 2010 James Halliday (mail@substack.net)
This project is free software released under the MIT/X11 license:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.

View file

@ -1,21 +0,0 @@
mkdirp
======
Like `mkdir -p`, but in node.js!
Example
=======
pow.js
------
var mkdirp = require('mkdirp');
mkdirp('/tmp/foo/bar/baz', 0755, function (err) {
if (err) console.error(err)
else console.log('pow!')
});
Output
pow!
And now /tmp/foo/bar/baz exists, huzzah!

View file

@ -1,6 +0,0 @@
var mkdirp = require('mkdirp');
mkdirp('/tmp/foo/bar/baz', 0755, function (err) {
if (err) console.error(err)
else console.log('pow!')
});

View file

@ -1,6 +0,0 @@
var mkdirp = require('mkdirp');
mkdirp('/tmp/foo/bar/baz', 0755, function (err) {
if (err) console.error(err)
else console.log('pow!')
});

View file

@ -1,19 +0,0 @@
--- examples/pow.js
+++ examples/pow.js
@@ -1,6 +1,15 @@
-var mkdirp = require('mkdirp').mkdirp;
+var mkdirp = require('../').mkdirp,
+ mkdirpSync = require('../').mkdirpSync;
mkdirp('/tmp/foo/bar/baz', 0755, function (err) {
if (err) console.error(err)
else console.log('pow!')
});
+
+try {
+ mkdirpSync('/tmp/bar/foo/baz', 0755);
+ console.log('double pow!');
+}
+catch (ex) {
+ console.log(ex);
+}

View file

@ -1,36 +0,0 @@
var path = require('path');
var fs = require('fs');
module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
function mkdirP (p, mode, f) {
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();
switch (er.code) {
case 'ENOENT':
mkdirP(path.dirname(p), mode, function (er) {
if (er) cb(er);
else mkdirP(p, mode, cb);
});
break;
case 'EEXIST':
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();
});
break;
default:
cb(er);
break;
}
});
}

View file

@ -1,23 +0,0 @@
{
"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": "*" }
}

View file

@ -1,39 +0,0 @@
var mkdirp = require('../').mkdirp;
var path = require('path');
var fs = require('fs');
var test = require('tap').test;
var ps = [ '', 'tmp' ];
for (var i = 0; i < 25; i++) {
var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
ps.push(dir);
}
var file = ps.join('/');
test('chmod-pre', function (t) {
var mode = 0744
mkdirp(file, mode, function (er) {
t.ifError(er, 'should not error');
fs.stat(file, function (er, stat) {
t.ifError(er, 'should exist');
t.ok(stat && stat.isDirectory(), 'should be directory');
t.equal(stat && stat.mode & 0777, mode, 'should be 0744');
t.end();
});
});
});
test('chmod', function (t) {
var mode = 0755
mkdirp(file, mode, function (er) {
t.ifError(er, 'should not error');
fs.stat(file, function (er, stat) {
t.ifError(er, 'should exist');
t.ok(stat && stat.isDirectory(), 'should be directory');
t.equal(stat && stat.mode & 0777, mode, 'should be 0755');
t.end();
});
});
});

View file

@ -1,37 +0,0 @@
var mkdirp = require('../').mkdirp;
var path = require('path');
var fs = require('fs');
var test = require('tap').test;
var ps = [ '', 'tmp' ];
for (var i = 0; i < 25; i++) {
var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
ps.push(dir);
}
var file = ps.join('/');
// a file in the way
var itw = ps.slice(0, 3).join('/');
test('clobber-pre', function (t) {
console.error("about to write to "+itw)
fs.writeFileSync(itw, 'I AM IN THE WAY, THE TRUTH, AND THE LIGHT.');
fs.stat(itw, function (er, stat) {
t.ifError(er)
t.ok(stat && stat.isFile(), 'should be file')
t.end()
})
})
test('clobber', function (t) {
t.plan(2);
mkdirp(file, 0755, function (err) {
t.ok(err);
t.equal(err.code, 'ENOTDIR');
t.end();
});
});

View file

@ -1,28 +0,0 @@
var mkdirp = require('../');
var path = require('path');
var fs = require('fs');
var test = require('tap').test;
test('woo', function (t) {
t.plan(2);
var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var file = '/tmp/' + [x,y,z].join('/');
mkdirp(file, 0755, function (err) {
if (err) t.fail(err);
else path.exists(file, function (ex) {
if (!ex) t.fail('file not created')
else fs.stat(file, function (err, stat) {
if (err) t.fail(err)
else {
t.equal(stat.mode & 0777, 0755);
t.ok(stat.isDirectory(), 'target not a directory');
t.end();
}
})
})
});
});

View file

@ -1,41 +0,0 @@
var mkdirp = require('../').mkdirp;
var path = require('path');
var fs = require('fs');
var test = require('tap').test;
test('race', function (t) {
t.plan(4);
var ps = [ '', 'tmp' ];
for (var i = 0; i < 25; i++) {
var dir = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
ps.push(dir);
}
var file = ps.join('/');
var res = 2;
mk(file, function () {
if (--res === 0) t.end();
});
mk(file, function () {
if (--res === 0) t.end();
});
function mk (file, cb) {
mkdirp(file, 0755, function (err) {
if (err) t.fail(err);
else path.exists(file, function (ex) {
if (!ex) t.fail('file not created')
else fs.stat(file, function (err, stat) {
if (err) t.fail(err)
else {
t.equal(stat.mode & 0777, 0755);
t.ok(stat.isDirectory(), 'target not a directory');
if (cb) cb();
}
})
})
});
}
});

View file

@ -1,32 +0,0 @@
var mkdirp = require('../');
var path = require('path');
var fs = require('fs');
var test = require('tap').test;
test('rel', function (t) {
t.plan(2);
var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
var cwd = process.cwd();
process.chdir('/tmp');
var file = [x,y,z].join('/');
mkdirp(file, 0755, function (err) {
if (err) t.fail(err);
else path.exists(file, function (ex) {
if (!ex) t.fail('file not created')
else fs.stat(file, function (err, stat) {
if (err) t.fail(err)
else {
process.chdir(cwd);
t.equal(stat.mode & 0777, 0755);
t.ok(stat.isDirectory(), 'target not a directory');
t.end();
}
})
})
});
});

View file

@ -1,5 +0,0 @@
# Authors sorted by whether or not they're me.
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

View file

@ -1,23 +0,0 @@
Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
All rights reserved.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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.

View file

@ -1,32 +0,0 @@
A `rm -rf` for node.
Install with `npm install rimraf`, or just drop rimraf.js somewhere.
## API
`rimraf(f, [options,] callback)`
The callback will be called with an error if there is one. Certain
errors are handled for you:
* `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times
before giving up.
* `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
It can remove stuff synchronously, too. But that's not so good. Use
the async API. It's better.

View file

@ -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()

View file

@ -1,9 +0,0 @@
{"name":"rimraf"
,"version":"1.0.9"
,"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"}
,"repository":"git://github.com/isaacs/rimraf.git"
,"scripts":{"test":"cd test && bash run.sh"}}

View file

@ -1,145 +0,0 @@
module.exports = rimraf
rimraf.sync = rimrafSync
var path = require("path")
, fs
try {
// optional dependency
fs = require("graceful-fs")
} catch (er) {
fs = require("fs")
}
var lstat = process.platform === "win32" ? "stat" : "lstat"
, lstatSync = lstat + "Sync"
// for EMFILE handling
var timeout = 0
, EMFILE_MAX = 1000
function rimraf (p, opts, cb) {
if (typeof opts === "function") cb = opts, opts = {}
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) {
if (er) {
if (er.code === "EBUSY" && busyTries < opts.maxBusyTries) {
var time = (opts.maxBusyTries - busyTries) * 100
busyTries ++
// try again, with the same exact callback as this one.
return setTimeout(function () {
rimraf_(p, opts, CB)
})
}
// this one won't happen if graceful-fs is used.
if (er.code === "EMFILE" && timeout < EMFILE_MAX) {
return setTimeout(function () {
rimraf_(p, opts, CB)
}, timeout ++)
}
// already gone
if (er.code === "ENOENT") er = null
}
timeout = 0
cb(er)
})
}
function rimraf_ (p, opts, 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()
// some other kind of error, permissions, etc.
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)
})
}
function rm_ (p, s, opts, cb) {
if (!s.isDirectory()) return fs.unlink(p, cb)
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)
}, function (er) {
if (er) return cb(er)
fs.rmdir(p, 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
, errState = null
list.forEach(function (item, i, list) {
fn(item, function (er) {
if (errState) return
if (er) return cb(errState = er)
if (-- c === 0) return cb()
})
})
}
// this looks simpler, but it will fail with big directory trees,
// or on slow stupid awful cygwin filesystems
function rimrafSync (p) {
try {
var s = fs[lstatSync](p)
} catch (er) {
if (er.code === "ENOENT") return
throw er
}
if (!s.isDirectory()) return fs.unlinkSync(p)
fs.readdirSync(p).forEach(function (f) {
rimrafSync(path.join(p, f))
})
fs.rmdirSync(p)
}

View file

@ -1,10 +0,0 @@
#!/bin/bash
set -e
for i in test-*.js; do
echo -n $i ...
bash setup.sh
node $i
! [ -d target ]
echo "pass"
done
rm -rf target

View file

@ -1,47 +0,0 @@
#!/bin/bash
set -e
files=10
folders=2
depth=4
target="$PWD/target"
rm -rf target
fill () {
local depth=$1
local files=$2
local folders=$3
local target=$4
if ! [ -d $target ]; then
mkdir -p $target
fi
local f
f=$files
while [ $f -gt 0 ]; do
touch "$target/f-$depth-$f"
let f--
done
let depth--
if [ $depth -le 0 ]; then
return 0
fi
f=$folders
while [ $f -gt 0 ]; do
mkdir "$target/folder-$depth-$f"
fill $depth $files $folders "$target/d-$depth-$f"
let f--
done
}
fill $depth $files $folders $target
# sanity assert
[ -d $target ]

View file

@ -1,5 +0,0 @@
var rimraf = require("../rimraf")
, path = require("path")
rimraf(path.join(__dirname, "target"), function (er) {
if (er) throw er
})

View file

@ -1,15 +0,0 @@
var rimraf
, path = require("path")
try {
rimraf = require("../fiber")
} catch (er) {
console.error("skipping fiber test")
}
if (rimraf) {
Fiber(function () {
rimraf(path.join(__dirname, "target")).wait()
}).run()
}

View file

@ -1,3 +0,0 @@
var rimraf = require("../rimraf")
, path = require("path")
rimraf.sync(path.join(__dirname, "target"))

View file

@ -11,6 +11,7 @@
, "dependencies": { , "dependencies": {
"ansi": "0.0.x" "ansi": "0.0.x"
, "glob": "3" , "glob": "3"
, "fstream": "0.1.x"
, "minimatch": "~0.1.4" , "minimatch": "~0.1.4"
, "mkdirp": "0.3.0" , "mkdirp": "0.3.0"
, "nopt": "1" , "nopt": "1"