remove-glob 0.2.0 → 0.3.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 CHANGED
@@ -5,6 +5,7 @@
5
5
  [![npm](https://img.shields.io/npm/v/remove-glob.svg)](https://www.npmjs.com/package/remove-glob)
6
6
  [![npm](https://img.shields.io/npm/dy/remove-glob)](https://www.npmjs.com/package/remove-glob)
7
7
  [![npm bundle size](https://img.shields.io/bundlephobia/minzip/remove-glob?color=success&label=gzip)](https://bundlephobia.com/result?p=remove-glob)
8
+ <a href="https://nodejs.org/en/about/previous-releases"><img src="https://img.shields.io/node/v/remove-glob.svg" alt="Node" /></a>
8
9
 
9
10
  ## remove-glob
10
11
 
@@ -31,7 +32,7 @@ Positionals:
31
32
  Options:
32
33
  --cwd Directory to resolve from (default ".") [string]
33
34
  --dryRun Show which files/dirs would be deleted but without actually re... [boolean]
34
- --glob Glob pattern to find which files/dirs to remove [string]
35
+ --glob Glob pattern(s) to find which files/dirs to remove [array]
35
36
  --stat Show the stats of the items being removed [boolean]
36
37
  --verbose If true, it will log each file or directory being removed [boolean]
37
38
 
@@ -46,8 +47,9 @@ Remove files or directories. Note: on Windows globs must be **double quoted**,
46
47
  # remove "foo" and "bar" via `npx`
47
48
  $ npx remove foo bar
48
49
 
49
- # or remove using glob pattern
50
+ # or remove using glob pattern(s)
50
51
  $ npx remove --glob \"dist/**/*.js\"
52
+ $ npx remove --glob=\"dist/**/*.js\" --glob=\"packages/*/tsconfig.tsbuildinfo\"
51
53
 
52
54
  # install globally, use whenever
53
55
  $ npm install remove-glob -g
package/dist/cli.js CHANGED
@@ -20,7 +20,7 @@ function handleError(err) {
20
20
  }
21
21
  }
22
22
  try {
23
- const results = parseArgs({
23
+ const config = {
24
24
  command: {
25
25
  name: 'remove',
26
26
  description: 'Remove all items recursively',
@@ -40,31 +40,35 @@ try {
40
40
  description: 'Directory to resolve from (default ".")',
41
41
  },
42
42
  dryRun: {
43
+ alias: 'd',
43
44
  type: 'boolean',
44
45
  default: false,
45
46
  description: 'Show which files/dirs would be deleted but without actually removing them',
46
47
  },
47
48
  glob: {
48
- type: 'string',
49
- description: 'Glob pattern to find which files/dirs to remove',
49
+ alias: 'g',
50
+ type: 'array',
51
+ description: 'Glob pattern(s) to find which files/dirs to remove',
50
52
  },
51
53
  stat: {
52
- type: 'boolean',
54
+ alias: 's',
53
55
  default: false,
54
56
  description: 'Show the stats of the items being removed',
57
+ type: 'boolean',
55
58
  },
56
59
  verbose: {
60
+ alias: 'v',
57
61
  type: 'boolean',
58
62
  default: false,
59
63
  description: 'If true, it will log each file or directory being removed',
60
64
  },
61
65
  },
62
66
  version: readPackage().version,
63
- });
67
+ };
68
+ const results = parseArgs(config);
64
69
  // execute remove function
65
70
  removeSync(results, err => handleError(err));
66
71
  }
67
72
  catch (err) {
68
73
  handleError(err);
69
74
  }
70
- //# sourceMappingURL=cli.js.map
package/dist/index.js CHANGED
@@ -31,8 +31,8 @@ export function removeSync(opts = {}, callback) {
31
31
  paths = paths.length ? [paths] : [];
32
32
  }
33
33
  const requiresCwdChange = !!(paths.length && opts.cwd);
34
- if (!paths.length) {
35
- paths = globSync([opts.glob], { cwd: opts.cwd, dot: true, onlyFiles: false, absolute: true });
34
+ if (!paths.length && opts.glob) {
35
+ paths = globSync(opts.glob, { cwd: opts.cwd, dot: true, onlyFiles: false, absolute: true });
36
36
  }
37
37
  opts.stat && console.time('Duration');
38
38
  opts.dryRun && console.log('=== dry-run ===');
@@ -77,4 +77,3 @@ export function removeSync(opts = {}, callback) {
77
77
  cb();
78
78
  return pathExists;
79
79
  }
80
- //# sourceMappingURL=index.js.map
@@ -9,7 +9,7 @@ export interface RemoveOptions {
9
9
  /** Show which files would be deleted but without actually deleting them */
10
10
  dryRun?: boolean;
11
11
  /** Glob pattern to find which files/directories to remove */
12
- glob?: string;
12
+ glob?: string | string[];
13
13
  /**
14
14
  * The filepath(s) to remove – may be a file or a directory.
15
15
  * An initial existence check is made for this filepath.
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAE/B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B,0CAA0C;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;IAE/B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEzB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE1B,0CAA0C;IAC1C,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=interfaces.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remove-glob",
3
- "version": "0.2.0",
3
+ "version": "0.3.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"
@@ -34,10 +34,14 @@
34
34
  "url": "https://github.com/ghiscoding/remove-glob/issues"
35
35
  },
36
36
  "dependencies": {
37
- "cli-nano": "^1.0.2",
37
+ "cli-nano": "^1.1.3",
38
38
  "tinyglobby": "^0.2.14"
39
39
  },
40
40
  "engines": {
41
- "node": ">=20.0.0"
41
+ "node": "^20.0.0 || >=22.0.0"
42
+ },
43
+ "funding": {
44
+ "type": "ko_fi",
45
+ "url": "https://ko-fi.com/ghiscoding"
42
46
  }
43
47
  }
package/src/cli.ts CHANGED
@@ -6,7 +6,6 @@ import { fileURLToPath } from 'node:url';
6
6
  import { parseArgs } from 'cli-nano';
7
7
 
8
8
  import { removeSync } from './index.js';
9
- import type { RemoveOptions } from './interfaces.js';
10
9
 
11
10
  function readPackage() {
12
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -25,7 +24,7 @@ function handleError(err?: Error) {
25
24
  }
26
25
 
27
26
  try {
28
- const results = parseArgs({
27
+ const config = {
29
28
  command: {
30
29
  name: 'remove',
31
30
  description: 'Remove all items recursively',
@@ -45,30 +44,36 @@ try {
45
44
  description: 'Directory to resolve from (default ".")',
46
45
  },
47
46
  dryRun: {
47
+ alias: 'd',
48
48
  type: 'boolean',
49
49
  default: false,
50
50
  description: 'Show which files/dirs would be deleted but without actually removing them',
51
51
  },
52
52
  glob: {
53
- type: 'string',
54
- description: 'Glob pattern to find which files/dirs to remove',
53
+ alias: 'g',
54
+ type: 'array',
55
+ description: 'Glob pattern(s) to find which files/dirs to remove',
55
56
  },
56
57
  stat: {
57
- type: 'boolean',
58
+ alias: 's',
58
59
  default: false,
59
60
  description: 'Show the stats of the items being removed',
61
+ type: 'boolean',
60
62
  },
61
63
  verbose: {
64
+ alias: 'v',
62
65
  type: 'boolean',
63
66
  default: false,
64
67
  description: 'If true, it will log each file or directory being removed',
65
68
  },
66
69
  },
67
70
  version: readPackage().version,
68
- });
71
+ } as const;
72
+
73
+ const results = parseArgs(config);
69
74
 
70
75
  // execute remove function
71
- removeSync(results as RemoveOptions, err => handleError(err));
76
+ removeSync(results, err => handleError(err));
72
77
  } catch (err) {
73
78
  handleError(err as Error);
74
79
  }
package/src/index.ts CHANGED
@@ -42,8 +42,8 @@ export function removeSync(opts: RemoveOptions = {}, callback?: (e?: Error) => v
42
42
  paths = paths.length ? [paths] : [];
43
43
  }
44
44
  const requiresCwdChange = !!(paths.length && opts.cwd);
45
- if (!paths.length) {
46
- paths = globSync([opts.glob!], { cwd: opts.cwd, dot: true, onlyFiles: false, absolute: true });
45
+ if (!paths.length && opts.glob) {
46
+ paths = globSync(opts.glob, { cwd: opts.cwd, dot: true, onlyFiles: false, absolute: true });
47
47
  }
48
48
  opts.stat && console.time('Duration');
49
49
  opts.dryRun && console.log('=== dry-run ===');
package/src/interfaces.ts CHANGED
@@ -12,7 +12,7 @@ export interface RemoveOptions {
12
12
  dryRun?: boolean;
13
13
 
14
14
  /** Glob pattern to find which files/directories to remove */
15
- glob?: string;
15
+ glob?: string | string[];
16
16
 
17
17
  /**
18
18
  * The filepath(s) to remove – may be a file or a directory.
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGxC,SAAS,WAAW;IAClB,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1D,MAAM,OAAO,G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