Skip to content

Commit b684074

Browse files
committed
mimic node's intended behavior with weird paths
When removing any path that has `..` or `.` as path portions, call `path.normalize` on the path before attempting to process it. When removing the path `''`, throw a `stat ENOENT` error. When removing `.`, replace with `process.cwd()` and proceed as normal. Also, add support for deleting `file:` URLs and Buffer paths, which are normalized to strings for the benefit of older Node versions. Glob patters must still be normal `strings`. This mirrors the behavior of node, once nodejs/node#61968 lands. Closes: #342 Fixes: #326 Re: nodejs/node#61958 Credit: @abhu85, @RajeshKumar11, @isaacs
1 parent 7263194 commit b684074

13 files changed

Lines changed: 598 additions & 467 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,3 @@ jobs:
5252

5353
- name: Run Tests
5454
run: npm test -- -c -t0
55-
env:
56-
RIMRAF_TEST_START_CHAR: a
57-
RIMRAF_TEST_END_CHAR: f
58-
RIMRAF_TEST_DEPTH: 5

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 6.2
2+
3+
- Handle `''`, `'..'` and `'.'` paths the same as Node's intended
4+
behavior.
5+
- Add support for `file:` URL objects and Buffers. (Glob patterns
6+
still have to be normal `string` types.)
7+
18
# 6.1
29

310
- Move to native `fs/promises` usage instead of promisifying

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ something was omitted from the removal via a `filter` option.
8282
This first parameter is a path or array of paths. The second
8383
argument is an options object.
8484

85+
If interpreted as `glob` patterns, then the paths must be
86+
normal `string` values. If not glob pattern matching, then you
87+
may also pass in `file:` URL objects, or `Buffer` objects, which
88+
will be turned into string paths in the normal ways.
89+
8590
Options:
8691

8792
- `preserveRoot`: If set to boolean `false`, then allow the

0 commit comments

Comments
 (0)