remove-glob 0.4.9 → 1.0.0

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
@@ -9,10 +9,13 @@
9
9
 
10
10
  ## remove-glob
11
11
 
12
- 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. It uses 2 small dependencies [tinyglobby](https://www.npmjs.com/package/tinyglobby) for glob support and [cli-nano](https://www.npmjs.com/package/cli-nano) for the CLI.
12
+ 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
13
 
14
14
  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
15
 
16
+ > [!NOTE]
17
+ > This project now requires Node.JS >= 22.17.0 so that we can use the native `fs.glob`, however if you can't update your Node.JS just yet, then just stick with `remove-glob: ^0.4.10` since that is the only change in v1.0.0
18
+
16
19
  ### Install
17
20
  ```sh
18
21
  npm install remove-glob
@@ -26,6 +29,9 @@ A `remove` binary is available, it takes an optional path argument (zero or mult
26
29
  > The `paths` and `glob` arguments are both optionals, but you **must** provide at least 1 of them.
27
30
  > However, please note that providing both of them simultaneously is not supported and will throw an error (choose the option that is best suited to your use case).
28
31
 
32
+ > [!NOTE]
33
+ > When using the `--glob` option, dotfiles and dot-directories (e.g. `.env`, `.gitignore`, `.config/`) are included by default. If you want to exclude them, you can adjust your glob pattern (e.g. use `**/[!.]*.js` or add an `!**/.*` pattern).
34
+
29
35
  ```
30
36
  Usage:
31
37
  remove [paths..] [options] Remove all items recursively
package/dist/cli.js CHANGED
@@ -3,8 +3,7 @@ import { readFileSync } from 'node:fs';
3
3
  import { dirname, resolve } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { parseArgs } from 'cli-nano';
6
- // @ts-expect-error
7
- import { removeSync } from './index.ts';
6
+ import { removeSync } from './index.js';
8
7
  function readPackage() {
9
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
10
9
  const pkgPath = resolve(__dirname, '../package.json');
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { RemoveOptions } from './interfaces.ts';
1
+ import type { RemoveOptions } from './interfaces.js';
2
2
  /**
3
3
  * Remove the files or directories, the item(s) can be provided via positional arguments or via a `--glob` pattern.
4
4
  * @param {RemoveOptions} options - CLI options
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAWrD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,aAAkB,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,qBAwElF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,aAAkB,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,qBAwElF"}
package/dist/index.js CHANGED
@@ -1,15 +1,6 @@
1
- import { existsSync, rmSync, statSync, unlinkSync } from 'node:fs';
1
+ import { existsSync, globSync, rmSync, statSync, unlinkSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
- import { globSync } from 'tinyglobby';
4
- /** Helper to throw or callback with error */
5
- function throwOrCallback(err, cb) {
6
- if (typeof cb === 'function') {
7
- cb(err);
8
- }
9
- else {
10
- throw err;
11
- }
12
- }
3
+ import { throwOrCallback } from './utils.js';
13
4
  /**
14
5
  * Remove the files or directories, the item(s) can be provided via positional arguments or via a `--glob` pattern.
15
6
  * @param {RemoveOptions} options - CLI options
@@ -32,13 +23,12 @@ export function removeSync(opts = {}, callback) {
32
23
  }
33
24
  const requiresCwdChange = !!(paths.length && opts.cwd);
34
25
  if (!paths.length && opts.glob) {
35
- paths = globSync(opts.glob, {
36
- cwd: opts.cwd,
37
- dot: true,
38
- onlyFiles: false,
39
- absolute: true,
40
- ignore: ['**/.git/**', '**/node_modules/**'],
41
- });
26
+ // Use fs.globSync to match files. Dotfiles and dot-directories are always included.
27
+ paths = globSync(opts.glob, { cwd: opts.cwd });
28
+ // Manually resolve to absolute paths if cwd is set
29
+ if (opts.cwd) {
30
+ paths = paths.map(p => resolve(opts.cwd, p));
31
+ }
42
32
  }
43
33
  if (opts.stat || opts.verbose) {
44
34
  console.time('Duration');
@@ -0,0 +1,3 @@
1
+ /** Helper to throw or callback with error */
2
+ export declare function throwOrCallback(err?: Error, cb?: (e?: Error) => void): void;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,wBAAgB,eAAe,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,QAMpE"}
package/dist/utils.js ADDED
@@ -0,0 +1,9 @@
1
+ /** Helper to throw or callback with error */
2
+ export function throwOrCallback(err, cb) {
3
+ if (typeof cb === 'function') {
4
+ cb(err);
5
+ }
6
+ else {
7
+ throw err;
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remove-glob",
3
- "version": "0.4.9",
3
+ "version": "1.0.0",
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,11 +35,10 @@
35
35
  "url": "https://github.com/ghiscoding/remove-glob/issues"
36
36
  },
37
37
  "dependencies": {
38
- "cli-nano": "^1.2.2",
39
- "tinyglobby": "^0.2.15"
38
+ "cli-nano": "^1.2.2"
40
39
  },
41
40
  "engines": {
42
- "node": "^20.0.0 || >=22.0.0"
41
+ "node": "^22.17.0 || >=24.0.0"
43
42
  },
44
43
  "funding": {
45
44
  "type": "ko_fi",
package/src/cli.ts CHANGED
@@ -5,8 +5,7 @@ import { dirname, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { parseArgs } from 'cli-nano';
7
7
 
8
- // @ts-expect-error
9
- import { removeSync } from './index.ts';
8
+ import { removeSync } from './index.js';
10
9
 
11
10
  function readPackage() {
12
11
  const __dirname = dirname(fileURLToPath(import.meta.url));
package/src/index.ts CHANGED
@@ -1,17 +1,7 @@
1
- import { existsSync, rmSync, statSync, unlinkSync } from 'node:fs';
1
+ import { existsSync, globSync, rmSync, statSync, unlinkSync } from 'node:fs';
2
2
  import { resolve } from 'node:path';
3
- import { globSync } from 'tinyglobby';
4
-
5
- import type { RemoveOptions } from './interfaces.ts';
6
-
7
- /** Helper to throw or callback with error */
8
- function throwOrCallback(err?: Error, cb?: (e?: Error) => void) {
9
- if (typeof cb === 'function') {
10
- cb(err);
11
- } else {
12
- throw err;
13
- }
14
- }
3
+ import type { RemoveOptions } from './interfaces.js';
4
+ import { throwOrCallback } from './utils.js';
15
5
 
16
6
  /**
17
7
  * Remove the files or directories, the item(s) can be provided via positional arguments or via a `--glob` pattern.
@@ -43,13 +33,13 @@ export function removeSync(opts: RemoveOptions = {}, callback?: (e?: Error) => v
43
33
  }
44
34
  const requiresCwdChange = !!(paths.length && opts.cwd);
45
35
  if (!paths.length && opts.glob) {
46
- paths = globSync(opts.glob, {
47
- cwd: opts.cwd,
48
- dot: true,
49
- onlyFiles: false,
50
- absolute: true,
51
- ignore: ['**/.git/**', '**/node_modules/**'],
52
- });
36
+ // Use fs.globSync to match files. Dotfiles and dot-directories are always included.
37
+ paths = globSync(opts.glob, { cwd: opts.cwd });
38
+
39
+ // Manually resolve to absolute paths if cwd is set
40
+ if (opts.cwd) {
41
+ paths = paths.map(p => resolve(opts.cwd as string, p));
42
+ }
53
43
  }
54
44
  if (opts.stat || opts.verbose) {
55
45
  console.time('Duration');
package/src/utils.ts ADDED
@@ -0,0 +1,8 @@
1
+ /** Helper to throw or callback with error */
2
+ export function throwOrCallback(err?: Error, cb?: (e?: Error) => void) {
3
+ if (typeof cb === 'function') {
4
+ cb(err);
5
+ } else {
6
+ throw err;
7
+ }
8
+ }