Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2014-06-14 04:07:12 +0400
committerisaacs <i@izs.me>2014-06-14 04:07:12 +0400
commit93dd1338a4a3d17443d3922324f9f43b398434ff (patch)
tree7bdc87d117f672d693a309917fd189e0e9529d77 /node_modules/rimraf
parent62f191fcccce5cafd170f8c36d370d4ce435461d (diff)
rimraf@2.2.8
Diffstat (limited to 'node_modules/rimraf')
-rw-r--r--node_modules/rimraf/package.json27
-rw-r--r--node_modules/rimraf/rimraf.js148
-rw-r--r--node_modules/rimraf/test/run.sh10
3 files changed, 139 insertions, 46 deletions
diff --git a/node_modules/rimraf/package.json b/node_modules/rimraf/package.json
index d26d949f9..164fc495a 100644
--- a/node_modules/rimraf/package.json
+++ b/node_modules/rimraf/package.json
@@ -1,6 +1,6 @@
{
"name": "rimraf",
- "version": "2.2.6",
+ "version": "2.2.8",
"main": "rimraf.js",
"description": "A deep deletion module for node (like `rm -rf`)",
"author": {
@@ -45,12 +45,29 @@
"email": "yosefd@microsoft.com"
}
],
- "readme": "`rm -rf` for node.\n\nInstall with `npm install rimraf`, or just drop rimraf.js somewhere.\n\n## API\n\n`rimraf(f, callback)`\n\nThe callback will be called with an error if there is one. Certain\nerrors are handled for you:\n\n* Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of\n `opts.maxBusyTries` times before giving up.\n* `ENOENT` - If the file doesn't exist, rimraf will return\n successfully, since your desired outcome is already the case.\n\n## rimraf.sync\n\nIt can remove stuff synchronously, too. But that's not so good. Use\nthe async API. It's better.\n\n## CLI\n\nIf installed with `npm install rimraf -g` it can be used as a global\ncommand `rimraf <path>` which is useful for cross platform support.\n\n## mkdirp\n\nIf you need to create a directory recursively, check out\n[mkdirp](https://github.com/substack/node-mkdirp).\n",
- "readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/isaacs/rimraf/issues"
},
"homepage": "https://github.com/isaacs/rimraf",
- "_id": "rimraf@2.2.6",
- "_from": "rimraf@~2.2.5"
+ "_id": "rimraf@2.2.8",
+ "_shasum": "e439be2aaee327321952730f99a8929e4fc50582",
+ "_from": "rimraf@latest",
+ "_npmVersion": "1.4.10",
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "maintainers": [
+ {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ }
+ ],
+ "dist": {
+ "shasum": "e439be2aaee327321952730f99a8929e4fc50582",
+ "tarball": "http://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz"
+ },
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz",
+ "readme": "ERROR: No README data found!"
}
diff --git a/node_modules/rimraf/rimraf.js b/node_modules/rimraf/rimraf.js
index ce62051fc..eb96c46af 100644
--- a/node_modules/rimraf/rimraf.js
+++ b/node_modules/rimraf/rimraf.js
@@ -1,6 +1,7 @@
module.exports = rimraf
rimraf.sync = rimrafSync
+var assert = require("assert")
var path = require("path")
var fs = require("fs")
@@ -11,11 +12,36 @@ exports.BUSYTRIES_MAX = 3
var isWindows = (process.platform === "win32")
-function rimraf (p, cb) {
+function defaults (options) {
+ var methods = [
+ 'unlink',
+ 'chmod',
+ 'stat',
+ 'rmdir',
+ 'readdir'
+ ]
+ methods.forEach(function(m) {
+ options[m] = options[m] || fs[m]
+ m = m + 'Sync'
+ options[m] = options[m] || fs[m]
+ })
+}
+
+function rimraf (p, options, cb) {
+ if (typeof options === 'function') {
+ cb = options
+ options = {}
+ }
+ assert(p)
+ assert(options)
+ assert(typeof cb === 'function')
+
+ defaults(options)
+
if (!cb) throw new Error("No callback passed to rimraf()")
var busyTries = 0
- rimraf_(p, function CB (er) {
+ rimraf_(p, options, function CB (er) {
if (er) {
if (isWindows && (er.code === "EBUSY" || er.code === "ENOTEMPTY") &&
busyTries < exports.BUSYTRIES_MAX) {
@@ -23,14 +49,14 @@ function rimraf (p, cb) {
var time = busyTries * 100
// try again, with the same exact callback as this one.
return setTimeout(function () {
- rimraf_(p, CB)
+ rimraf_(p, options, CB)
}, time)
}
// this one won't happen if graceful-fs is used.
if (er.code === "EMFILE" && timeout < exports.EMFILE_MAX) {
return setTimeout(function () {
- rimraf_(p, CB)
+ rimraf_(p, options, CB)
}, timeout ++)
}
@@ -54,64 +80,91 @@ function rimraf (p, cb) {
//
// If anyone ever complains about this, then I guess the strategy could
// be made configurable somehow. But until then, YAGNI.
-function rimraf_ (p, cb) {
- fs.unlink(p, function (er) {
+function rimraf_ (p, options, cb) {
+ assert(p)
+ 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, er, cb) : rmdir(p, er, cb)
+ return (isWindows)
+ ? fixWinEPERM(p, options, er, cb)
+ : rmdir(p, options, er, cb)
if (er.code === "EISDIR")
- return rmdir(p, er, cb)
+ return rmdir(p, options, er, cb)
}
return cb(er)
})
}
-function fixWinEPERM (p, er, cb) {
- fs.chmod(p, 666, function (er2) {
+function fixWinEPERM (p, options, er, cb) {
+ assert(p)
+ assert(options)
+ assert(typeof cb === 'function')
+ if (er)
+ assert(er instanceof Error)
+
+ options.chmod(p, 666, function (er2) {
if (er2)
cb(er2.code === "ENOENT" ? null : er)
else
- fs.stat(p, function(er3, stats) {
+ options.stat(p, function(er3, stats) {
if (er3)
cb(er3.code === "ENOENT" ? null : er)
else if (stats.isDirectory())
- rmdir(p, er, cb)
+ rmdir(p, options, er, cb)
else
- fs.unlink(p, cb)
+ options.unlink(p, cb)
})
})
}
-function fixWinEPERMSync (p, er, cb) {
+function fixWinEPERMSync (p, options, er) {
+ assert(p)
+ assert(options)
+ if (er)
+ assert(er instanceof Error)
+
try {
- fs.chmodSync(p, 666)
+ options.chmodSync(p, 666)
} catch (er2) {
- if (er2.code !== "ENOENT")
+ if (er2.code === "ENOENT")
+ return
+ else
throw er
}
try {
- var stats = fs.statSync(p)
+ var stats = options.statSync(p)
} catch (er3) {
- if (er3 !== "ENOENT")
+ if (er3.code === "ENOENT")
+ return
+ else
throw er
}
if (stats.isDirectory())
- rmdirSync(p, er)
+ rmdirSync(p, options, er)
else
- fs.unlinkSync(p)
+ options.unlinkSync(p)
}
-function rmdir (p, originalEr, cb) {
+function rmdir (p, options, originalEr, cb) {
+ assert(p)
+ assert(options)
+ if (originalEr)
+ assert(originalEr instanceof Error)
+ assert(typeof cb === 'function')
+
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
// if we guessed wrong, and it's not a directory, then
// raise the original error.
- fs.rmdir(p, function (er) {
+ options.rmdir(p, function (er) {
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
- rmkids(p, cb)
+ rmkids(p, options, cb)
else if (er && er.code === "ENOTDIR")
cb(originalEr)
else
@@ -119,22 +172,26 @@ function rmdir (p, originalEr, cb) {
})
}
-function rmkids(p, cb) {
- fs.readdir(p, function (er, files) {
+function rmkids(p, options, cb) {
+ assert(p)
+ assert(options)
+ assert(typeof cb === 'function')
+
+ options.readdir(p, function (er, files) {
if (er)
return cb(er)
var n = files.length
if (n === 0)
- return fs.rmdir(p, cb)
+ return options.rmdir(p, cb)
var errState
files.forEach(function (f) {
- rimraf(path.join(p, f), function (er) {
+ rimraf(path.join(p, f), options, function (er) {
if (errState)
return
if (er)
return cb(errState = er)
if (--n === 0)
- fs.rmdir(p, cb)
+ options.rmdir(p, cb)
})
})
})
@@ -143,36 +200,49 @@ function rmkids(p, cb) {
// this looks simpler, and is strictly *faster*, but will
// tie up the JavaScript thread and fail on excessively
// deep directory trees.
-function rimrafSync (p) {
+function rimrafSync (p, options) {
+ options = options || {}
+ defaults(options)
+
+ assert(p)
+ assert(options)
+
try {
- fs.unlinkSync(p)
+ options.unlinkSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
if (er.code === "EPERM")
- return isWindows ? fixWinEPERMSync(p, er) : rmdirSync(p, er)
+ return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
if (er.code !== "EISDIR")
throw er
- rmdirSync(p, er)
+ rmdirSync(p, options, er)
}
}
-function rmdirSync (p, originalEr) {
+function rmdirSync (p, options, originalEr) {
+ assert(p)
+ assert(options)
+ if (originalEr)
+ assert(originalEr instanceof Error)
+
try {
- fs.rmdirSync(p)
+ options.rmdirSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
if (er.code === "ENOTDIR")
throw originalEr
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
- rmkidsSync(p)
+ rmkidsSync(p, options)
}
}
-function rmkidsSync (p) {
- fs.readdirSync(p).forEach(function (f) {
- rimrafSync(path.join(p, f))
+function rmkidsSync (p, options) {
+ assert(p)
+ assert(options)
+ options.readdirSync(p).forEach(function (f) {
+ rimrafSync(path.join(p, f), options)
})
- fs.rmdirSync(p)
+ options.rmdirSync(p, options)
}
diff --git a/node_modules/rimraf/test/run.sh b/node_modules/rimraf/test/run.sh
index 598f0163b..653ff9b79 100644
--- a/node_modules/rimraf/test/run.sh
+++ b/node_modules/rimraf/test/run.sh
@@ -1,10 +1,16 @@
#!/bin/bash
set -e
+code=0
for i in test-*.js; do
echo -n $i ...
bash setup.sh
node $i
- ! [ -d target ]
- echo "pass"
+ if [ -d target ]; then
+ echo "fail"
+ code=1
+ else
+ echo "pass"
+ fi
done
rm -rf target
+exit $code