remove-glob 0.3.1 → 0.3.3
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 +21 -23
- package/dist/cli.js +17 -7
- package/package.json +2 -2
- package/src/cli.ts +18 -7
package/README.md
CHANGED
|
@@ -20,25 +20,27 @@ npm install remove-glob
|
|
|
20
20
|
|
|
21
21
|
### Command Line
|
|
22
22
|
|
|
23
|
-
A `remove` binary is available, it takes
|
|
23
|
+
A `remove` binary is available, it takes an optional paths argument (zero or multiple file/directory paths) to be removed **or** a `--glob` pattern instead of paths.
|
|
24
|
+
|
|
25
|
+
> [!NOTE]
|
|
26
|
+
> The `paths` (argument) and `glob` (option) are both optional, but you **must** provide at least 1 of them.
|
|
27
|
+
> However, providing both of them simultaneously is not supported (choose which option is best suited to your use case).
|
|
24
28
|
|
|
25
29
|
```
|
|
26
30
|
Usage:
|
|
27
31
|
remove [paths..] [options] Remove all items recursively
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
paths
|
|
33
|
+
Arguments:
|
|
34
|
+
paths directory or file paths to remove [string..]
|
|
31
35
|
|
|
32
36
|
Options:
|
|
33
|
-
--cwd
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-h, --help Show help [boolean]
|
|
41
|
-
-v, --version Show version number [boolean]
|
|
37
|
+
--cwd Directory to resolve from (default ".") [string]
|
|
38
|
+
-d, --dryRun Show which files/dirs would be deleted but without actually removing them [boolean]
|
|
39
|
+
-g, --glob Glob pattern(s) to find which files/dirs to remove [array]
|
|
40
|
+
-s, --stat Show the stats of the items being removed [boolean]
|
|
41
|
+
-v, --verbose If true, it will log each file or directory being removed [boolean]
|
|
42
|
+
-h, --help Show help [boolean]
|
|
43
|
+
-v, --version Show version number [boolean]
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
Remove files or directories. Note: on Windows globs must be **double quoted**, everybody else can quote however they please.
|
|
@@ -63,16 +65,12 @@ $ remove --glob \"dist/**/*.{js,map}\"
|
|
|
63
65
|
import { resolve } from 'node:path';
|
|
64
66
|
import { removeSync } from 'remove-glob';
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
removeSync({ paths: ['./foo/file1.txt', './foo/file2.txt'] });
|
|
68
|
+
// remove via paths
|
|
69
|
+
removeSync({ paths: './foobar' });
|
|
70
|
+
removeSync({ paths: ['./foo/file1.txt', './foo/file2.txt'] });
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} catch (err) {
|
|
74
|
-
//
|
|
75
|
-
}
|
|
72
|
+
// or remove via glob pattern
|
|
73
|
+
removeSync({ glob: 'foo/**/*.txt' });
|
|
76
74
|
|
|
77
75
|
// Using `cwd` option
|
|
78
76
|
const dir = resolve('./foo/bar');
|
|
@@ -100,5 +98,5 @@ The first argument is an object holding any of the options shown below. The last
|
|
|
100
98
|
}
|
|
101
99
|
```
|
|
102
100
|
|
|
103
|
-
> [!
|
|
104
|
-
> The first argument is
|
|
101
|
+
> [!NOTE]
|
|
102
|
+
> The first argument is required and it **must** include either a `paths` or a `glob`, but it cannot include both options simultaneously.
|
package/dist/cli.js
CHANGED
|
@@ -23,11 +23,19 @@ try {
|
|
|
23
23
|
const config = {
|
|
24
24
|
command: {
|
|
25
25
|
name: 'remove',
|
|
26
|
-
|
|
26
|
+
describe: 'Remove all items recursively',
|
|
27
|
+
examples: [
|
|
28
|
+
{ cmd: '$0 foo bar', describe: '→ Remove "foo" and "bar" folders' },
|
|
29
|
+
{ cmd: '$0 --glob=\"dist/**/*.js\"', describe: '→ Remove all files from from "dist" folder with ".js" extension' },
|
|
30
|
+
{
|
|
31
|
+
cmd: '$0 --glob=\"dist/**/*.js\" --glob=\"packages/*/tsconfig.tsbuildinfo\"',
|
|
32
|
+
describe: '→ Remove all files from from "dist" folder with ".js" extension and "tsconfig.tsbuildinfo" file from every "packages" folders',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
27
35
|
positionals: [
|
|
28
36
|
{
|
|
29
37
|
name: 'paths',
|
|
30
|
-
|
|
38
|
+
describe: 'Directory or file paths to remove',
|
|
31
39
|
type: 'string',
|
|
32
40
|
variadic: true,
|
|
33
41
|
required: false,
|
|
@@ -37,32 +45,34 @@ try {
|
|
|
37
45
|
options: {
|
|
38
46
|
cwd: {
|
|
39
47
|
type: 'string',
|
|
40
|
-
|
|
48
|
+
describe: 'Directory to resolve from (default ".")',
|
|
41
49
|
},
|
|
42
50
|
dryRun: {
|
|
43
51
|
alias: 'd',
|
|
44
52
|
type: 'boolean',
|
|
45
53
|
default: false,
|
|
46
|
-
|
|
54
|
+
describe: 'Show which files/dirs would be deleted but without actually removing them',
|
|
47
55
|
},
|
|
48
56
|
glob: {
|
|
49
57
|
alias: 'g',
|
|
50
58
|
type: 'array',
|
|
51
|
-
|
|
59
|
+
describe: 'Glob pattern(s) to find which files/dirs to remove',
|
|
52
60
|
},
|
|
53
61
|
stat: {
|
|
54
62
|
alias: 's',
|
|
55
63
|
default: false,
|
|
56
|
-
|
|
64
|
+
describe: 'Show the stats of the items being removed',
|
|
57
65
|
type: 'boolean',
|
|
58
66
|
},
|
|
59
67
|
verbose: {
|
|
60
68
|
alias: 'v',
|
|
61
69
|
type: 'boolean',
|
|
62
70
|
default: false,
|
|
63
|
-
|
|
71
|
+
describe: 'If true, it will log each file or directory being removed',
|
|
64
72
|
},
|
|
65
73
|
},
|
|
74
|
+
helpOptLength: 16,
|
|
75
|
+
helpDescLength: 73,
|
|
66
76
|
version: readPackage().version,
|
|
67
77
|
};
|
|
68
78
|
const results = parseArgs(config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remove-glob",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "A tiny utility to remove items or directories recursively, also supports glob",
|
|
5
5
|
"bin": {
|
|
6
6
|
"remove": "dist/cli.js"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"url": "https://github.com/ghiscoding/remove-glob/issues"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"cli-nano": "^1.1
|
|
37
|
+
"cli-nano": "^1.2.1",
|
|
38
38
|
"tinyglobby": "^0.2.14"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
package/src/cli.ts
CHANGED
|
@@ -27,11 +27,20 @@ try {
|
|
|
27
27
|
const config = {
|
|
28
28
|
command: {
|
|
29
29
|
name: 'remove',
|
|
30
|
-
|
|
30
|
+
describe: 'Remove all items recursively',
|
|
31
|
+
examples: [
|
|
32
|
+
{ cmd: '$0 foo bar', describe: '→ Remove "foo" and "bar" folders' },
|
|
33
|
+
{ cmd: '$0 --glob=\"dist/**/*.js\"', describe: '→ Remove all files from from "dist" folder with ".js" extension' },
|
|
34
|
+
{
|
|
35
|
+
cmd: '$0 --glob=\"dist/**/*.js\" --glob=\"packages/*/tsconfig.tsbuildinfo\"',
|
|
36
|
+
describe:
|
|
37
|
+
'→ Remove all files from from "dist" folder with ".js" extension and "tsconfig.tsbuildinfo" file from every "packages" folders',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
31
40
|
positionals: [
|
|
32
41
|
{
|
|
33
42
|
name: 'paths',
|
|
34
|
-
|
|
43
|
+
describe: 'Directory or file paths to remove',
|
|
35
44
|
type: 'string',
|
|
36
45
|
variadic: true,
|
|
37
46
|
required: false,
|
|
@@ -41,32 +50,34 @@ try {
|
|
|
41
50
|
options: {
|
|
42
51
|
cwd: {
|
|
43
52
|
type: 'string',
|
|
44
|
-
|
|
53
|
+
describe: 'Directory to resolve from (default ".")',
|
|
45
54
|
},
|
|
46
55
|
dryRun: {
|
|
47
56
|
alias: 'd',
|
|
48
57
|
type: 'boolean',
|
|
49
58
|
default: false,
|
|
50
|
-
|
|
59
|
+
describe: 'Show which files/dirs would be deleted but without actually removing them',
|
|
51
60
|
},
|
|
52
61
|
glob: {
|
|
53
62
|
alias: 'g',
|
|
54
63
|
type: 'array',
|
|
55
|
-
|
|
64
|
+
describe: 'Glob pattern(s) to find which files/dirs to remove',
|
|
56
65
|
},
|
|
57
66
|
stat: {
|
|
58
67
|
alias: 's',
|
|
59
68
|
default: false,
|
|
60
|
-
|
|
69
|
+
describe: 'Show the stats of the items being removed',
|
|
61
70
|
type: 'boolean',
|
|
62
71
|
},
|
|
63
72
|
verbose: {
|
|
64
73
|
alias: 'v',
|
|
65
74
|
type: 'boolean',
|
|
66
75
|
default: false,
|
|
67
|
-
|
|
76
|
+
describe: 'If true, it will log each file or directory being removed',
|
|
68
77
|
},
|
|
69
78
|
},
|
|
79
|
+
helpOptLength: 16,
|
|
80
|
+
helpDescLength: 73,
|
|
70
81
|
version: readPackage().version,
|
|
71
82
|
} as const;
|
|
72
83
|
|