Delete files and directories by glob in Node.js, with a promise API
open sourceMITfree
del is a Node.js package that deletes files and directories matching glob patterns, like rimraf but with a promise API, several patterns at once and negated patterns to keep paths. It refuses to delete the current working directory and the directories above it unless forced, offers a dry run that returns what would be deleted, a concurrency limit, and gitignore-aware exclusions through globby, and returns the deleted paths.
Problems it solves
- clean a build directory with glob patterns in a Node.js script
- delete files matching a pattern but keep a few, in Node
- preview which files a cleanup script would delete
Features
- deletes files and directories by glob patterns, with negations
- promise-based deleteAsync and synchronous deleteSync
- protects the working directory and its parents unless forced
- dry run that returns the paths it would delete
- concurrency limit and gitignore-aware exclusions
Limitations
- Glob patterns can only use forward slashes; Windows paths with glob characters need path.posix.join()1
Alternatives
The same job
These do what del does.
- rimraf rm -rf for Node.js, cross-platform
- globby Glob matching for Node.js with negated patterns, directory expansion and .gitignore support
- glob Match files using the patterns the shell uses
- minimatch Glob matching for JavaScript, without regular expressions
- fast-glob Very fast and efficient glob library for Node.js
