source: trip-planner-front/node_modules/del/readme.md@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.1 KB
Line 
1# del [![Build Status](https://travis-ci.org/sindresorhus/del.svg?branch=master)](https://travis-ci.org/sindresorhus/del) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)
2
3> Delete files and folders using [globs](https://github.com/isaacs/minimatch#usage)
4
5Similar to [rimraf](https://github.com/isaacs/rimraf), but with a Promise API and support for multiple files and globbing. It also protects you against deleting the current working directory and above.
6
7---
8
9<p align="center">🐶</p>
10<p align="center"><b>Support this project and improve your JavaScript skills with this great <a href="https://ES6.io/friend/AWESOME">ES6 course</a> by Wes Bos.</b><br>Try his free <a href="https://javascript30.com/friend/AWESOME">JavaScript 30 course</a> for a taste of what to expect. You might also like his <a href="https://ReactForBeginners.com/friend/AWESOME">React</a> and <a href="https://SublimeTextBook.com/friend/AWESOME">Sublime</a> course.</p>
11
12---
13
14
15## Install
16
17```
18$ npm install del
19```
20
21
22## Usage
23
24```js
25const del = require('del');
26
27(async () => {
28 const deletedPaths = await del(['tmp/*.js', '!tmp/unicorn.js']);
29
30 console.log('Deleted files and folders:\n', deletedPaths.join('\n'));
31})();
32```
33
34
35## Beware
36
37The glob pattern `**` matches all children and *the parent*.
38
39So this won't work:
40
41```js
42del.sync(['public/assets/**', '!public/assets/goat.png']);
43```
44
45You have to explicitly ignore the parent directories too:
46
47```js
48del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);
49```
50
51Suggestions on how to improve this welcome!
52
53
54## API
55
56### del(patterns, [options])
57
58Returns a promise for an array of deleted paths.
59
60### del.sync(patterns, [options])
61
62Returns an array of deleted paths.
63
64#### patterns
65
66Type: `string` `string[]`
67
68See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage).
69
70- [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
71- [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
72
73#### options
74
75Type: `Object`
76
77See the [`glob` options](https://github.com/isaacs/node-glob#options).
78
79##### force
80
81Type: `boolean`<br>
82Default: `false`
83
84Allow deleting the current working directory and outside.
85
86##### dryRun
87
88Type: `boolean`<br>
89Default: `false`
90
91See what would be deleted.
92
93```js
94const del = require('del');
95
96(async () => {
97 const deletedPaths = await del(['tmp/*.js'], {dryRun: true});
98
99 console.log('Files and folders that would be deleted:\n', deletedPaths.join('\n'));
100})();
101```
102
103##### concurrency
104
105Type: `number`<br>
106Default: `Infinity`<br>
107Minimum: `1`
108
109Concurrency limit.
110
111
112## CLI
113
114See [del-cli](https://github.com/sindresorhus/del-cli) for a CLI for this module and [trash-cli](https://github.com/sindresorhus/trash-cli) for a safe version that is suitable for running by hand.
115
116
117## Related
118
119- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed
120- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching
121
122
123## License
124
125MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracBrowser for help on using the repository browser.