remove-glob 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,19 +2,27 @@
|
|
|
2
2
|
[](http://www.typescriptlang.org/)
|
|
3
3
|
[](https://vitest.dev/)
|
|
4
4
|
[](https://codecov.io/gh/ghiscoding/remove-glob)
|
|
5
|
-
[](https://www.npmjs.com/package/remove-glob)
|
|
6
|
-
[](https://www.npmjs.com/package/remove-glob)
|
|
7
|
-
[](https://bundlephobia.com/result?p=remove-glob)
|
|
8
5
|
<a href="https://nodejs.org/en/about/previous-releases"><img src="https://img.shields.io/node/v/remove-glob.svg" alt="Node" /></a>
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/remove-glob)
|
|
8
|
+
[](https://www.npmjs.com/package/remove-glob)
|
|
9
|
+
[-1.05kB-1183c4)](https://bundlejs.com/?q=remove-glob)
|
|
10
|
+
[-4.08kB-1183c4)](https://bundlejs.com/?q=remove-glob%2Cremove-glob%2Fdist%2Fcli.js)
|
|
11
|
+
|
|
12
|
+
## Remove-Glob
|
|
11
13
|
|
|
12
14
|
A tiny cross-platform utility to remove items or directories recursively, it also accepts an optional glob pattern. There's also a CLI for easy, cross-platform usage using [cli-nano](https://www.npmjs.com/package/cli-nano) which is the only external dependency.
|
|
13
15
|
|
|
14
16
|
Inspired by [rimraf](https://www.npmjs.com/package/rimraf) and [premove](https://www.npmjs.com/package/premove) but also supports glob pattern to remove multiple files or directories.
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
### Major Changes
|
|
19
|
+
#### version 0.x
|
|
20
|
+
- works with Node.JS 20.x by using `tinyglobby` for glob matching
|
|
21
|
+
|
|
22
|
+
#### version 1.0
|
|
23
|
+
- drop `tinyglobby` and use `fs.glob` native code (requires Node.JS >=22.17)
|
|
24
|
+
|
|
25
|
+
---
|
|
18
26
|
|
|
19
27
|
### Install
|
|
20
28
|
```sh
|
|
@@ -50,8 +58,7 @@ Options:
|
|
|
50
58
|
-v, --version Show version number [boolean]
|
|
51
59
|
```
|
|
52
60
|
|
|
53
|
-
When `exclude` glob pattern(s) are provided, it will override the default exclude
|
|
54
|
-
|
|
61
|
+
When `exclude` glob pattern(s) are provided, it will override the default exclude [`"**/.git/**", "**/.git", "**/node_modules/**", "**/node_modules"`].
|
|
55
62
|
|
|
56
63
|
The `--all`/`-a` option includes dotfiles (files starting with a dot) in glob matches. By default, dotfiles are excluded unless explicitly matched or this option is used.
|
|
57
64
|
|
|
@@ -87,11 +94,12 @@ $ remove foo bar
|
|
|
87
94
|
$ remove --glob \"dist/**/*.{js,map}\"
|
|
88
95
|
```
|
|
89
96
|
|
|
90
|
-
When using the `--glob` option, it will skip `.git/` and `node_modules/` directories by default (
|
|
97
|
+
When using the `--glob` option, it will skip `.git/` and `node_modules/` directories by default (internally it just set that as the default `exclude`). If you want to allow deletion of these directories, you can override the default by providing your own `--exclude` option (including an empty array to disable exclusion), for example:
|
|
91
98
|
|
|
92
99
|
```sh
|
|
93
100
|
# Remove everything, including .git and node_modules
|
|
94
101
|
$ npx remove --glob "**/*" --exclude ""
|
|
102
|
+
|
|
95
103
|
# Or exclude only .git, but allow node_modules to be deleted
|
|
96
104
|
$ npx remove --glob "**/*" --exclude "**/.git/**" --exclude "**/.git"
|
|
97
105
|
```
|
|
@@ -114,7 +122,7 @@ const dir = resolve('./foo/bar');
|
|
|
114
122
|
await removeSync({ paths: ['hello.txt'], cwd: dir });
|
|
115
123
|
```
|
|
116
124
|
|
|
117
|
-
|
|
125
|
+
## JavaScript API
|
|
118
126
|
|
|
119
127
|
```js
|
|
120
128
|
import { removeSync } from 'remove-glob';
|
|
@@ -126,14 +134,14 @@ The first argument is an object holding any of the options shown below. The last
|
|
|
126
134
|
|
|
127
135
|
```js
|
|
128
136
|
{
|
|
129
|
-
cwd: string;
|
|
130
|
-
dryRun: boolean;
|
|
131
|
-
paths: string | string[];
|
|
132
|
-
glob: string | string[];
|
|
133
|
-
exclude: string | string[];
|
|
134
|
-
all: boolean;
|
|
135
|
-
stat: boolean;
|
|
136
|
-
verbose: boolean;
|
|
137
|
+
cwd: string; // directory to resolve your `filepath` from, defaults to `process.cwd()`
|
|
138
|
+
dryRun: boolean; // show what would be removed, without actually removing anything
|
|
139
|
+
paths: string | string[]; // filepath(s) to remove – may be a file or a directory.
|
|
140
|
+
glob: string | string[]; // glob pattern(s) to find which files/directories to remove
|
|
141
|
+
exclude: string | string[]; // glob pattern(s) to exclude from deletion
|
|
142
|
+
all: boolean; // include dotfiles (files starting with a dot) in glob matches
|
|
143
|
+
stat: boolean; // show some statistics after execution (time + file count)
|
|
144
|
+
verbose: boolean; // print more information to console when executing the removal
|
|
137
145
|
}
|
|
138
146
|
```
|
|
139
147
|
|
|
@@ -141,7 +149,7 @@ The first argument is an object holding any of the options shown below. The last
|
|
|
141
149
|
> [!NOTE]
|
|
142
150
|
> The first argument is required and it **must** include either a `paths` or a `glob`, but it cannot include both options simultaneously. A
|
|
143
151
|
|
|
144
|
-
When an `exclude` glob pattern is provided, it will override the default exclusion
|
|
152
|
+
When an `exclude` glob pattern is provided, it will override the default exclusion [`"**/.git/**", "**/.git", "**/node_modules/**", "**/node_modules"`].
|
|
145
153
|
|
|
146
154
|
#### Advanced glob usage
|
|
147
155
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remove-glob",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A tiny utility to remove items or directories recursively, also supports glob",
|
|
5
5
|
"bin": {
|
|
6
6
|
"remove": "dist/cli.js"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"url": "https://github.com/ghiscoding/remove-glob/issues"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"cli-nano": "^1.
|
|
38
|
+
"cli-nano": "^1.4.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": "^22.17.0 || >=24.0.0"
|