diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-03-06 05:25:01 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-03-06 05:25:01 +0300 |
commit | 8885c4dfb618f2838930b5c5149abea300a762d6 (patch) | |
tree | 4b427f2c56e22dc06f90c578884719f89030f56e | |
parent | 2abc3ee08f0cabc4e7bfd7b973c0b59dc44715ff (diff) |
rimraf@2.3.1
* Glob arguments for better Windows support.
* Handle bad symlinks properly.
* Make maxBusyTries and emfileWait configurable
* Also upgrade to glob@4.4.1
-rw-r--r-- | node_modules/glob/glob.js | 19 | ||||
-rw-r--r-- | node_modules/glob/package.json | 19 | ||||
-rw-r--r-- | node_modules/glob/sync.js | 13 | ||||
-rw-r--r-- | node_modules/rimraf/AUTHORS | 6 | ||||
-rw-r--r-- | node_modules/rimraf/README.md | 10 | ||||
-rw-r--r-- | node_modules/rimraf/package.json | 49 | ||||
-rw-r--r-- | node_modules/rimraf/rimraf.js | 155 | ||||
-rw-r--r-- | node_modules/rimraf/test/run.sh | 16 | ||||
-rw-r--r-- | node_modules/rimraf/test/setup.sh | 47 | ||||
-rw-r--r-- | node_modules/rimraf/test/test-async.js | 5 | ||||
-rw-r--r-- | node_modules/rimraf/test/test-sync.js | 3 | ||||
-rw-r--r-- | package.json | 4 |
12 files changed, 173 insertions, 173 deletions
diff --git a/node_modules/glob/glob.js b/node_modules/glob/glob.js index 0075c1fb8..e1a5c9ece 100644 --- a/node_modules/glob/glob.js +++ b/node_modules/glob/glob.js @@ -627,12 +627,23 @@ Glob.prototype._stat = function (f, cb) { } var self = this - var statcb = inflight('stat\0' + abs, statcb_) + var statcb = inflight('stat\0' + abs, lstatcb_) if (statcb) - fs.stat(abs, statcb) + fs.lstat(abs, statcb) - function statcb_ (er, stat) { - self._stat2(f, abs, er, stat, cb) + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) + } } } diff --git a/node_modules/glob/package.json b/node_modules/glob/package.json index 8c11fbb77..59eff1188 100644 --- a/node_modules/glob/package.json +++ b/node_modules/glob/package.json @@ -6,7 +6,7 @@ }, "name": "glob", "description": "a little globber", - "version": "4.4.1", + "version": "4.4.2", "repository": { "type": "git", "url": "git://github.com/isaacs/node-glob.git" @@ -42,16 +42,16 @@ "benchclean": "bash benchclean.sh" }, "license": "ISC", - "gitHead": "a10b0294183788c0e9f56fc3ac88832e2c3513bc", + "gitHead": "c13abc0df649ec29f8cfec42f818412887736aa1", "bugs": { "url": "https://github.com/isaacs/node-glob/issues" }, "homepage": "https://github.com/isaacs/node-glob", - "_id": "glob@4.4.1", - "_shasum": "8395b16d01f4a58f0bf3f6359174997b78d74197", - "_from": "glob@>=4.4.1 <4.5.0", + "_id": "glob@4.4.2", + "_shasum": "3ef93e297ee096c1b9b3ffb1d21025c78ab60548", + "_from": "glob@>=4.4.2 <4.5.0", "_npmVersion": "2.6.0", - "_nodeVersion": "1.1.0", + "_nodeVersion": "1.4.2", "_npmUser": { "name": "isaacs", "email": "i@izs.me" @@ -63,9 +63,10 @@ } ], "dist": { - "shasum": "8395b16d01f4a58f0bf3f6359174997b78d74197", - "tarball": "http://registry.npmjs.org/glob/-/glob-4.4.1.tgz" + "shasum": "3ef93e297ee096c1b9b3ffb1d21025c78ab60548", + "tarball": "http://registry.npmjs.org/glob/-/glob-4.4.2.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/glob/-/glob-4.4.1.tgz" + "_resolved": "https://registry.npmjs.org/glob/-/glob-4.4.2.tgz", + "readme": "ERROR: No README data found!" } diff --git a/node_modules/glob/sync.js b/node_modules/glob/sync.js index 7aa0d07c5..315fbfb0b 100644 --- a/node_modules/glob/sync.js +++ b/node_modules/glob/sync.js @@ -391,11 +391,22 @@ GlobSync.prototype._stat = function (f) { var exists var stat = this.statCache[abs] if (!stat) { + var lstat try { - stat = fs.statSync(abs) + lstat = fs.lstatSync(abs) } catch (er) { return false } + + if (lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs) + } catch (er) { + stat = lstat + } + } else { + stat = lstat + } } this.statCache[abs] = stat diff --git a/node_modules/rimraf/AUTHORS b/node_modules/rimraf/AUTHORS deleted file mode 100644 index 247b75437..000000000 --- a/node_modules/rimraf/AUTHORS +++ /dev/null @@ -1,6 +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 -Yosef Dinerstein <yosefd@microsoft.com> diff --git a/node_modules/rimraf/README.md b/node_modules/rimraf/README.md index cd123b652..58e7ac303 100644 --- a/node_modules/rimraf/README.md +++ b/node_modules/rimraf/README.md @@ -1,4 +1,4 @@ -`rm -rf` for node. +The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node. Install with `npm install rimraf`, or just drop rimraf.js somewhere. @@ -10,9 +10,15 @@ The callback will be called with an error if there is one. Certain errors are handled for you: * Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of - `opts.maxBusyTries` times before giving up. + `opts.maxBusyTries` times before giving up, adding 100ms of wait + between each attempt. The default `maxBusyTries` is 3. * `ENOENT` - If the file doesn't exist, rimraf will return successfully, since your desired outcome is already the case. +* `EMFILE` - Since `readdir` requires opening a file descriptor, it's + possible to hit `EMFILE` if too many file descriptors are in use. + In the sync case, there's nothing to be done for this. But in the + async case, rimraf will gradually back off with timeouts up to + `opts.emfileWait` ms, which defaults to 1000. ## rimraf.sync diff --git a/node_modules/rimraf/package.json b/node_modules/rimraf/package.json index 164fc495a..a257986de 100644 --- a/node_modules/rimraf/package.json +++ b/node_modules/rimraf/package.json @@ -1,6 +1,6 @@ { "name": "rimraf", - "version": "2.2.8", + "version": "2.3.1", "main": "rimraf.js", "description": "A deep deletion module for node (like `rm -rf`)", "author": { @@ -22,37 +22,25 @@ "bin": { "rimraf": "./bin.js" }, - "contributors": [ - { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me" - }, - { - "name": "Wayne Larsen", - "email": "wayne@larsen.st", - "url": "http://github.com/wvl" - }, - { - "name": "ritch", - "email": "skawful@gmail.com" - }, - { - "name": "Marcel Laverdet" - }, - { - "name": "Yosef Dinerstein", - "email": "yosefd@microsoft.com" - } + "dependencies": { + "glob": "^4.4.2" + }, + "files": [ + "bin.js", + "rimraf.js", + "LICENSE", + "README.md" ], + "gitHead": "aa707db2fb5b11c35fc614a1472775373dc9d46c", "bugs": { "url": "https://github.com/isaacs/rimraf/issues" }, "homepage": "https://github.com/isaacs/rimraf", - "_id": "rimraf@2.2.8", - "_shasum": "e439be2aaee327321952730f99a8929e4fc50582", - "_from": "rimraf@latest", - "_npmVersion": "1.4.10", + "_id": "rimraf@2.3.1", + "_shasum": "f83df78c168d5daf9f021e8e092e7a165898ee75", + "_from": "rimraf@>=2.3.1 <2.4.0", + "_npmVersion": "2.6.0", + "_nodeVersion": "1.4.2", "_npmUser": { "name": "isaacs", "email": "i@izs.me" @@ -64,10 +52,9 @@ } ], "dist": { - "shasum": "e439be2aaee327321952730f99a8929e4fc50582", - "tarball": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz" + "shasum": "f83df78c168d5daf9f021e8e092e7a165898ee75", + "tarball": "http://registry.npmjs.org/rimraf/-/rimraf-2.3.1.tgz" }, "directories": {}, - "_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", - "readme": "ERROR: No README data found!" + "_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.3.1.tgz" } diff --git a/node_modules/rimraf/rimraf.js b/node_modules/rimraf/rimraf.js index eb96c46af..6dffdf064 100644 --- a/node_modules/rimraf/rimraf.js +++ b/node_modules/rimraf/rimraf.js @@ -4,11 +4,17 @@ rimraf.sync = rimrafSync var assert = require("assert") var path = require("path") var fs = require("fs") +var glob = require("glob") + +var globOpts = { + nosort: true, + nocomment: true, + nonegate: true, + silent: true +} // for EMFILE handling var timeout = 0 -exports.EMFILE_MAX = 1000 -exports.BUSYTRIES_MAX = 3 var isWindows = (process.platform === "win32") @@ -17,6 +23,7 @@ function defaults (options) { 'unlink', 'chmod', 'stat', + 'lstat', 'rmdir', 'readdir' ] @@ -25,6 +32,9 @@ function defaults (options) { m = m + 'Sync' options[m] = options[m] || fs[m] }) + + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 } function rimraf (p, options, cb) { @@ -41,32 +51,54 @@ function rimraf (p, options, cb) { if (!cb) throw new Error("No callback passed to rimraf()") var busyTries = 0 - rimraf_(p, options, function CB (er) { - if (er) { - if (isWindows && (er.code === "EBUSY" || er.code === "ENOTEMPTY") && - busyTries < exports.BUSYTRIES_MAX) { - busyTries ++ - var time = busyTries * 100 - // try again, with the same exact callback as this one. - return setTimeout(function () { - rimraf_(p, options, CB) - }, time) - } + var errState = null + var n = 0 - // this one won't happen if graceful-fs is used. - if (er.code === "EMFILE" && timeout < exports.EMFILE_MAX) { - return setTimeout(function () { - rimraf_(p, options, CB) - }, timeout ++) - } + glob(p, globOpts, afterGlob) - // already gone - if (er.code === "ENOENT") er = null - } + function next (er) { + errState = errState || er + if (--n === 0) + cb(errState) + } - timeout = 0 - cb(er) - }) + function afterGlob (er, results) { + if (er) + return cb(er) + + n = results.length + if (n === 0) + return cb() + + results.forEach(function (p) { + rimraf_(p, options, function CB (er) { + if (er) { + if (isWindows && (er.code === "EBUSY" || er.code === "ENOTEMPTY") && + busyTries < options.maxBusyTries) { + busyTries ++ + var time = busyTries * 100 + // try again, with the same exact callback as this one. + return setTimeout(function () { + rimraf_(p, options, CB) + }, time) + } + + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(function () { + rimraf_(p, options, CB) + }, timeout ++) + } + + // already gone + if (er.code === "ENOENT") er = null + } + + timeout = 0 + next(er) + }) + }) + } } // Two possible strategies. @@ -85,18 +117,28 @@ function rimraf_ (p, options, cb) { assert(options) assert(typeof cb === 'function') - options.unlink(p, function (er) { - if (er) { - if (er.code === "ENOENT") - return cb(null) - if (er.code === "EPERM") - return (isWindows) - ? fixWinEPERM(p, options, er, cb) - : rmdir(p, options, er, cb) - if (er.code === "EISDIR") - return rmdir(p, options, er, cb) - } - return cb(er) + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, function (er, st) { + if (er && er.code === "ENOENT") + return cb(null) + + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) + + options.unlink(p, function (er) { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) }) } @@ -207,16 +249,35 @@ function rimrafSync (p, options) { assert(p) assert(options) - try { - options.unlinkSync(p) - } catch (er) { - if (er.code === "ENOENT") - return - if (er.code === "EPERM") - return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) - if (er.code !== "EISDIR") - throw er - rmdirSync(p, options, er) + var results = glob.sync(p, globOpts) + if (!results.length) + return + + for (var i = 0; i < results.length; i++) { + var p = results[i] + + try { + var st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + } + + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er + rmdirSync(p, options, er) + } } } diff --git a/node_modules/rimraf/test/run.sh b/node_modules/rimraf/test/run.sh deleted file mode 100644 index 653ff9b79..000000000 --- a/node_modules/rimraf/test/run.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -e -code=0 -for i in test-*.js; do - echo -n $i ... - bash setup.sh - node $i - if [ -d target ]; then - echo "fail" - code=1 - else - echo "pass" - fi -done -rm -rf target -exit $code diff --git a/node_modules/rimraf/test/setup.sh b/node_modules/rimraf/test/setup.sh deleted file mode 100644 index 2602e6316..000000000 --- a/node_modules/rimraf/test/setup.sh +++ /dev/null @@ -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 ] diff --git a/node_modules/rimraf/test/test-async.js b/node_modules/rimraf/test/test-async.js deleted file mode 100644 index 9c2e0b7be..000000000 --- a/node_modules/rimraf/test/test-async.js +++ /dev/null @@ -1,5 +0,0 @@ -var rimraf = require("../rimraf") - , path = require("path") -rimraf(path.join(__dirname, "target"), function (er) { - if (er) throw er -}) diff --git a/node_modules/rimraf/test/test-sync.js b/node_modules/rimraf/test/test-sync.js deleted file mode 100644 index eb71f1047..000000000 --- a/node_modules/rimraf/test/test-sync.js +++ /dev/null @@ -1,3 +0,0 @@ -var rimraf = require("../rimraf") - , path = require("path") -rimraf.sync(path.join(__dirname, "target")) diff --git a/package.json b/package.json index 1ec2b779c..99a4ebe9d 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "fstream-npm": "~1.0.1", "github-url-from-git": "~1.4.0", "github-url-from-username-repo": "~1.0.2", - "glob": "~4.4.1", + "glob": "~4.4.2", "graceful-fs": "~3.0.5", "inflight": "~1.0.4", "inherits": "~2.0.1", @@ -84,7 +84,7 @@ "realize-package-specifier": "~1.3.0", "request": "~2.53.0", "retry": "~0.6.1", - "rimraf": "~2.2.8", + "rimraf": "~2.3.1", "semver": "~4.3.1", "sha": "~1.3.0", "slide": "~1.1.6", |