remove-glob 0.3.5 → 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.
- package/dist/cli.js +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -9
- package/package.json +3 -2
- package/src/cli.ts +2 -2
- package/src/index.ts +7 -8
package/dist/cli.js
CHANGED
|
@@ -26,9 +26,9 @@ try {
|
|
|
26
26
|
describe: 'Remove all items recursively',
|
|
27
27
|
examples: [
|
|
28
28
|
{ cmd: '$0 foo bar', describe: '→ Remove "foo" and "bar" folders' },
|
|
29
|
-
{ cmd: '$0 --glob
|
|
29
|
+
{ cmd: '$0 --glob="dist/**/*.js"', describe: '→ Remove all files from from "dist" folder with ".js" extension' },
|
|
30
30
|
{
|
|
31
|
-
cmd: '$0 --glob
|
|
31
|
+
cmd: '$0 --glob="dist/**/*.js" --glob="packages/*/tsconfig.tsbuildinfo"',
|
|
32
32
|
describe: '→ Remove all files from from "dist" folder with ".js" extension and "tsconfig.tsbuildinfo" file from every "packages" folders',
|
|
33
33
|
},
|
|
34
34
|
],
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,
|
|
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,
|
|
2
|
-
import {
|
|
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
|
|
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
|
|
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
|
-
|
|
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.
|
|
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/cli.ts
CHANGED
|
@@ -30,9 +30,9 @@ try {
|
|
|
30
30
|
describe: 'Remove all items recursively',
|
|
31
31
|
examples: [
|
|
32
32
|
{ cmd: '$0 foo bar', describe: '→ Remove "foo" and "bar" folders' },
|
|
33
|
-
{ cmd: '$0 --glob
|
|
33
|
+
{ cmd: '$0 --glob="dist/**/*.js"', describe: '→ Remove all files from from "dist" folder with ".js" extension' },
|
|
34
34
|
{
|
|
35
|
-
cmd: '$0 --glob
|
|
35
|
+
cmd: '$0 --glob="dist/**/*.js" --glob="packages/*/tsconfig.tsbuildinfo"',
|
|
36
36
|
describe:
|
|
37
37
|
'→ Remove all files from from "dist" folder with ".js" extension and "tsconfig.tsbuildinfo" file from every "packages" folders',
|
|
38
38
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { existsSync,
|
|
2
|
-
import {
|
|
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
|
|
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
|
|
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
|
-
|
|
92
|
+
typeof cb === 'function' && cb();
|
|
94
93
|
return pathExists;
|
|
95
94
|
}
|