rimraf 2.5.4 → 2.6.3

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/bin.js +13 -3
  2. package/package.json +6 -3
  3. package/rimraf.js +25 -4
package/bin.js CHANGED
@@ -4,16 +4,21 @@ var rimraf = require('./')
4
4
 
5
5
  var help = false
6
6
  var dashdash = false
7
+ var noglob = false
7
8
  var args = process.argv.slice(2).filter(function(arg) {
8
9
  if (dashdash)
9
10
  return !!arg
10
11
  else if (arg === '--')
11
12
  dashdash = true
13
+ else if (arg === '--no-glob' || arg === '-G')
14
+ noglob = true
15
+ else if (arg === '--glob' || arg === '-g')
16
+ noglob = false
12
17
  else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/))
13
18
  help = true
14
19
  else
15
20
  return !!arg
16
- });
21
+ })
17
22
 
18
23
  if (help || args.length === 0) {
19
24
  // If they didn't ask for help, then this is not a "success"
@@ -24,7 +29,9 @@ if (help || args.length === 0) {
24
29
  log('')
25
30
  log('Options:')
26
31
  log('')
27
- log(' -h, --help Display this usage info')
32
+ log(' -h, --help Display this usage info')
33
+ log(' -G, --no-glob Do not expand glob patterns in arguments')
34
+ log(' -g, --glob Expand glob patterns in arguments (default)')
28
35
  process.exit(help ? 0 : 1)
29
36
  } else
30
37
  go(0)
@@ -32,7 +39,10 @@ if (help || args.length === 0) {
32
39
  function go (n) {
33
40
  if (n >= args.length)
34
41
  return
35
- rimraf(args[n], function (er) {
42
+ var options = {}
43
+ if (noglob)
44
+ options = { glob: false }
45
+ rimraf(args[n], options, function (er) {
36
46
  if (er)
37
47
  throw er
38
48
  go(n+1)
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "rimraf",
3
- "version": "2.5.4",
3
+ "version": "2.6.3",
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/)",
7
7
  "license": "ISC",
8
8
  "repository": "git://github.com/isaacs/rimraf.git",
9
9
  "scripts": {
10
+ "preversion": "npm test",
11
+ "postversion": "npm publish",
12
+ "postpublish": "git push origin --all; git push origin --tags",
10
13
  "test": "tap test/*.js"
11
14
  },
12
15
  "bin": "./bin.js",
13
16
  "dependencies": {
14
- "glob": "^7.0.5"
17
+ "glob": "^7.1.3"
15
18
  },
16
19
  "files": [
17
20
  "LICENSE",
@@ -21,6 +24,6 @@
21
24
  ],
22
25
  "devDependencies": {
23
26
  "mkdirp": "^0.5.1",
24
- "tap": "^6.1.1"
27
+ "tap": "^12.1.1"
25
28
  }
26
29
  }
package/rimraf.js CHANGED
@@ -5,6 +5,7 @@ var assert = require("assert")
5
5
  var path = require("path")
6
6
  var fs = require("fs")
7
7
  var glob = require("glob")
8
+ var _0666 = parseInt('666', 8)
8
9
 
9
10
  var defaultGlobOpts = {
10
11
  nosort: true,
@@ -85,7 +86,7 @@ function rimraf (p, options, cb) {
85
86
  results.forEach(function (p) {
86
87
  rimraf_(p, options, function CB (er) {
87
88
  if (er) {
88
- if (isWindows && (er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
89
+ if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
89
90
  busyTries < options.maxBusyTries) {
90
91
  busyTries ++
91
92
  var time = busyTries * 100
@@ -165,7 +166,7 @@ function fixWinEPERM (p, options, er, cb) {
165
166
  if (er)
166
167
  assert(er instanceof Error)
167
168
 
168
- options.chmod(p, 666, function (er2) {
169
+ options.chmod(p, _0666, function (er2) {
169
170
  if (er2)
170
171
  cb(er2.code === "ENOENT" ? null : er)
171
172
  else
@@ -187,7 +188,7 @@ function fixWinEPERMSync (p, options, er) {
187
188
  assert(er instanceof Error)
188
189
 
189
190
  try {
190
- options.chmodSync(p, 666)
191
+ options.chmodSync(p, _0666)
191
192
  } catch (er2) {
192
193
  if (er2.code === "ENOENT")
193
194
  return
@@ -310,6 +311,7 @@ function rimrafSync (p, options) {
310
311
  return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
311
312
  if (er.code !== "EISDIR")
312
313
  throw er
314
+
313
315
  rmdirSync(p, options, er)
314
316
  }
315
317
  }
@@ -339,5 +341,24 @@ function rmkidsSync (p, options) {
339
341
  options.readdirSync(p).forEach(function (f) {
340
342
  rimrafSync(path.join(p, f), options)
341
343
  })
342
- options.rmdirSync(p, options)
344
+
345
+ // We only end up here once we got ENOTEMPTY at least once, and
346
+ // at this point, we are guaranteed to have removed all the kids.
347
+ // So, we know that it won't be ENOENT or ENOTDIR or anything else.
348
+ // try really hard to delete stuff on windows, because it has a
349
+ // PROFOUNDLY annoying habit of not closing handles promptly when
350
+ // files are deleted, resulting in spurious ENOTEMPTY errors.
351
+ var retries = isWindows ? 100 : 1
352
+ var i = 0
353
+ do {
354
+ var threw = true
355
+ try {
356
+ var ret = options.rmdirSync(p, options)
357
+ threw = false
358
+ return ret
359
+ } finally {
360
+ if (++i < retries && threw)
361
+ continue
362
+ }
363
+ } while (true)
343
364
  }