Skip to content

Commit

Permalink
rewrite in TS, export hybrid, update changelog, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 12, 2023
1 parent 1b3f46e commit 08bbb06
Show file tree
Hide file tree
Showing 56 changed files with 1,164 additions and 612 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
npm-debug.log
.nyc_output
coverage
/node_modules/
/.nyc_output
/coverage
/dist
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v4.0

- Remove `glob` dependency entirely. This library now only
accepts actual file and folder names to delete.
- Accept array of paths or single path.
- Windows performance and reliability improved.
- All strategies separated into explicitly exported methods.
- Drop support for Node.js below version 14
- rewrite in TypeScript
- ship CJS/ESM hybrid module

# v3.0

- Add `--preserve-root` option to executable (default true)
Expand Down
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,24 @@ Install with `npm install rimraf`, or just drop rimraf.js somewhere.

## API

Hybrid module, load either with `import` or `require()`.

```js
// default export is the main rimraf function
import rimraf from 'rimraf'
// or
const rimraf = require('rimraf').default

// other strategies exported as well
import { rimraf, rimrafSync, native, nativeSync } from 'rimraf'
// or
const { rimraf, rimrafSync, native, nativeSync } = require('rimraf')
```

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

This first parameter is a path. The second argument is an options object.
This first parameter is a path or array of paths. The second
argument is an options object.

Options:

Expand All @@ -31,9 +46,10 @@ Options:
`os.tmpdir()` when that is on the same drive letter as the path
being deleted, or `${drive}:\temp` if present, or `${drive}:\`
if not.
- `retries`: Windows only. Maximum number of synchronous retry
attempts in case of `EBUSY`, `EMFILE`, and `ENFILE` errors.
Default `10`
- `maxRetries`: Windows and Native only. Maximum number of
retry attempts in case of `EBUSY`, `EMFILE`, and `ENFILE`
errors. Default `10` for Windows implementation, `0` for Native
implementation.
- `backoff`: Windows only. Rate of exponential backoff for async
removal in case of `EBUSY`, `EMFILE`, and `ENFILE` errors.
Should be a number greater than 1. Default `1.2`
Expand All @@ -42,6 +58,8 @@ Options:
`ENFILE` errors. Default `200`. With the default `1.2` backoff
rate, this results in 14 retries, with the final retry being
delayed 33ms.
- `retryDelay`: Native only. Time to wait between retries, using
linear backoff. Default `100`.

Any other options are provided to the native Node.js `fs.rm` implementation
when that is used.
Expand Down Expand Up @@ -123,7 +141,7 @@ 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 '/' (default)
--preserve-root Do not remove '/' recursively (default)
--no-preserve-root Do not treat '/' specially
--impl=<type> Specify the implementationt to use.
Expand All @@ -132,11 +150,13 @@ Options:
manual: the platform-specific JS implementation
posix: the Posix JS implementation
windows: the Windows JS implementation
move-remove: a slower Windows JS fallback implementation
Implementation-specific options:
--tmp=<path> Folder to hold temp files for 'windows' implementation
--max-retries=<n> maxRetries for the 'native' implementation
--retry-delay=<n> retryDelay for the 'native' implementation
--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
--backoff=<n> Exponential backoff factor for retries (default: 1.2)
```

## mkdirp
Expand Down
15 changes: 15 additions & 0 deletions fixup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF

chmod 0755 dist/cjs/src/bin.js
53 changes: 0 additions & 53 deletions lib/fix-eperm.js

This file was deleted.

89 changes: 0 additions & 89 deletions lib/fs.js

This file was deleted.

18 changes: 0 additions & 18 deletions lib/ignore-enoent.js

This file was deleted.

69 changes: 0 additions & 69 deletions lib/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions lib/opt-arg.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/platform.js

This file was deleted.

19 changes: 0 additions & 19 deletions lib/readdir-or-error.js

This file was deleted.

14 changes: 0 additions & 14 deletions lib/rimraf-manual.js

This file was deleted.

Loading

0 comments on commit 08bbb06

Please sign in to comment.