https://github.com/luftywiranda13/force-del
Force delete files or folders using globs
https://github.com/luftywiranda13/force-del
clean concurrency del delete destroy dir directory file files folder glob-pattern parallel remove rimraf trash
Last synced: 9 months ago
JSON representation
Force delete files or folders using globs
- Host: GitHub
- URL: https://github.com/luftywiranda13/force-del
- Owner: luftywiranda13
- License: mit
- Created: 2018-01-11T15:12:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:19:11.000Z (over 5 years ago)
- Last Synced: 2025-03-25T21:12:52.419Z (10 months ago)
- Topics: clean, concurrency, del, delete, destroy, dir, directory, file, files, folder, glob-pattern, parallel, remove, rimraf, trash
- Language: JavaScript
- Homepage:
- Size: 133 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# force-del
> Force delete files or folders using [globs](https://github.com/isaacs/minimatch#usage)
[](https://www.npmjs.com/package/force-del)
[](https://npm-stat.com/charts.html?package=force-del&from=2016-04-01)
[](https://travis-ci.org/luftywiranda13/force-del)
[](https://codecov.io/gh/luftywiranda13/force-del)
If the matching files or folders are managed by `git`, theyʼll be deleted and marked as `deleted` in staging area. Otherwise, theyʼll be deleted permanently (not to the trash).
## How does it work?
* Filters the files that should be deleted by using [globby](https://github.com/sindresorhus/globby)
* Maps the matching paths _one-by-one_ to be included in `git rm -rf` command
* Uses [rimraf](https://github.com/isaacs/rimraf) if the matching item isnʼt managed by `git`
* These processes run concurrently
## Installation
```sh
npm install force-del
```
## Usage
```js
const forceDel = require('force-del');
forceDel(['**/*.{gif,jpg}', 'oops/vids/*.3gp']).then(paths => {
console.log('Deleted:\n', paths.join('\n'));
});
```
## API
### forceDel(patterns, [options])
Returns `Promise` of deleted paths.
#### patterns
Type: `string` | `string[]`
See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage).
* [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
* [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
#### options
Type: `Object`
##### concurrency
Type: `number`
Default: `Infinity`
Minimum: `1`
Concurrency limit.
##### cwd
Type: `string`
Default: `process.cwd()`
Current working directory.
##### onlyFiles
Type: `boolean`
Default: `false`
Set to `true` to match files only.
Other options are derived from the defaults of these libraries:
* [globby](https://github.com/sindresorhus/globby#options)
* [node-glob](https://github.com/isaacs/node-glob#options)
* [execa](https://github.com/sindresorhus/execa/#options)
## Related
* [force-del-cli](https://github.com/luftywiranda13/force-del-cli) - CLI for this module
* [remove-lockfiles](https://github.com/luftywiranda13/remove-lockfiles) - Prevent committing lockfiles
## License
MIT © [Lufty Wiranda](https://www.luftywiranda.com)