What is del-cli?
The del-cli package is a command-line tool for deleting files and directories using glob patterns. It is a convenient wrapper around the 'del' module, making it easy to use from the command line.
What are del-cli's main functionalities?
Delete files
This feature allows you to delete a specific file by providing its path.
del-cli 'path/to/file.txt'
Delete directories
This feature allows you to delete an entire directory and its contents by providing the directory path.
del-cli 'path/to/directory'
Use glob patterns
This feature allows you to use glob patterns to delete multiple files that match the pattern. For example, this command deletes all .txt files in the specified directory.
del-cli 'path/to/files/*.txt'
Force delete
This feature allows you to forcefully delete files or directories that are normally protected. Use with caution.
del-cli 'path/to/file.txt' --force
Dry run
This feature allows you to perform a dry run, showing which files would be deleted without actually deleting them. This is useful for testing your glob patterns.
del-cli 'path/to/files/*.txt' --dry-run
Other packages similar to del-cli
rimraf
Rimraf is a deep deletion module for node (like `rm -rf`). It is more focused on being a programmatic solution rather than a CLI tool, but it can be used from the command line as well. Rimraf is very robust and handles edge cases like long paths on Windows.
trash-cli
Trash-cli is a command-line tool that moves files and directories to the trash instead of permanently deleting them. This can be safer as it allows for recovery of accidentally deleted files. It is a good alternative if you want a safer deletion process.
shx
Shx is a wrapper around ShellJS Unix commands, providing cross-platform compatibility for shell commands. It includes a `rm` command that can be used to delete files and directories. Shx is useful if you need a broader set of shell commands in addition to deletion.
del-cli
Delete files and directories
Useful for use in build scripts and automated things.
Note that this does permanent deletion. See trash-cli
for something safer.
Install
npm install --global del-cli
Usage
$ del --help
Usage
$ del <path|glob> …
Options
--force, -f Allow deleting the current working directory and outside
--dry-run, -d List what would be deleted instead of deleting
--verbose, -v Display the absolute path of files and directories as they are deleted
Examples
$ del unicorn.png rainbow.png
$ del "*.png" "!unicorn.png"
:warning: Windows users: Since $ del
is already a builtin command on Windows, you need to use $ del-cli
there.
Comparison
Benefits over rimraf
CLI: Supports globbing (even on Windows), safer by default as it doesn't allow deleting parent directories, and has a dry-run mode.
Benefits over rm -rf
: Cross-platform, safer by default as it doesn't allow deleting parent directories, and has a dry-run mode.
Related
- del - API for this package
- trash-cli - Move files and directories to the trash
- make-dir-cli - Make directories and their parents if needed