Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: isaacs/rimraf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.2.0
Choose a base ref
...
head repository: isaacs/rimraf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.3.0
Choose a head ref
  • 9 commits
  • 25 files changed
  • 2 contributors

Commits on Mar 3, 2023

  1. Update v4 glob support in README

    PR-URL: #258
    Credit: @dcroote
    Close: #258
    Reviewed-by: @isaacs
    dcroote authored and isaacs committed Mar 3, 2023
    Copy the full SHA
    e828fe2 View commit details

Commits on Mar 4, 2023

  1. add filter option

    Re: #140
    Fix: #160
    isaacs committed Mar 4, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ed3288e View commit details
  2. add --verbose, --no-verbose to bin

    Fix: #140
    isaacs committed Mar 4, 2023
    Copy the full SHA
    3b57687 View commit details
  3. Copy the full SHA
    ca28abb View commit details
  4. bin: add interactive mode

    I'm slightly concerned that this will hang in CI, the node readline
    module is a bit touchy when stdin is not a tty.
    
    If it's a huge problem, can just make the timeout signal make the test
    pass rather than fail, even though that's really not ideal.  It seems
    really reliable when it is actually interactive, though.
    isaacs committed Mar 4, 2023
    Copy the full SHA
    38e731f View commit details
  5. try to make the interactive test less flaky

    It seems like it's not getting the last item sometimes,
    because the readline doesn't see it in time, or something.
    
    Just keep repeating the last entry if it asks again.
    isaacs committed Mar 4, 2023
    Copy the full SHA
    95e13f2 View commit details
  6. Copy the full SHA
    4cb1d47 View commit details
  7. test: chmod ordering is nondeterministic

    This just snapshots *whether* we had some chmods, since many of these
    cases, it can be one of 2 different files in either order.
    isaacs committed Mar 4, 2023
    Copy the full SHA
    ed7b2a6 View commit details
  8. 4.3.0

    isaacs committed Mar 4, 2023
    Copy the full SHA
    f923bb0 View commit details
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 4.3

- Return boolean indicating whether the path was fully removed
- Add filter option
- bin: add --verbose, -v to print files as they are deleted
- bin: add --no-verbose, -V to not print files as they are deleted
- bin: add -i --interactive to be prompted on each deletion
- bin: add -I --no-interactive to not be prompted on each
deletion

# v4.2

- Brought back `glob` support, using the new and improved glob v9
79 changes: 57 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@ Install with `npm install rimraf`.
## Major Changes from v3 to v4

- The function returns a `Promise` instead of taking a callback.
- Built-in glob support removed.
- Globbing requires the `--glob` option to be set. (Removed in
4.0 and 4.1, opt-in support added in 4.2.)
- Functions take arrays of paths, as well as a single path.
- Native implementation used by default when available, except on
Windows, where this implementation is faster and more reliable.
@@ -14,6 +15,7 @@ Install with `npm install rimraf`.
resolve the situation.
- Simplified implementation on Posix, since the Windows
affordances are not necessary there.
- As of 4.3, return/resolve value is boolean instead of undefined

## API

@@ -31,6 +33,12 @@ import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'
const { rimraf, rimrafSync, native, nativeSync } = require('rimraf')
```

All removal functions return a boolean indicating that all
entries were successfully removed.

The only case in which this will not return `true` is if
something was omitted from the removal via a `filter` option.

### `rimraf(f, [opts]) -> Promise`

This first parameter is a path or array of paths. The second
@@ -63,9 +71,28 @@ Options:
linear backoff. Default `100`.
- `signal` Pass in an AbortSignal to cancel the directory
removal. This is useful when removing large folder structures,
if you'd like to limit the amount of time spent. Using a
`signal` option prevents the use of Node's built-in `fs.rm`
because that implementation does not support abort signals.
if you'd like to limit the amount of time spent.

Using a `signal` option prevents the use of Node's built-in
`fs.rm` because that implementation does not support abort
signals.

- `filter` Method that receives a path string as an argument, and
returns a boolean indicating whether that path should be
deleted. With async rimraf methods, this may return a Promise
that resolves to a boolean. (Since Promises are truthy,
returning a Promise from a sync filter is the same as just not
filtering anything.)

If a filter method is provided, it will _only_ remove entries
if the filter returns (or resolves to) a truthy value. Omitting
a directory will still allow its children to be removed, unless
they are also filtered out, but any parents of a filtered entry
will not be removed, since the directory would not be empty in
that case.

Using a filter method prevents the use of Node's built-in
`fs.rm` because that implementation does not support filtering.

Any other options are provided to the native Node.js `fs.rm` implementation
when that is used.
@@ -141,31 +168,39 @@ Synchronous form of `rimraf.moveRemove()`
### Command Line Interface

```
rimraf version 4.2.0
rimraf version 4.3.0
Usage: rimraf <path> [<path> ...]
Deletes all files and folders at "path", recursively.
Options:
-- Treat all subsequent arguments as paths
-h --help Display this usage info
--preserve-root Do not remove '/' recursively (default)
--no-preserve-root Do not treat '/' specially
-G --no-glob Treat arguments as literal paths, not globs (default)
-g --glob Treat arguments as glob patterns
--impl=<type> Specify the implementation to use.
rimraf: choose the best option
native: the built-in implementation in Node.js
manual: the platform-specific JS implementation
posix: the Posix JS implementation
windows: the Windows JS implementation
move-remove: a slower Windows JS fallback implementation
-- Treat all subsequent arguments as paths
-h --help Display this usage info
--preserve-root Do not remove '/' recursively (default)
--no-preserve-root Do not treat '/' specially
-G --no-glob Treat arguments as literal paths, not globs (default)
-g --glob Treat arguments as glob patterns
-v --verbose Be verbose when deleting files, showing them as
they are removed. Not compatible with --impl=native
-V --no-verbose Be silent when deleting files, showing nothing as
they are removed (default)
-i --interactive Ask for confirmation before deleting anything
Not compatible with --impl=native
-I --no-interactive Do not ask for confirmation before deleting
--impl=<type> Specify the implementation to use:
rimraf: choose the best option (default)
native: the built-in implementation in Node.js
manual: the platform-specific JS implementation
posix: the Posix JS implementation
windows: the Windows JS implementation (falls back to
move-remove on ENOTEMPTY)
move-remove: a slow reliable Windows fallback
Implementation-specific options:
--tmp=<path> Folder to hold temp files for 'move-remove' implementation
--max-retries=<n> maxRetries for the 'native' and 'windows' implementations
--retry-delay=<n> retryDelay for the 'native' implementation, default 100
--tmp=<path> Temp file folder for 'move-remove' implementation
--max-retries=<n> maxRetries for 'native' and 'windows' implementations
--retry-delay=<n> retryDelay for 'native' implementation, default 100
--backoff=<n> Exponential backoff factor for retries (default: 1.2)
```

2 changes: 1 addition & 1 deletion libtap-settings.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,6 @@ const rimraf = require('./')
module.exports = {
rmdirRecursiveSync: path => rimraf.sync(path),
rmdirRecursive(path, cb) {
rimraf(path).then(cb, cb)
rimraf(path, {}).then(() => cb(), cb)
},
}
132 changes: 71 additions & 61 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rimraf",
"version": "4.2.0",
"version": "4.3.0",
"main": "./dist/cjs/src/index-cjs.js",
"module": "./dist/mjs/index.js",
"types": "./dist/mjs/index.d.ts",
@@ -57,7 +57,7 @@
"eslint-config-prettier": "^8.6.0",
"mkdirp": "1",
"prettier": "^2.8.2",
"tap": "^16.3.3",
"tap": "^16.3.4",
"ts-node": "^10.9.1",
"typedoc": "^0.23.21",
"typescript": "^4.9.3"
Loading