remove-glob 0.3.6 → 0.3.7

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.
@@ -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,qBA0ElF"}
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,qBAyElF"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { existsSync, readdirSync, rmSync, statSync, unlinkSync } from 'node:fs';
2
- import { join, resolve } from 'node:path';
1
+ import { existsSync, rmSync, statSync, unlinkSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
3
  import { globSync } from 'tinyglobby';
4
4
  /** Helper to throw or callback with error */
5
5
  function throwOrCallback(err, cb) {
@@ -23,7 +23,7 @@ export function removeSync(opts = {}, callback) {
23
23
  return;
24
24
  }
25
25
  if (paths.length && opts.glob) {
26
- throwOrCallback(new Error('Providing both `--paths` and `--glob` pattern are not supported, you must provide only one of these options.'), cb);
26
+ throwOrCallback(new Error('Providing both `--paths` and `--glob` pattern at the same time is not supported, you must chose only one.'), cb);
27
27
  return;
28
28
  }
29
29
  let pathExists = false;
@@ -40,7 +40,9 @@ export function removeSync(opts = {}, callback) {
40
40
  ignore: ['**/.git/**', '**/node_modules/**'],
41
41
  });
42
42
  }
43
- opts.stat && console.time('Duration');
43
+ if (opts.stat || opts.verbose) {
44
+ console.time('Duration');
45
+ }
44
46
  opts.dryRun && console.log('=== dry-run ===');
45
47
  paths.forEach(path => {
46
48
  // do we need to resolve file/dir from a different cwd?
@@ -55,9 +57,6 @@ export function removeSync(opts = {}, callback) {
55
57
  }
56
58
  else {
57
59
  opts.verbose && console.log(`removing directory: ${path}`);
58
- readdirSync(path).forEach(name => {
59
- removeSync({ paths: join(path, name) }); // recursively remove content
60
- });
61
60
  rmSync(path, { recursive: true, force: true, maxRetries: process.platform === 'win32' ? 10 : 0 });
62
61
  }
63
62
  }
@@ -79,7 +78,6 @@ export function removeSync(opts = {}, callback) {
79
78
  console.timeEnd('Duration');
80
79
  }
81
80
  opts.dryRun && console.log('=== dry-run ===');
82
- if (typeof cb === 'function')
83
- cb();
81
+ typeof cb === 'function' && cb();
84
82
  return pathExists;
85
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remove-glob",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "A tiny utility to remove items or directories recursively, also supports glob",
5
5
  "bin": {
6
6
  "remove": "dist/cli.js"
@@ -17,7 +17,8 @@
17
17
  },
18
18
  "module": "./dist/index.js",
19
19
  "publishConfig": {
20
- "access": "public"
20
+ "access": "public",
21
+ "registry": "https://registry.npmjs.org/"
21
22
  },
22
23
  "files": [
23
24
  "/dist",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { existsSync, readdirSync, rmSync, statSync, unlinkSync } from 'node:fs';
2
- import { join, resolve } from 'node:path';
1
+ import { existsSync, rmSync, statSync, unlinkSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
3
  import { globSync } from 'tinyglobby';
4
4
 
5
5
  import type { RemoveOptions } from './interfaces.js';
@@ -32,7 +32,7 @@ export function removeSync(opts: RemoveOptions = {}, callback?: (e?: Error) => v
32
32
  }
33
33
  if (paths.length && opts.glob) {
34
34
  throwOrCallback(
35
- new Error('Providing both `--paths` and `--glob` pattern are not supported, you must provide only one of these options.'),
35
+ new Error('Providing both `--paths` and `--glob` pattern at the same time is not supported, you must chose only one.'),
36
36
  cb,
37
37
  );
38
38
  return;
@@ -51,7 +51,9 @@ export function removeSync(opts: RemoveOptions = {}, callback?: (e?: Error) => v
51
51
  ignore: ['**/.git/**', '**/node_modules/**'],
52
52
  });
53
53
  }
54
- opts.stat && console.time('Duration');
54
+ if (opts.stat || opts.verbose) {
55
+ console.time('Duration');
56
+ }
55
57
  opts.dryRun && console.log('=== dry-run ===');
56
58
 
57
59
  paths.forEach(path => {
@@ -67,9 +69,6 @@ export function removeSync(opts: RemoveOptions = {}, callback?: (e?: Error) => v
67
69
  console.log(`would remove directory: ${path}`);
68
70
  } else {
69
71
  opts.verbose && console.log(`removing directory: ${path}`);
70
- readdirSync(path).forEach(name => {
71
- removeSync({ paths: join(path, name) }); // recursively remove content
72
- });
73
72
  rmSync(path, { recursive: true, force: true, maxRetries: process.platform === 'win32' ? 10 : 0 });
74
73
  }
75
74
  } else {
@@ -90,6 +89,6 @@ export function removeSync(opts: RemoveOptions = {}, callback?: (e?: Error) => v
90
89
  console.timeEnd('Duration');
91
90
  }
92
91
  opts.dryRun && console.log('=== dry-run ===');
93
- if (typeof cb === 'function') cb();
92
+ typeof cb === 'function' && cb();
94
93
  return pathExists;
95
94
  }