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:
authorRuy Adorno <ruyadorno@hotmail.com>2020-09-30 20:57:44 +0300
committerRuy Adorno <ruyadorno@hotmail.com>2020-09-30 20:57:44 +0300
commitbc20e0c8ae30a202c72af88586ab9c167dff980a (patch)
treee55437e397b5518cf9ea894fa2dfe617efc956a8 /node_modules/rimraf
parentd77594e52f2f7d65d45347f542f48e4dbb6d2f26 (diff)
rimraf@3.0.2
Diffstat (limited to 'node_modules/rimraf')
-rw-r--r--node_modules/rimraf/CHANGELOG.md65
-rwxr-xr-xnode_modules/rimraf/bin.js64
-rw-r--r--node_modules/rimraf/package.json7
-rw-r--r--node_modules/rimraf/rimraf.js146
4 files changed, 178 insertions, 104 deletions
diff --git a/node_modules/rimraf/CHANGELOG.md b/node_modules/rimraf/CHANGELOG.md
new file mode 100644
index 000000000..f116f1414
--- /dev/null
+++ b/node_modules/rimraf/CHANGELOG.md
@@ -0,0 +1,65 @@
+# v3.0
+
+- Add `--preserve-root` option to executable (default true)
+- Drop support for Node.js below version 6
+
+# v2.7
+
+- Make `glob` an optional dependency
+
+# 2.6
+
+- Retry on EBUSY on non-windows platforms as well
+- Make `rimraf.sync` 10000% more reliable on Windows
+
+# 2.5
+
+- Handle Windows EPERM when lstat-ing read-only dirs
+- Add glob option to pass options to glob
+
+# 2.4
+
+- Add EPERM to delay/retry loop
+- Add `disableGlob` option
+
+# 2.3
+
+- Make maxBusyTries and emfileWait configurable
+- Handle weird SunOS unlink-dir issue
+- Glob the CLI arg for better Windows support
+
+# 2.2
+
+- Handle ENOENT properly on Windows
+- Allow overriding fs methods
+- Treat EPERM as indicative of non-empty dir
+- Remove optional graceful-fs dep
+- Consistently return null error instead of undefined on success
+- win32: Treat ENOTEMPTY the same as EBUSY
+- Add `rimraf` binary
+
+# 2.1
+
+- Fix SunOS error code for a non-empty directory
+- Try rmdir before readdir
+- Treat EISDIR like EPERM
+- Remove chmod
+- Remove lstat polyfill, node 0.7 is not supported
+
+# 2.0
+
+- Fix myGid call to check process.getgid
+- Simplify the EBUSY backoff logic.
+- Use fs.lstat in node >= 0.7.9
+- Remove gently option
+- remove fiber implementation
+- Delete files that are marked read-only
+
+# 1.0
+
+- Allow ENOENT in sync method
+- Throw when no callback is provided
+- Make opts.gently an absolute path
+- use 'stat' if 'lstat' is not available
+- Consistent error naming, and rethrow non-ENOENT stat errors
+- add fiber implementation
diff --git a/node_modules/rimraf/bin.js b/node_modules/rimraf/bin.js
index 0d1e17be7..023814cc9 100755
--- a/node_modules/rimraf/bin.js
+++ b/node_modules/rimraf/bin.js
@@ -1,11 +1,24 @@
#!/usr/bin/env node
-var rimraf = require('./')
+const rimraf = require('./')
-var help = false
-var dashdash = false
-var noglob = false
-var args = process.argv.slice(2).filter(function(arg) {
+const path = require('path')
+
+const isRoot = arg => /^(\/|[a-zA-Z]:\\)$/.test(path.resolve(arg))
+const filterOutRoot = arg => {
+ const ok = preserveRoot === false || !isRoot(arg)
+ if (!ok) {
+ console.error(`refusing to remove ${arg}`)
+ console.error('Set --no-preserve-root to allow this')
+ }
+ return ok
+}
+
+let help = false
+let dashdash = false
+let noglob = false
+let preserveRoot = true
+const args = process.argv.slice(2).filter(arg => {
if (dashdash)
return !!arg
else if (arg === '--')
@@ -16,35 +29,40 @@ var args = process.argv.slice(2).filter(function(arg) {
noglob = false
else if (arg.match(/^(-+|\/)(h(elp)?|\?)$/))
help = true
+ else if (arg === '--preserve-root')
+ preserveRoot = true
+ else if (arg === '--no-preserve-root')
+ preserveRoot = false
else
return !!arg
-})
+}).filter(arg => !preserveRoot || filterOutRoot(arg))
+
+const go = n => {
+ if (n >= args.length)
+ return
+ const options = noglob ? { glob: false } : {}
+ rimraf(args[n], options, er => {
+ if (er)
+ throw er
+ go(n+1)
+ })
+}
if (help || args.length === 0) {
// If they didn't ask for help, then this is not a "success"
- var log = help ? console.log : console.error
+ const log = help ? console.log : console.error
log('Usage: rimraf <path> [<path> ...]')
log('')
log(' Deletes all files and folders at "path" recursively.')
log('')
log('Options:')
log('')
- log(' -h, --help Display this usage info')
- log(' -G, --no-glob Do not expand glob patterns in arguments')
- log(' -g, --glob Expand glob patterns in arguments (default)')
+ log(' -h, --help Display this usage info')
+ log(' -G, --no-glob Do not expand glob patterns in arguments')
+ log(' -g, --glob Expand glob patterns in arguments (default)')
+ log(' --preserve-root Do not remove \'/\' (default)')
+ log(' --no-preserve-root Do not treat \'/\' specially')
+ log(' -- Stop parsing flags')
process.exit(help ? 0 : 1)
} else
go(0)
-
-function go (n) {
- if (n >= args.length)
- return
- var options = {}
- if (noglob)
- options = { glob: false }
- rimraf(args[n], options, function (er) {
- if (er)
- throw er
- go(n+1)
- })
-}
diff --git a/node_modules/rimraf/package.json b/node_modules/rimraf/package.json
index 26e05d85e..1bf8d5e38 100644
--- a/node_modules/rimraf/package.json
+++ b/node_modules/rimraf/package.json
@@ -1,6 +1,6 @@
{
"name": "rimraf",
- "version": "2.7.1",
+ "version": "3.0.2",
"main": "rimraf.js",
"description": "A deep deletion module for node (like `rm -rf`)",
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
@@ -9,7 +9,7 @@
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
- "postpublish": "git push origin --all; git push origin --tags",
+ "postpublish": "git push origin --follow-tags",
"test": "tap test/*.js"
},
"bin": "./bin.js",
@@ -25,5 +25,8 @@
"devDependencies": {
"mkdirp": "^0.5.1",
"tap": "^12.1.1"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
}
}
diff --git a/node_modules/rimraf/rimraf.js b/node_modules/rimraf/rimraf.js
index a90ad029f..34da4171d 100644
--- a/node_modules/rimraf/rimraf.js
+++ b/node_modules/rimraf/rimraf.js
@@ -1,29 +1,25 @@
-module.exports = rimraf
-rimraf.sync = rimrafSync
-
-var assert = require("assert")
-var path = require("path")
-var fs = require("fs")
-var glob = undefined
+const assert = require("assert")
+const path = require("path")
+const fs = require("fs")
+let glob = undefined
try {
glob = require("glob")
} catch (_err) {
// treat glob as optional.
}
-var _0666 = parseInt('666', 8)
-var defaultGlobOpts = {
+const defaultGlobOpts = {
nosort: true,
silent: true
}
// for EMFILE handling
-var timeout = 0
+let timeout = 0
-var isWindows = (process.platform === "win32")
+const isWindows = (process.platform === "win32")
-function defaults (options) {
- var methods = [
+const defaults = options => {
+ const methods = [
'unlink',
'chmod',
'stat',
@@ -31,7 +27,7 @@ function defaults (options) {
'rmdir',
'readdir'
]
- methods.forEach(function(m) {
+ methods.forEach(m => {
options[m] = options[m] || fs[m]
m = m + 'Sync'
options[m] = options[m] || fs[m]
@@ -49,7 +45,7 @@ function defaults (options) {
options.glob = options.glob || defaultGlobOpts
}
-function rimraf (p, options, cb) {
+const rimraf = (p, options, cb) => {
if (typeof options === 'function') {
cb = options
options = {}
@@ -63,27 +59,17 @@ function rimraf (p, options, cb) {
defaults(options)
- var busyTries = 0
- var errState = null
- var n = 0
-
- if (options.disableGlob || !glob.hasMagic(p))
- return afterGlob(null, [p])
-
- options.lstat(p, function (er, stat) {
- if (!er)
- return afterGlob(null, [p])
+ let busyTries = 0
+ let errState = null
+ let n = 0
- glob(p, options.glob, afterGlob)
- })
-
- function next (er) {
+ const next = (er) => {
errState = errState || er
if (--n === 0)
cb(errState)
}
- function afterGlob (er, results) {
+ const afterGlob = (er, results) => {
if (er)
return cb(er)
@@ -91,24 +77,19 @@ function rimraf (p, options, cb) {
if (n === 0)
return cb()
- results.forEach(function (p) {
- rimraf_(p, options, function CB (er) {
+ results.forEach(p => {
+ const CB = (er) => {
if (er) {
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
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)
+ return setTimeout(() => rimraf_(p, options, CB), busyTries * 100)
}
// 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 ++)
+ return setTimeout(() => rimraf_(p, options, CB), timeout ++)
}
// already gone
@@ -117,9 +98,21 @@ function rimraf (p, options, cb) {
timeout = 0
next(er)
- })
+ }
+ rimraf_(p, options, CB)
})
}
+
+ if (options.disableGlob || !glob.hasMagic(p))
+ return afterGlob(null, [p])
+
+ options.lstat(p, (er, stat) => {
+ if (!er)
+ return afterGlob(null, [p])
+
+ glob(p, options.glob, afterGlob)
+ })
+
}
// Two possible strategies.
@@ -133,14 +126,14 @@ function rimraf (p, options, cb) {
//
// If anyone ever complains about this, then I guess the strategy could
// be made configurable somehow. But until then, YAGNI.
-function rimraf_ (p, options, cb) {
+const rimraf_ = (p, options, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
// 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) {
+ options.lstat(p, (er, st) => {
if (er && er.code === "ENOENT")
return cb(null)
@@ -151,7 +144,7 @@ function rimraf_ (p, options, cb) {
if (st && st.isDirectory())
return rmdir(p, options, er, cb)
- options.unlink(p, function (er) {
+ options.unlink(p, er => {
if (er) {
if (er.code === "ENOENT")
return cb(null)
@@ -167,18 +160,16 @@ function rimraf_ (p, options, cb) {
})
}
-function fixWinEPERM (p, options, er, cb) {
+const fixWinEPERM = (p, options, er, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
- if (er)
- assert(er instanceof Error)
- options.chmod(p, _0666, function (er2) {
+ options.chmod(p, 0o666, er2 => {
if (er2)
cb(er2.code === "ENOENT" ? null : er)
else
- options.stat(p, function(er3, stats) {
+ options.stat(p, (er3, stats) => {
if (er3)
cb(er3.code === "ENOENT" ? null : er)
else if (stats.isDirectory())
@@ -189,14 +180,12 @@ function fixWinEPERM (p, options, er, cb) {
})
}
-function fixWinEPERMSync (p, options, er) {
+const fixWinEPERMSync = (p, options, er) => {
assert(p)
assert(options)
- if (er)
- assert(er instanceof Error)
try {
- options.chmodSync(p, _0666)
+ options.chmodSync(p, 0o666)
} catch (er2) {
if (er2.code === "ENOENT")
return
@@ -204,8 +193,9 @@ function fixWinEPERMSync (p, options, er) {
throw er
}
+ let stats
try {
- var stats = options.statSync(p)
+ stats = options.statSync(p)
} catch (er3) {
if (er3.code === "ENOENT")
return
@@ -219,17 +209,15 @@ function fixWinEPERMSync (p, options, er) {
options.unlinkSync(p)
}
-function rmdir (p, options, originalEr, cb) {
+const 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.
- options.rmdir(p, function (er) {
+ options.rmdir(p, er => {
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
rmkids(p, options, cb)
else if (er && er.code === "ENOTDIR")
@@ -239,20 +227,20 @@ function rmdir (p, options, originalEr, cb) {
})
}
-function rmkids(p, options, cb) {
+const rmkids = (p, options, cb) => {
assert(p)
assert(options)
assert(typeof cb === 'function')
- options.readdir(p, function (er, files) {
+ options.readdir(p, (er, files) => {
if (er)
return cb(er)
- var n = files.length
+ let n = files.length
if (n === 0)
return options.rmdir(p, cb)
- var errState
- files.forEach(function (f) {
- rimraf(path.join(p, f), options, function (er) {
+ let errState
+ files.forEach(f => {
+ rimraf(path.join(p, f), options, er => {
if (errState)
return
if (er)
@@ -267,7 +255,7 @@ function rmkids(p, options, 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, options) {
+const rimrafSync = (p, options) => {
options = options || {}
defaults(options)
@@ -276,7 +264,7 @@ function rimrafSync (p, options) {
assert(options, 'rimraf: missing options')
assert.equal(typeof options, 'object', 'rimraf: options should be object')
- var results
+ let results
if (options.disableGlob || !glob.hasMagic(p)) {
results = [p]
@@ -292,11 +280,12 @@ function rimrafSync (p, options) {
if (!results.length)
return
- for (var i = 0; i < results.length; i++) {
- var p = results[i]
+ for (let i = 0; i < results.length; i++) {
+ const p = results[i]
+ let st
try {
- var st = options.lstatSync(p)
+ st = options.lstatSync(p)
} catch (er) {
if (er.code === "ENOENT")
return
@@ -325,11 +314,9 @@ function rimrafSync (p, options) {
}
}
-function rmdirSync (p, options, originalEr) {
+const rmdirSync = (p, options, originalEr) => {
assert(p)
assert(options)
- if (originalEr)
- assert(originalEr instanceof Error)
try {
options.rmdirSync(p)
@@ -343,12 +330,10 @@ function rmdirSync (p, options, originalEr) {
}
}
-function rmkidsSync (p, options) {
+const rmkidsSync = (p, options) => {
assert(p)
assert(options)
- options.readdirSync(p).forEach(function (f) {
- rimrafSync(path.join(p, f), options)
- })
+ options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options))
// We only end up here once we got ENOTEMPTY at least once, and
// at this point, we are guaranteed to have removed all the kids.
@@ -356,12 +341,12 @@ function rmkidsSync (p, options) {
// try really hard to delete stuff on windows, because it has a
// PROFOUNDLY annoying habit of not closing handles promptly when
// files are deleted, resulting in spurious ENOTEMPTY errors.
- var retries = isWindows ? 100 : 1
- var i = 0
+ const retries = isWindows ? 100 : 1
+ let i = 0
do {
- var threw = true
+ let threw = true
try {
- var ret = options.rmdirSync(p, options)
+ const ret = options.rmdirSync(p, options)
threw = false
return ret
} finally {
@@ -370,3 +355,6 @@ function rmkidsSync (p, options) {
}
} while (true)
}
+
+module.exports = rimraf
+rimraf.sync = rimrafSync