rimraf 3.0.2 → 4.0.0
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.
- package/LICENSE +1 -1
- package/README.md +128 -64
- package/dist/cjs/package.json +74 -0
- package/dist/cjs/src/bin.d.ts +7 -0
- package/dist/cjs/src/bin.js +144 -0
- package/dist/cjs/src/bin.js.map +1 -0
- package/dist/cjs/src/default-tmp.d.ts +2 -0
- package/dist/cjs/src/default-tmp.js +61 -0
- package/dist/cjs/src/default-tmp.js.map +1 -0
- package/dist/cjs/src/fix-eperm.d.ts +2 -0
- package/dist/cjs/src/fix-eperm.js +58 -0
- package/dist/cjs/src/fix-eperm.js.map +1 -0
- package/dist/cjs/src/fs.d.ts +17 -0
- package/dist/cjs/src/fs.js +41 -0
- package/dist/cjs/src/fs.js.map +1 -0
- package/dist/cjs/src/ignore-enoent.d.ts +2 -0
- package/dist/cjs/src/ignore-enoent.js +21 -0
- package/dist/cjs/src/ignore-enoent.js.map +1 -0
- package/dist/cjs/src/index.d.ts +60 -0
- package/dist/cjs/src/index.js +79 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/cjs/src/opt-arg.d.ts +3 -0
- package/dist/cjs/src/opt-arg.js +8 -0
- package/dist/cjs/src/opt-arg.js.map +1 -0
- package/dist/cjs/src/path-arg.d.ts +3 -0
- package/dist/cjs/src/path-arg.js +54 -0
- package/dist/cjs/src/path-arg.js.map +1 -0
- package/dist/cjs/src/platform.d.ts +2 -0
- package/dist/cjs/src/platform.js +4 -0
- package/dist/cjs/src/platform.js.map +1 -0
- package/dist/cjs/src/readdir-or-error.d.ts +3 -0
- package/dist/cjs/src/readdir-or-error.js +19 -0
- package/dist/cjs/src/readdir-or-error.js.map +1 -0
- package/dist/cjs/src/retry-busy.d.ts +7 -0
- package/dist/cjs/src/retry-busy.js +65 -0
- package/dist/cjs/src/retry-busy.js.map +1 -0
- package/dist/cjs/src/rimraf-manual.d.ts +2 -0
- package/dist/cjs/src/rimraf-manual.js +12 -0
- package/dist/cjs/src/rimraf-manual.js.map +1 -0
- package/dist/cjs/src/rimraf-move-remove.d.ts +3 -0
- package/dist/cjs/src/rimraf-move-remove.js +124 -0
- package/dist/cjs/src/rimraf-move-remove.js.map +1 -0
- package/dist/cjs/src/rimraf-native.d.ts +3 -0
- package/dist/cjs/src/rimraf-native.js +18 -0
- package/dist/cjs/src/rimraf-native.js.map +1 -0
- package/dist/cjs/src/rimraf-posix.d.ts +3 -0
- package/dist/cjs/src/rimraf-posix.js +60 -0
- package/dist/cjs/src/rimraf-posix.js.map +1 -0
- package/dist/cjs/src/rimraf-windows.d.ts +3 -0
- package/dist/cjs/src/rimraf-windows.js +110 -0
- package/dist/cjs/src/rimraf-windows.js.map +1 -0
- package/dist/cjs/src/use-native.d.ts +2 -0
- package/dist/cjs/src/use-native.js +9 -0
- package/dist/cjs/src/use-native.js.map +1 -0
- package/dist/mjs/package.json +74 -0
- package/dist/mjs/src/bin.d.ts +7 -0
- package/dist/mjs/src/bin.js +138 -0
- package/dist/mjs/src/bin.js.map +1 -0
- package/dist/mjs/src/default-tmp.d.ts +2 -0
- package/dist/mjs/src/default-tmp.js +55 -0
- package/dist/mjs/src/default-tmp.js.map +1 -0
- package/dist/mjs/src/fix-eperm.d.ts +2 -0
- package/dist/mjs/src/fix-eperm.js +53 -0
- package/dist/mjs/src/fix-eperm.js.map +1 -0
- package/dist/mjs/src/fs.d.ts +17 -0
- package/dist/mjs/src/fs.js +27 -0
- package/dist/mjs/src/fs.js.map +1 -0
- package/dist/mjs/src/ignore-enoent.d.ts +2 -0
- package/dist/mjs/src/ignore-enoent.js +16 -0
- package/dist/mjs/src/ignore-enoent.js.map +1 -0
- package/dist/mjs/src/index.d.ts +60 -0
- package/dist/mjs/src/index.js +71 -0
- package/dist/mjs/src/index.js.map +1 -0
- package/dist/mjs/src/opt-arg.d.ts +3 -0
- package/dist/mjs/src/opt-arg.js +6 -0
- package/dist/mjs/src/opt-arg.js.map +1 -0
- package/dist/mjs/src/path-arg.d.ts +3 -0
- package/dist/mjs/src/path-arg.js +49 -0
- package/dist/mjs/src/path-arg.js.map +1 -0
- package/dist/mjs/src/platform.d.ts +2 -0
- package/dist/mjs/src/platform.js +2 -0
- package/dist/mjs/src/platform.js.map +1 -0
- package/dist/mjs/src/readdir-or-error.d.ts +3 -0
- package/dist/mjs/src/readdir-or-error.js +14 -0
- package/dist/mjs/src/readdir-or-error.js.map +1 -0
- package/dist/mjs/src/retry-busy.d.ts +7 -0
- package/dist/mjs/src/retry-busy.js +60 -0
- package/dist/mjs/src/retry-busy.js.map +1 -0
- package/dist/mjs/src/rimraf-manual.d.ts +2 -0
- package/dist/mjs/src/rimraf-manual.js +6 -0
- package/dist/mjs/src/rimraf-manual.js.map +1 -0
- package/dist/mjs/src/rimraf-move-remove.d.ts +3 -0
- package/dist/mjs/src/rimraf-move-remove.js +119 -0
- package/dist/mjs/src/rimraf-move-remove.js.map +1 -0
- package/dist/mjs/src/rimraf-native.d.ts +3 -0
- package/dist/mjs/src/rimraf-native.js +13 -0
- package/dist/mjs/src/rimraf-native.js.map +1 -0
- package/dist/mjs/src/rimraf-posix.d.ts +3 -0
- package/dist/mjs/src/rimraf-posix.js +55 -0
- package/dist/mjs/src/rimraf-posix.js.map +1 -0
- package/dist/mjs/src/rimraf-windows.d.ts +3 -0
- package/dist/mjs/src/rimraf-windows.js +105 -0
- package/dist/mjs/src/rimraf-windows.js.map +1 -0
- package/dist/mjs/src/use-native.d.ts +2 -0
- package/dist/mjs/src/use-native.js +6 -0
- package/dist/mjs/src/use-native.js.map +1 -0
- package/package.json +57 -15
- package/CHANGELOG.md +0 -65
- package/bin.js +0 -68
- package/rimraf.js +0 -360
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The ISC License
|
|
2
2
|
|
|
3
|
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
|
3
|
+
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
6
|
purpose with or without fee is hereby granted, provided that the above
|
package/README.md
CHANGED
|
@@ -1,101 +1,165 @@
|
|
|
1
|
-
[
|
|
2
|
-
|
|
3
|
-
The [UNIX command](http://en.wikipedia.org/wiki/Rm_(Unix)) `rm -rf` for node.
|
|
1
|
+
The [UNIX command](<http://en.wikipedia.org/wiki/Rm_(Unix)>) `rm -rf` for node.
|
|
4
2
|
|
|
5
3
|
Install with `npm install rimraf`, or just drop rimraf.js somewhere.
|
|
6
4
|
|
|
5
|
+
## Major Changes from v3 to v4
|
|
6
|
+
|
|
7
|
+
- The function returns a `Promise` instead of taking a callback.
|
|
8
|
+
- Built-in glob support removed.
|
|
9
|
+
- Functions take arrays of paths, as well as a single path.
|
|
10
|
+
- Native implementation used by default when available.
|
|
11
|
+
- New implementation on Windows, falling back to "move then
|
|
12
|
+
remove" strategy when exponential backoff for `EBUSY` fails to
|
|
13
|
+
resolve the situation.
|
|
14
|
+
- Simplified implementation on Posix, since the Windows affordances are not
|
|
15
|
+
necessary there.
|
|
16
|
+
|
|
7
17
|
## API
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
Hybrid module, load either with `import` or `require()`.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// default export is the main rimraf function
|
|
23
|
+
import rimraf from 'rimraf'
|
|
24
|
+
// or
|
|
25
|
+
const rimraf = require('rimraf').default
|
|
26
|
+
|
|
27
|
+
// other strategies exported as well
|
|
28
|
+
import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'
|
|
29
|
+
// or
|
|
30
|
+
const { rimraf, rimrafSync, native, nativeSync } = require('rimraf')
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `rimraf(f, [opts]) -> Promise`
|
|
34
|
+
|
|
35
|
+
This first parameter is a path or array of paths. The second
|
|
36
|
+
argument is an options object.
|
|
37
|
+
|
|
38
|
+
Options:
|
|
39
|
+
|
|
40
|
+
- `preserveRoot`: If set to boolean `false`, then allow the
|
|
41
|
+
recursive removal of the root directory. Otherwise, this is
|
|
42
|
+
not allowed.
|
|
43
|
+
- `tmp`: Windows only. Temp folder to use to place files and
|
|
44
|
+
folders for the "move then remove" fallback. Must be on the
|
|
45
|
+
same physical device as the path being deleted. Defaults to
|
|
46
|
+
`os.tmpdir()` when that is on the same drive letter as the path
|
|
47
|
+
being deleted, or `${drive}:\temp` if present, or `${drive}:\`
|
|
48
|
+
if not.
|
|
49
|
+
- `maxRetries`: Windows and Native only. Maximum number of
|
|
50
|
+
retry attempts in case of `EBUSY`, `EMFILE`, and `ENFILE`
|
|
51
|
+
errors. Default `10` for Windows implementation, `0` for Native
|
|
52
|
+
implementation.
|
|
53
|
+
- `backoff`: Windows only. Rate of exponential backoff for async
|
|
54
|
+
removal in case of `EBUSY`, `EMFILE`, and `ENFILE` errors.
|
|
55
|
+
Should be a number greater than 1. Default `1.2`
|
|
56
|
+
- `maxBackoff`: Windows only. Maximum total backoff time in ms to
|
|
57
|
+
attempt asynchronous retries in case of `EBUSY`, `EMFILE`, and
|
|
58
|
+
`ENFILE` errors. Default `200`. With the default `1.2` backoff
|
|
59
|
+
rate, this results in 14 retries, with the final retry being
|
|
60
|
+
delayed 33ms.
|
|
61
|
+
- `retryDelay`: Native only. Time to wait between retries, using
|
|
62
|
+
linear backoff. Default `100`.
|
|
63
|
+
|
|
64
|
+
Any other options are provided to the native Node.js `fs.rm` implementation
|
|
65
|
+
when that is used.
|
|
10
66
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
globbing wildcard characters.
|
|
67
|
+
This will attempt to choose the best implementation, based on Node.js
|
|
68
|
+
version and `process.platform`. To force a specific implementation, use
|
|
69
|
+
one of the other functions provided.
|
|
15
70
|
|
|
16
|
-
|
|
17
|
-
errors are handled for you:
|
|
71
|
+
### `rimraf.sync(f, [opts])` `rimraf.rimrafSync(f, [opts])`
|
|
18
72
|
|
|
19
|
-
|
|
20
|
-
`opts.maxBusyTries` times before giving up, adding 100ms of wait
|
|
21
|
-
between each attempt. The default `maxBusyTries` is 3.
|
|
22
|
-
* `ENOENT` - If the file doesn't exist, rimraf will return
|
|
23
|
-
successfully, since your desired outcome is already the case.
|
|
24
|
-
* `EMFILE` - Since `readdir` requires opening a file descriptor, it's
|
|
25
|
-
possible to hit `EMFILE` if too many file descriptors are in use.
|
|
26
|
-
In the sync case, there's nothing to be done for this. But in the
|
|
27
|
-
async case, rimraf will gradually back off with timeouts up to
|
|
28
|
-
`opts.emfileWait` ms, which defaults to 1000.
|
|
73
|
+
Synchronous form of `rimraf()`
|
|
29
74
|
|
|
30
|
-
|
|
75
|
+
Note that, unlike many file system operations, the synchronous form will
|
|
76
|
+
typically be significantly _slower_ than the async form, because recursive
|
|
77
|
+
deletion is extremely parallelizable.
|
|
31
78
|
|
|
32
|
-
|
|
33
|
-
unlinkSync, chmodSync, statSync, lstatSync, rmdirSync, readdirSync
|
|
79
|
+
### `rimraf.native(f, [opts])`
|
|
34
80
|
|
|
35
|
-
|
|
36
|
-
|
|
81
|
+
Uses the built-in `fs.rm` implementation that Node.js provides. This is
|
|
82
|
+
used by default on Node.js versions greater than or equal to `14.14.0`.
|
|
37
83
|
|
|
38
|
-
|
|
39
|
-
the supplied function will be used instead of the default fs
|
|
40
|
-
method.
|
|
84
|
+
### `rimraf.nativeSync(f, [opts])` `rimraf.native.sync(f, [opts])`
|
|
41
85
|
|
|
42
|
-
|
|
86
|
+
Synchronous form of `rimraf.native`
|
|
43
87
|
|
|
44
|
-
|
|
88
|
+
### `rimraf.manual(f, [opts])`
|
|
45
89
|
|
|
46
|
-
|
|
47
|
-
var myCustomFS = require('some-custom-fs')
|
|
90
|
+
Use the JavaScript implementation appropriate for your operating system.
|
|
48
91
|
|
|
49
|
-
|
|
50
|
-
```
|
|
92
|
+
### `rimraf.manualSync(f, [opts])` `rimraf.manualSync(f, opts)`
|
|
51
93
|
|
|
52
|
-
|
|
94
|
+
Synchronous form of `rimraf.manual()`
|
|
53
95
|
|
|
54
|
-
|
|
55
|
-
on Windows systems, then rimraf will retry with a linear backoff
|
|
56
|
-
wait of 100ms longer on each try. The default maxBusyTries is 3.
|
|
96
|
+
### `rimraf.windows(f, [opts])`
|
|
57
97
|
|
|
58
|
-
|
|
98
|
+
JavaScript implementation of file removal appropriate for Windows
|
|
99
|
+
platforms. Works around `unlink` and `rmdir` not being atomic
|
|
100
|
+
operations, and `EPERM` when deleting files with certain
|
|
101
|
+
permission modes.
|
|
59
102
|
|
|
60
|
-
|
|
103
|
+
First deletes all non-directory files within the tree, and then
|
|
104
|
+
removes all directories, which should ideally be empty by that
|
|
105
|
+
time. When an `ENOTEMPTY` is raised in the second pass, falls
|
|
106
|
+
back to the `rimraf.moveRemove` strategy as needed.
|
|
61
107
|
|
|
62
|
-
|
|
63
|
-
repeatedly with a linear backoff of 1ms longer on each try, until
|
|
64
|
-
the timeout counter hits this max. The default limit is 1000.
|
|
108
|
+
### `rimraf.windows.sync(path, [opts])` `rimraf.windowsSync(path, [opts])`
|
|
65
109
|
|
|
66
|
-
|
|
67
|
-
[graceful-fs](http://npm.im/graceful-fs) in your program.
|
|
110
|
+
Synchronous form of `rimraf.windows()`
|
|
68
111
|
|
|
69
|
-
|
|
112
|
+
### `rimraf.moveRemove(path, [opts])`
|
|
70
113
|
|
|
71
|
-
|
|
114
|
+
Moves all files and folders to the parent directory of `path`
|
|
115
|
+
with a temporary filename prior to attempting to remove them.
|
|
72
116
|
|
|
73
|
-
|
|
74
|
-
|
|
117
|
+
Note that, in cases where the operation fails, this _may_ leave
|
|
118
|
+
files lying around in the parent directory with names like
|
|
119
|
+
`.file-basename.txt.0.123412341`. Until the Windows kernel
|
|
120
|
+
provides a way to perform atomic `unlink` and `rmdir` operations,
|
|
121
|
+
this is unfortunately unavoidable.
|
|
75
122
|
|
|
76
|
-
|
|
77
|
-
|
|
123
|
+
To move files to a different temporary directory other than the
|
|
124
|
+
parent, provide `opts.tmp`. Note that this _must_ be on the same
|
|
125
|
+
physical device as the folder being deleted, or else the
|
|
126
|
+
operation will fail.
|
|
78
127
|
|
|
79
|
-
|
|
128
|
+
This is the slowest strategy, but most reliable on Windows
|
|
129
|
+
platforms. Used as a last-ditch fallback by `rimraf.windows()`.
|
|
80
130
|
|
|
81
|
-
|
|
131
|
+
### `rimraf.moveRemove.sync(path, [opts])` `rimraf.moveRemoveSync(path, [opts])`
|
|
82
132
|
|
|
83
|
-
|
|
133
|
+
Synchronous form of `rimraf.moveRemove()`
|
|
84
134
|
|
|
85
|
-
|
|
86
|
-
(Equivalent to setting `glob: false`.)
|
|
135
|
+
### Command Line Interface
|
|
87
136
|
|
|
88
|
-
|
|
137
|
+
```
|
|
138
|
+
Usage: rimraf <path> [<path> ...]
|
|
139
|
+
Deletes all files and folders at "path", recursively.
|
|
89
140
|
|
|
90
|
-
|
|
91
|
-
|
|
141
|
+
Options:
|
|
142
|
+
-- Treat all subsequent arguments as paths
|
|
143
|
+
-h --help Display this usage info
|
|
144
|
+
--preserve-root Do not remove '/' recursively (default)
|
|
145
|
+
--no-preserve-root Do not treat '/' specially
|
|
92
146
|
|
|
93
|
-
|
|
147
|
+
--impl=<type> Specify the implementationt to use.
|
|
148
|
+
rimraf: choose the best option
|
|
149
|
+
native: the C++ implementation in Node.js
|
|
150
|
+
manual: the platform-specific JS implementation
|
|
151
|
+
posix: the Posix JS implementation
|
|
152
|
+
windows: the Windows JS implementation
|
|
153
|
+
move-remove: a slower Windows JS fallback implementation
|
|
94
154
|
|
|
95
|
-
|
|
96
|
-
|
|
155
|
+
Implementation-specific options:
|
|
156
|
+
--tmp=<path> Folder to hold temp files for 'move-remove' implementation
|
|
157
|
+
--max-retries=<n> maxRetries for the 'native' and 'windows' implementations
|
|
158
|
+
--retry-delay=<n> retryDelay for the 'native' implementation, default 100
|
|
159
|
+
--backoff=<n> Exponential backoff factor for retries (default: 1.2)
|
|
160
|
+
```
|
|
97
161
|
|
|
98
162
|
## mkdirp
|
|
99
163
|
|
|
100
|
-
If you need to
|
|
101
|
-
[mkdirp](https://github.com/
|
|
164
|
+
If you need to _create_ a directory recursively, check out
|
|
165
|
+
[mkdirp](https://github.com/isaacs/node-mkdirp).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rimraf",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"main": "./dist/cjs/src/index.js",
|
|
5
|
+
"module": "./dist/mjs/src/index.js",
|
|
6
|
+
"bin": "./dist/cjs/src/bin.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/mjs/src/index.js",
|
|
10
|
+
"require": "./dist/cjs/src/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"description": "A deep deletion module for node (like `rm -rf`)",
|
|
17
|
+
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"repository": "git://github.com/isaacs/rimraf.git",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"preversion": "npm test",
|
|
22
|
+
"postversion": "npm publish",
|
|
23
|
+
"prepublishOnly": "git push origin --follow-tags",
|
|
24
|
+
"preprepare": "rm -rf dist",
|
|
25
|
+
"prepare": "tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json",
|
|
26
|
+
"postprepare": "bash fixup.sh",
|
|
27
|
+
"pretest": "npm run prepare",
|
|
28
|
+
"presnap": "npm run prepare",
|
|
29
|
+
"test": "c8 tap",
|
|
30
|
+
"snap": "c8 tap",
|
|
31
|
+
"format": "prettier --write . --loglevel warn",
|
|
32
|
+
"benchmark": "node benchmark/index.js",
|
|
33
|
+
"typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts"
|
|
34
|
+
},
|
|
35
|
+
"prettier": {
|
|
36
|
+
"semi": false,
|
|
37
|
+
"printWidth": 80,
|
|
38
|
+
"tabWidth": 2,
|
|
39
|
+
"useTabs": false,
|
|
40
|
+
"singleQuote": true,
|
|
41
|
+
"jsxSingleQuote": false,
|
|
42
|
+
"bracketSameLine": true,
|
|
43
|
+
"arrowParens": "avoid",
|
|
44
|
+
"endOfLine": "lf"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^18.11.9",
|
|
48
|
+
"@types/tap": "^15.0.7",
|
|
49
|
+
"c8": "^7.12.0",
|
|
50
|
+
"eslint-config-prettier": "^8.6.0",
|
|
51
|
+
"mkdirp": "1",
|
|
52
|
+
"prettier": "^2.8.2",
|
|
53
|
+
"tap": "^16.3.3",
|
|
54
|
+
"ts-node": "^10.9.1",
|
|
55
|
+
"typedoc": "^0.23.21",
|
|
56
|
+
"typescript": "^4.9.3"
|
|
57
|
+
},
|
|
58
|
+
"tap": {
|
|
59
|
+
"coverage": false,
|
|
60
|
+
"libtap-settings": "libtap-settings.js",
|
|
61
|
+
"node-arg": [
|
|
62
|
+
"--no-warnings",
|
|
63
|
+
"--loader",
|
|
64
|
+
"ts-node/esm"
|
|
65
|
+
],
|
|
66
|
+
"ts": false
|
|
67
|
+
},
|
|
68
|
+
"funding": {
|
|
69
|
+
"url": "https://github.com/sponsors/isaacs"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=14"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.help = void 0;
|
|
8
|
+
const package_json_1 = require("../package.json");
|
|
9
|
+
const _1 = __importDefault(require("./"));
|
|
10
|
+
const runHelpForUsage = () => console.error('run `rimraf --help` for usage information');
|
|
11
|
+
exports.help = `rimraf version ${package_json_1.version}
|
|
12
|
+
|
|
13
|
+
Usage: rimraf <path> [<path> ...]
|
|
14
|
+
Deletes all files and folders at "path", recursively.
|
|
15
|
+
|
|
16
|
+
Options:
|
|
17
|
+
-- Treat all subsequent arguments as paths
|
|
18
|
+
-h --help Display this usage info
|
|
19
|
+
--preserve-root Do not remove '/' recursively (default)
|
|
20
|
+
--no-preserve-root Do not treat '/' specially
|
|
21
|
+
|
|
22
|
+
--impl=<type> Specify the implementationt to use.
|
|
23
|
+
rimraf: choose the best option
|
|
24
|
+
native: the C++ implementation in Node.js
|
|
25
|
+
manual: the platform-specific JS implementation
|
|
26
|
+
posix: the Posix JS implementation
|
|
27
|
+
windows: the Windows JS implementation
|
|
28
|
+
move-remove: a slower Windows JS fallback implementation
|
|
29
|
+
|
|
30
|
+
Implementation-specific options:
|
|
31
|
+
--tmp=<path> Folder to hold temp files for 'move-remove' implementation
|
|
32
|
+
--max-retries=<n> maxRetries for the 'native' and 'windows' implementations
|
|
33
|
+
--retry-delay=<n> retryDelay for the 'native' implementation, default 100
|
|
34
|
+
--backoff=<n> Exponential backoff factor for retries (default: 1.2)
|
|
35
|
+
`;
|
|
36
|
+
const path_1 = require("path");
|
|
37
|
+
const main = async (...args) => {
|
|
38
|
+
if (process.env.__RIMRAF_TESTING_BIN_FAIL__ === '1') {
|
|
39
|
+
throw new Error('simulated rimraf failure');
|
|
40
|
+
}
|
|
41
|
+
const opt = {};
|
|
42
|
+
const paths = [];
|
|
43
|
+
let dashdash = false;
|
|
44
|
+
let impl = _1.default;
|
|
45
|
+
for (const arg of args) {
|
|
46
|
+
if (dashdash) {
|
|
47
|
+
paths.push(arg);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (arg === '--') {
|
|
51
|
+
dashdash = true;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
else if (arg === '-h' || arg === '--help') {
|
|
55
|
+
console.log(exports.help);
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
else if (arg === '--preserve-root') {
|
|
59
|
+
opt.preserveRoot = true;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
else if (arg === '--no-preserve-root') {
|
|
63
|
+
opt.preserveRoot = false;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
else if (/^--tmp=/.test(arg)) {
|
|
67
|
+
const val = arg.substring('--tmp='.length);
|
|
68
|
+
opt.tmp = val;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
else if (/^--max-retries=/.test(arg)) {
|
|
72
|
+
const val = +arg.substring('--max-retries='.length);
|
|
73
|
+
opt.maxRetries = val;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
else if (/^--retry-delay=/.test(arg)) {
|
|
77
|
+
const val = +arg.substring('--retry-delay='.length);
|
|
78
|
+
opt.retryDelay = val;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
else if (/^--backoff=/.test(arg)) {
|
|
82
|
+
const val = +arg.substring('--backoff='.length);
|
|
83
|
+
opt.backoff = val;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
else if (/^--impl=/.test(arg)) {
|
|
87
|
+
const val = arg.substring('--impl='.length);
|
|
88
|
+
switch (val) {
|
|
89
|
+
case 'rimraf':
|
|
90
|
+
impl = _1.default;
|
|
91
|
+
continue;
|
|
92
|
+
case 'native':
|
|
93
|
+
case 'manual':
|
|
94
|
+
case 'posix':
|
|
95
|
+
case 'windows':
|
|
96
|
+
impl = _1.default[val];
|
|
97
|
+
continue;
|
|
98
|
+
case 'move-remove':
|
|
99
|
+
impl = _1.default.moveRemove;
|
|
100
|
+
continue;
|
|
101
|
+
default:
|
|
102
|
+
console.error(`unknown implementation: ${val}`);
|
|
103
|
+
runHelpForUsage();
|
|
104
|
+
return 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (/^-/.test(arg)) {
|
|
108
|
+
console.error(`unknown option: ${arg}`);
|
|
109
|
+
runHelpForUsage();
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
paths.push(arg);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (opt.preserveRoot !== false) {
|
|
117
|
+
for (const path of paths.map(p => (0, path_1.resolve)(p))) {
|
|
118
|
+
if (path === (0, path_1.parse)(path).root) {
|
|
119
|
+
console.error(`rimraf: it is dangerous to operate recursively on '/'`);
|
|
120
|
+
console.error('use --no-preserve-root to override this failsafe');
|
|
121
|
+
return 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (!paths.length) {
|
|
126
|
+
console.error('rimraf: must provide a path to remove');
|
|
127
|
+
runHelpForUsage();
|
|
128
|
+
return 1;
|
|
129
|
+
}
|
|
130
|
+
await impl(paths, opt);
|
|
131
|
+
return 0;
|
|
132
|
+
};
|
|
133
|
+
main.help = exports.help;
|
|
134
|
+
exports.default = main;
|
|
135
|
+
if (typeof require === 'function' &&
|
|
136
|
+
typeof module === 'object' &&
|
|
137
|
+
require.main === module) {
|
|
138
|
+
const args = process.argv.slice(2);
|
|
139
|
+
main(...args).then(code => process.exit(code), er => {
|
|
140
|
+
console.error(er);
|
|
141
|
+
process.exit(1);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=bin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../src/bin.ts"],"names":[],"mappings":";;;;;;;AACA,kDAAyC;AACzC,0CAA0C;AAE1C,MAAM,eAAe,GAAG,GAAG,EAAE,CAC3B,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;AAE/C,QAAA,IAAI,GAAG,kBAAkB,sBAAO;;;;;;;;;;;;;;;;;;;;;;;;CAwB5C,CAAA;AAED,+BAAqC;AAErC,MAAM,IAAI,GAAG,KAAK,EAAE,GAAG,IAAc,EAAE,EA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.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defaultTmpSync = exports.defaultTmp = void 0;
|
|
7
|
+
// The default temporary folder location for use in the windows algorithm.
|
|
8
|
+
// It's TEMPting to use dirname(path), since that's guaranteed to be on the
|
|
9
|
+
// same device. However, this means that:
|
|
10
|
+
// rimraf(path).then(() => rimraf(dirname(path)))
|
|
11
|
+
// will often fail with EBUSY, because the parent dir contains
|
|
12
|
+
// marked-for-deletion directory entries (which do not show up in readdir).
|
|
13
|
+
// The approach here is to use os.tmpdir() if it's on the same drive letter,
|
|
14
|
+
// or resolve(path, '\\temp') if it exists, or the root of the drive if not.
|
|
15
|
+
// On Posix (not that you'd be likely to use the windows algorithm there),
|
|
16
|
+
// it uses os.tmpdir() always.
|
|
17
|
+
const os_1 = require("os");
|
|
18
|
+
const path_1 = require("path");
|
|
19
|
+
const fs_1 = require("./fs");
|
|
20
|
+
const platform_1 = __importDefault(require("./platform"));
|
|
21
|
+
const { stat } = fs_1.promises;
|
|
22
|
+
const isDirSync = (path) => {
|
|
23
|
+
try {
|
|
24
|
+
return (0, fs_1.statSync)(path).isDirectory();
|
|
25
|
+
}
|
|
26
|
+
catch (er) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const isDir = (path) => stat(path).then(st => st.isDirectory(), () => false);
|
|
31
|
+
const win32DefaultTmp = async (path) => {
|
|
32
|
+
const { root } = (0, path_1.parse)(path);
|
|
33
|
+
const tmp = (0, os_1.tmpdir)();
|
|
34
|
+
const { root: tmpRoot } = (0, path_1.parse)(tmp);
|
|
35
|
+
if (root.toLowerCase() === tmpRoot.toLowerCase()) {
|
|
36
|
+
return tmp;
|
|
37
|
+
}
|
|
38
|
+
const driveTmp = (0, path_1.resolve)(root, '/temp');
|
|
39
|
+
if (await isDir(driveTmp)) {
|
|
40
|
+
return driveTmp;
|
|
41
|
+
}
|
|
42
|
+
return root;
|
|
43
|
+
};
|
|
44
|
+
const win32DefaultTmpSync = (path) => {
|
|
45
|
+
const { root } = (0, path_1.parse)(path);
|
|
46
|
+
const tmp = (0, os_1.tmpdir)();
|
|
47
|
+
const { root: tmpRoot } = (0, path_1.parse)(tmp);
|
|
48
|
+
if (root.toLowerCase() === tmpRoot.toLowerCase()) {
|
|
49
|
+
return tmp;
|
|
50
|
+
}
|
|
51
|
+
const driveTmp = (0, path_1.resolve)(root, '/temp');
|
|
52
|
+
if (isDirSync(driveTmp)) {
|
|
53
|
+
return driveTmp;
|
|
54
|
+
}
|
|
55
|
+
return root;
|
|
56
|
+
};
|
|
57
|
+
const posixDefaultTmp = async () => (0, os_1.tmpdir)();
|
|
58
|
+
const posixDefaultTmpSync = () => (0, os_1.tmpdir)();
|
|
59
|
+
exports.defaultTmp = platform_1.default === 'win32' ? win32DefaultTmp : posixDefaultTmp;
|
|
60
|
+
exports.defaultTmpSync = platform_1.default === 'win32' ? win32DefaultTmpSync : posixDefaultTmpSync;
|
|
61
|
+
//# sourceMappingURL=default-tmp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-tmp.js","sourceRoot":"","sources":["../../../src/default-tmp.ts"],"names":[],"mappings":";;;;;;AAAA,0EAA0E;AAC1E,2EAA2E;AAC3E,0CAA0C;AAC1C,iDAAiD;AACjD,8DAA8D;AAC9D,2EAA2E;AAC3E,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,8BAA8B;AAC9B,2BAA2B;AAC3B,+BAAqC;AACrC,6BAAyC;AACzC,0DAAiC;AACjC,MAAM,EAAE,IAAI,EAAE,GAAG,aAAQ,CAAA;AAEzB,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE;IACjC,IAAI;QACF,OAAO,IAAA,aAAQ,EAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;KACpC;IAAC,OAAO,EAAE,EAAE;QACX,OAAO,KAAK,CAAA;KACb;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vB,OAAO,QAAQ,CAAA;KAChB;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE,CAAC,IAAA,WAAM,GAAE,CAAA;AAC5C,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAA,WAAM,GAAE,CAAA;AAE7B,QAAA,UAAU,GACrB,kBAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAA;AAC7C,QAAA,cAAc,GACzB,kBAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fixEPERMSync = exports.fixEPERM = void 0;
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
const { chmod } = fs_1.promises;
|
|
6
|
+
const fixEPERM = (fn) => async (path) => {
|
|
7
|
+
try {
|
|
8
|
+
return await fn(path);
|
|
9
|
+
}
|
|
10
|
+
catch (er) {
|
|
11
|
+
const fer = er;
|
|
12
|
+
if (fer?.code === 'ENOENT') {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (fer?.code === 'EPERM') {
|
|
16
|
+
try {
|
|
17
|
+
await chmod(path, 0o666);
|
|
18
|
+
}
|
|
19
|
+
catch (er2) {
|
|
20
|
+
const fer2 = er2;
|
|
21
|
+
if (fer2?.code === 'ENOENT') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
throw er;
|
|
25
|
+
}
|
|
26
|
+
return await fn(path);
|
|
27
|
+
}
|
|
28
|
+
throw er;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.fixEPERM = fixEPERM;
|
|
32
|
+
const fixEPERMSync = (fn) => (path) => {
|
|
33
|
+
try {
|
|
34
|
+
return fn(path);
|
|
35
|
+
}
|
|
36
|
+
catch (er) {
|
|
37
|
+
const fer = er;
|
|
38
|
+
if (fer?.code === 'ENOENT') {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (fer?.code === 'EPERM') {
|
|
42
|
+
try {
|
|
43
|
+
(0, fs_1.chmodSync)(path, 0o666);
|
|
44
|
+
}
|
|
45
|
+
catch (er2) {
|
|
46
|
+
const fer2 = er2;
|
|
47
|
+
if (fer2?.code === 'ENOENT') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
throw er;
|
|
51
|
+
}
|
|
52
|
+
return fn(path);
|
|
53
|
+
}
|
|
54
|
+
throw er;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.fixEPERMSync = fixEPERMSync;
|
|
58
|
+
//# sourceMappingURL=fix-eperm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fix-eperm.js","sourceRoot":"","sources":["../../../src/fix-eperm.ts"],"names":[],"mappings":";;;AAAA,6BAAmD;AACnD,MAAM,EAAE,KAAK,EAAE,GAAG,aAAQ,CAAA;AAEnB,MAAM,QAAQ,GACnB,CAAC,EAAkC,EAAE,EAAE,CAAC,KAAK,EAAE,IAAY,EAAE,EAAE;IAC7D,IAAI;QACF,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;KACtB;IAAC,OAAO,EAAE,EAAE;QACX,MAAM,GAAG,GAAG,EAAa,CAAA;QACzB,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,EAAE;YAC1B,OAAM;SACP;QACD,IAAI,GAAG,EAAE,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI;gBACF,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;aACzB;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,IAAI,GAAG,GAAc,CAAA;gBAC3B,IAAI,IAAI,EAAE,IAAI,KAAK,QAAQ,EAAE;oBAC3B,OAAM;iBACP;gBACD,MAAM,EAAE,CAAA;aACT;YACD,OAAO,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;SACtB;QACD,MAAM,EAAE,CAAA;KACT;AACH,CAAC,CAAA;AAvBU,QAAA,QAAQ,YAuBlB;AAEI,MAAM,YAAY,GAAG,CAAC,EAAyB,EAAE,EAAE,CAAC,CAAC,IAAY,EAAE,EAAE;IAC1E,IAAI;QACF,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;KAChB;IAAC,OAAO,EAAE,EAAE;QACX,MAAM,GAAG,GAAG,EAAa,CAAA;QACzB,IAAI,GAAG,EAAE,IAAI,KAAK,QAAQ,EAAE;YAC1B,OAAM;SACP;QACD,IAAI,GAAG,EAAE,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI;gBACF,IAAA,cAAS,EAAC,IAAI,EAAE,KAAK,CAAC,CAAA;aACvB;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,IAAI,GAAG,GAAc,CAAA;gBAC3B,IAAI,IAAI,EAAE,IAAI,KAAK,QAAQ,EAAE;oBAC3B,OAAM;iBACP;gBACD,MAAM,EAAE,CAAA;aACT;YACD,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;SAChB;QACD,MAAM,EAAE,CAAA;KACT;AACH,CAAC,CAAA;AAtBY,QAAA,YAAY,gBAsBxB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
export type FsError = Error & {
|
|
3
|
+
code?: string;
|
|
4
|
+
};
|
|
5
|
+
export { chmodSync, mkdirSync, readdirSync, renameSync, rmdirSync, rmSync, statSync, unlinkSync, } from 'fs';
|
|
6
|
+
export declare const promises: {
|
|
7
|
+
chmod: (path: fs.PathLike, mode: fs.Mode) => Promise<void>;
|
|
8
|
+
mkdir: (path: fs.PathLike, options?: fs.Mode | (fs.MakeDirectoryOptions & {
|
|
9
|
+
recursive?: boolean | null;
|
|
10
|
+
}) | undefined | null) => Promise<string | undefined>;
|
|
11
|
+
readdir: (path: fs.PathLike) => Promise<string[]>;
|
|
12
|
+
rename: (oldPath: fs.PathLike, newPath: fs.PathLike) => Promise<void>;
|
|
13
|
+
rm: (path: fs.PathLike, options: fs.RmOptions) => Promise<void>;
|
|
14
|
+
rmdir: (path: fs.PathLike) => Promise<void>;
|
|
15
|
+
stat: (path: fs.PathLike) => Promise<fs.Stats>;
|
|
16
|
+
unlink: (path: fs.PathLike) => Promise<void>;
|
|
17
|
+
};
|