remove-glob 0.3.2 → 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 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 1 or more file/directory paths to be removed or any other options shown below (you can use an optional `--glob` pattern instead of paths).
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
- Positionals:
30
- paths directory or file paths to remove [string]
33
+ Arguments:
34
+ paths directory or file paths to remove [string..]
31
35
 
32
36
  Options:
33
- --cwd Directory to resolve from (default ".") [string]
34
- --dryRun Show which files/dirs would be deleted but without actually re... [boolean]
35
- --glob Glob pattern(s) to find which files/dirs to remove [array]
36
- --stat Show the stats of the items being removed [boolean]
37
- --verbose If true, it will log each file or directory being removed [boolean]
38
-
39
- Default options:
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
- try {
67
- // remove via paths
68
- removeSync({ paths: './foobar' });
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
- // or remove via glob pattern
72
- removeSync({ glob: 'foo/**/*.txt' })
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
- > [!WARNING]
104
- > The first argument is necessary and it **must** include a `paths` or a `glob` (but it cannot include both options together).
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
- description: 'Remove all items recursively',
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
- description: 'directory or file paths to remove',
38
+ describe: 'Directory or file paths to remove',
31
39
  type: 'string',
32
40
  variadic: true,
33
41
  required: false,
@@ -37,33 +45,34 @@ try {
37
45
  options: {
38
46
  cwd: {
39
47
  type: 'string',
40
- description: 'Directory to resolve from (default ".")',
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
- description: 'Show which files/dirs would be deleted but without actually removing them',
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
- description: 'Glob pattern(s) to find which files/dirs to remove',
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
- description: 'Show the stats of the items being removed',
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
- description: 'If true, it will log each file or directory being removed',
71
+ describe: 'If true, it will log each file or directory being removed',
64
72
  },
65
73
  },
66
- helpDescLength: 75,
74
+ helpOptLength: 16,
75
+ helpDescLength: 73,
67
76
  version: readPackage().version,
68
77
  };
69
78
  const results = parseArgs(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remove-glob",
3
- "version": "0.3.2",
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.3",
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
- description: 'Remove all items recursively',
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
- description: 'directory or file paths to remove',
43
+ describe: 'Directory or file paths to remove',
35
44
  type: 'string',
36
45
  variadic: true,
37
46
  required: false,
@@ -41,33 +50,34 @@ try {
41
50
  options: {
42
51
  cwd: {
43
52
  type: 'string',
44
- description: 'Directory to resolve from (default ".")',
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
- description: 'Show which files/dirs would be deleted but without actually removing them',
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
- description: 'Glob pattern(s) to find which files/dirs to remove',
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
- description: 'Show the stats of the items being removed',
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
- description: 'If true, it will log each file or directory being removed',
76
+ describe: 'If true, it will log each file or directory being removed',
68
77
  },
69
78
  },
70
- helpDescLength: 75,
79
+ helpOptLength: 16,
80
+ helpDescLength: 73,
71
81
  version: readPackage().version,
72
82
  } as const;
73
83