summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/rimraf
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-05-05 22:33:06 -0700
committerisaacs <i@izs.me>2012-05-05 22:33:12 -0700
commit33a9ac6087732da48e7d12ea7f7fbb41926fe46c (patch)
treea914e333e80a3401ce8726355b38f1d636500cb5 /deps/npm/node_modules/rimraf
parent1858d1c340ca2631e28a32eb542c85ee8f725cac (diff)
downloadandroid-node-v8-33a9ac6087732da48e7d12ea7f7fbb41926fe46c.tar.gz
android-node-v8-33a9ac6087732da48e7d12ea7f7fbb41926fe46c.tar.bz2
android-node-v8-33a9ac6087732da48e7d12ea7f7fbb41926fe46c.zip
Upgrade npm to 1.1.21
Somehow this got downgraded in the last v0.6 merge. Very strange.
Diffstat (limited to 'deps/npm/node_modules/rimraf')
-rw-r--r--deps/npm/node_modules/rimraf/AUTHORS1
-rw-r--r--deps/npm/node_modules/rimraf/README.md13
-rw-r--r--deps/npm/node_modules/rimraf/fiber.js86
-rw-r--r--deps/npm/node_modules/rimraf/package.json3
-rw-r--r--deps/npm/node_modules/rimraf/rimraf.js106
5 files changed, 61 insertions, 148 deletions
diff --git a/deps/npm/node_modules/rimraf/AUTHORS b/deps/npm/node_modules/rimraf/AUTHORS
index 008cbe7dd9..247b754373 100644
--- a/deps/npm/node_modules/rimraf/AUTHORS
+++ b/deps/npm/node_modules/rimraf/AUTHORS
@@ -3,3 +3,4 @@ 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
+Yosef Dinerstein <yosefd@microsoft.com>
diff --git a/deps/npm/node_modules/rimraf/README.md b/deps/npm/node_modules/rimraf/README.md
index 99983dc437..96ce9b2a0b 100644
--- a/deps/npm/node_modules/rimraf/README.md
+++ b/deps/npm/node_modules/rimraf/README.md
@@ -4,7 +4,7 @@ Install with `npm install rimraf`, or just drop rimraf.js somewhere.
## API
-`rimraf(f, [options,] callback)`
+`rimraf(f, callback)`
The callback will be called with an error if there is one. Certain
errors are handled for you:
@@ -14,17 +14,6 @@ errors are handled for you:
* `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
diff --git a/deps/npm/node_modules/rimraf/fiber.js b/deps/npm/node_modules/rimraf/fiber.js
deleted file mode 100644
index 8812a6b449..0000000000
--- a/deps/npm/node_modules/rimraf/fiber.js
+++ /dev/null
@@ -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()
diff --git a/deps/npm/node_modules/rimraf/package.json b/deps/npm/node_modules/rimraf/package.json
index 2b69536ef9..952bc8af9f 100644
--- a/deps/npm/node_modules/rimraf/package.json
+++ b/deps/npm/node_modules/rimraf/package.json
@@ -1,9 +1,10 @@
{"name":"rimraf"
-,"version":"1.0.9"
+,"version":"2.0.1"
,"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"}
+,"optionalDependencies":{"graceful-fs":"~1.1"}
,"repository":"git://github.com/isaacs/rimraf.git"
,"scripts":{"test":"cd test && bash run.sh"}}
diff --git a/deps/npm/node_modules/rimraf/rimraf.js b/deps/npm/node_modules/rimraf/rimraf.js
index e8104e9e4b..67d018ab4a 100644
--- a/deps/npm/node_modules/rimraf/rimraf.js
+++ b/deps/npm/node_modules/rimraf/rimraf.js
@@ -16,34 +16,30 @@ var lstat = process.platform === "win32" ? "stat" : "lstat"
// for EMFILE handling
var timeout = 0
- , EMFILE_MAX = 1000
+exports.EMFILE_MAX = 1000
+exports.BUSYTRIES_MAX = 3
-function rimraf (p, opts, cb) {
- if (typeof opts === "function") cb = opts, opts = {}
+function rimraf (p, cb) {
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) {
+ rimraf_(p, function CB (er) {
if (er) {
- if (er.code === "EBUSY" && busyTries < opts.maxBusyTries) {
- var time = (opts.maxBusyTries - busyTries) * 100
+ if (er.code === "EBUSY" && busyTries < exports.BUSYTRIES_MAX) {
+ var time = (exports.BUSYTRIES_MAX - busyTries) * 100
busyTries ++
// try again, with the same exact callback as this one.
return setTimeout(function () {
- rimraf_(p, opts, CB)
+ rimraf_(p, CB)
})
}
// this one won't happen if graceful-fs is used.
- if (er.code === "EMFILE" && timeout < EMFILE_MAX) {
+ if (er.code === "EMFILE" && timeout < exports.EMFILE_MAX) {
return setTimeout(function () {
- rimraf_(p, opts, CB)
+ rimraf_(p, CB)
}, timeout ++)
}
@@ -56,9 +52,8 @@ function rimraf (p, opts, cb) {
})
}
-function rimraf_ (p, opts, cb) {
+function rimraf_ (p, 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()
@@ -66,20 +61,55 @@ function rimraf_ (p, opts, cb) {
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)
+ return rm_(p, s, false, cb)
})
}
-function rm_ (p, s, opts, cb) {
- if (!s.isDirectory()) return fs.unlink(p, cb)
+
+var myGid = function myGid () {
+ var g = process.getuid && process.getgid()
+ myGid = function myGid () { return g }
+ return g
+}
+
+var myUid = function myUid () {
+ var u = process.getuid && process.getuid()
+ myUid = function myUid () { return u }
+ return u
+}
+
+
+function writable (s) {
+ var mode = s.mode || 0777
+ , uid = myUid()
+ , gid = myGid()
+ return (mode & 0002)
+ || (gid === s.gid && (mode & 0020))
+ || (uid === s.uid && (mode & 0200))
+}
+
+function rm_ (p, s, didWritableCheck, cb) {
+ if (!didWritableCheck && !writable(s)) {
+ // make file writable
+ // user/group/world, doesn't matter at this point
+ // since it's about to get nuked.
+ return fs.chmod(p, s.mode | 0222, function (er) {
+ if (er) return cb(er)
+ rm_(p, s, true, cb)
+ })
+ }
+
+ if (!s.isDirectory()) {
+ return fs.unlink(p, cb)
+ }
+
+ // directory
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)
+ rimraf(file, cb)
}, function (er) {
if (er) return cb(er)
fs.rmdir(p, cb)
@@ -87,34 +117,6 @@ function rm_ (p, s, opts, 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
@@ -137,7 +139,13 @@ function rimrafSync (p) {
if (er.code === "ENOENT") return
throw er
}
+
+ if (!writable(s)) {
+ fs.chmodSync(p, s.mode | 0222)
+ }
+
if (!s.isDirectory()) return fs.unlinkSync(p)
+
fs.readdirSync(p).forEach(function (f) {
rimrafSync(path.join(p, f))
})