rimraf 2.2.2 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +10 -6
  2. package/package.json +1 -4
  3. package/rimraf.js +6 -12
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- A `rm -rf` for node.
1
+ `rm -rf` for node.
2
2
 
3
3
  Install with `npm install rimraf`, or just drop rimraf.js somewhere.
4
4
 
@@ -9,11 +9,10 @@ Install with `npm install rimraf`, or just drop rimraf.js somewhere.
9
9
  The callback will be called with an error if there is one. Certain
10
10
  errors are handled for you:
11
11
 
12
- * `EBUSY` - rimraf will back off a maximum of opts.maxBusyTries times
13
- before giving up.
14
- * `EMFILE` - If too many file descriptors get opened, rimraf will
15
- patiently wait until more become available.
16
-
12
+ * Windows: `EBUSY` and `ENOTEMPTY` - rimraf will back off a maximum of
13
+ `opts.maxBusyTries` times before giving up.
14
+ * `ENOENT` - If the file doesn't exist, rimraf will return
15
+ successfully, since your desired outcome is already the case.
17
16
 
18
17
  ## rimraf.sync
19
18
 
@@ -24,3 +23,8 @@ the async API. It's better.
24
23
 
25
24
  If installed with `npm install rimraf -g` it can be used as a global
26
25
  command `rimraf <path>` which is useful for cross platform support.
26
+
27
+ ## mkdirp
28
+
29
+ If you need to create a directory recursively, check out
30
+ [mkdirp](https://github.com/substack/node-mkdirp).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimraf",
3
- "version": "2.2.2",
3
+ "version": "2.2.6",
4
4
  "main": "rimraf.js",
5
5
  "description": "A deep deletion module for node (like `rm -rf`)",
6
6
  "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
@@ -8,9 +8,6 @@
8
8
  "type": "MIT",
9
9
  "url": "https://github.com/isaacs/rimraf/raw/master/LICENSE"
10
10
  },
11
- "optionalDependencies": {
12
- "graceful-fs": "~2"
13
- },
14
11
  "repository": "git://github.com/isaacs/rimraf.git",
15
12
  "scripts": {
16
13
  "test": "cd test && bash run.sh"
package/rimraf.js CHANGED
@@ -2,14 +2,7 @@ module.exports = rimraf
2
2
  rimraf.sync = rimrafSync
3
3
 
4
4
  var path = require("path")
5
- , fs
6
-
7
- try {
8
- // optional dependency
9
- fs = require("graceful-fs")
10
- } catch (er) {
11
- fs = require("fs")
12
- }
5
+ var fs = require("fs")
13
6
 
14
7
  // for EMFILE handling
15
8
  var timeout = 0
@@ -24,7 +17,8 @@ function rimraf (p, cb) {
24
17
  var busyTries = 0
25
18
  rimraf_(p, function CB (er) {
26
19
  if (er) {
27
- if (er.code === "EBUSY" && busyTries < exports.BUSYTRIES_MAX) {
20
+ if (isWindows && (er.code === "EBUSY" || er.code === "ENOTEMPTY") &&
21
+ busyTries < exports.BUSYTRIES_MAX) {
28
22
  busyTries ++
29
23
  var time = busyTries * 100
30
24
  // try again, with the same exact callback as this one.
@@ -64,7 +58,7 @@ function rimraf_ (p, cb) {
64
58
  fs.unlink(p, function (er) {
65
59
  if (er) {
66
60
  if (er.code === "ENOENT")
67
- return cb()
61
+ return cb(null)
68
62
  if (er.code === "EPERM")
69
63
  return (isWindows) ? fixWinEPERM(p, er, cb) : rmdir(p, er, cb)
70
64
  if (er.code === "EISDIR")
@@ -116,7 +110,7 @@ function rmdir (p, originalEr, cb) {
116
110
  // if we guessed wrong, and it's not a directory, then
117
111
  // raise the original error.
118
112
  fs.rmdir(p, function (er) {
119
- if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST"))
113
+ if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
120
114
  rmkids(p, cb)
121
115
  else if (er && er.code === "ENOTDIR")
122
116
  cb(originalEr)
@@ -171,7 +165,7 @@ function rmdirSync (p, originalEr) {
171
165
  return
172
166
  if (er.code === "ENOTDIR")
173
167
  throw originalEr
174
- if (er.code === "ENOTEMPTY" || er.code === "EEXIST")
168
+ if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
175
169
  rmkidsSync(p)
176
170
  }
177
171
  }