@naturalcycles/nodejs-lib 12.93.1 → 12.93.2
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/bin/del.js +1 -1
- package/dist/fs/del.js +6 -4
- package/package.json +1 -1
- package/src/bin/del.ts +2 -2
- package/src/fs/del.ts +11 -4
package/dist/bin/del.js
CHANGED
package/dist/fs/del.js
CHANGED
|
@@ -43,7 +43,9 @@ async function del(_opt) {
|
|
|
43
43
|
}
|
|
44
44
|
if (dry)
|
|
45
45
|
return;
|
|
46
|
-
await (0, js_lib_1.pMap)(filenames, filepath => fsp.
|
|
46
|
+
await (0, js_lib_1.pMap)(filenames, filepath => fsp.rm(filepath, {
|
|
47
|
+
force: true,
|
|
48
|
+
}), { concurrency });
|
|
47
49
|
// 2. glob only dirs, expand, delete only empty!
|
|
48
50
|
let dirnames = await (0, index_1.globby)(patterns, {
|
|
49
51
|
dot: true,
|
|
@@ -60,7 +62,7 @@ async function del(_opt) {
|
|
|
60
62
|
for await (const dirpath of dirnamesSorted) {
|
|
61
63
|
if (await isEmptyDir(dirpath)) {
|
|
62
64
|
// console.log(`empty dir: ${dirpath}`)
|
|
63
|
-
await fsp.
|
|
65
|
+
await fsp.rm(dirpath, { force: true, recursive: true });
|
|
64
66
|
deletedDirs.push(dirpath);
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -98,7 +100,7 @@ function delSync(_opt) {
|
|
|
98
100
|
}
|
|
99
101
|
if (dry)
|
|
100
102
|
return;
|
|
101
|
-
filenames.forEach(filepath => fs.
|
|
103
|
+
filenames.forEach(filepath => fs.rmSync(filepath, { force: true }));
|
|
102
104
|
// 2. glob only dirs, expand, delete only empty!
|
|
103
105
|
let dirnames = index_1.globby.sync(patterns, {
|
|
104
106
|
dot: true,
|
|
@@ -113,7 +115,7 @@ function delSync(_opt) {
|
|
|
113
115
|
for (const dirpath of dirnamesSorted) {
|
|
114
116
|
if (isEmptyDirSync(dirpath)) {
|
|
115
117
|
// console.log(`empty dir: ${dirpath}`)
|
|
116
|
-
fs.
|
|
118
|
+
fs.rmSync(dirpath, { force: true, recursive: true });
|
|
117
119
|
deletedDirs.push(dirpath);
|
|
118
120
|
}
|
|
119
121
|
}
|
package/package.json
CHANGED
package/src/bin/del.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import * as yargs from 'yargs'
|
|
4
|
-
import {
|
|
4
|
+
import { delSync } from '../fs/del'
|
|
5
5
|
import { runScript } from '../script'
|
|
6
6
|
|
|
7
7
|
runScript(async () => {
|
|
@@ -23,5 +23,5 @@ runScript(async () => {
|
|
|
23
23
|
},
|
|
24
24
|
}).argv
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
delSync({ patterns: patterns as string[], ...opt })
|
|
27
27
|
})
|
package/src/fs/del.ts
CHANGED
|
@@ -71,7 +71,14 @@ export async function del(_opt: DelOptions | DelSingleOption): Promise<void> {
|
|
|
71
71
|
|
|
72
72
|
if (dry) return
|
|
73
73
|
|
|
74
|
-
await pMap(
|
|
74
|
+
await pMap(
|
|
75
|
+
filenames,
|
|
76
|
+
filepath =>
|
|
77
|
+
fsp.rm(filepath, {
|
|
78
|
+
force: true,
|
|
79
|
+
}),
|
|
80
|
+
{ concurrency },
|
|
81
|
+
)
|
|
75
82
|
|
|
76
83
|
// 2. glob only dirs, expand, delete only empty!
|
|
77
84
|
let dirnames = await globby(patterns, {
|
|
@@ -95,7 +102,7 @@ export async function del(_opt: DelOptions | DelSingleOption): Promise<void> {
|
|
|
95
102
|
for await (const dirpath of dirnamesSorted) {
|
|
96
103
|
if (await isEmptyDir(dirpath)) {
|
|
97
104
|
// console.log(`empty dir: ${dirpath}`)
|
|
98
|
-
await fsp.
|
|
105
|
+
await fsp.rm(dirpath, { force: true, recursive: true })
|
|
99
106
|
deletedDirs.push(dirpath)
|
|
100
107
|
}
|
|
101
108
|
}
|
|
@@ -145,7 +152,7 @@ export function delSync(_opt: DelOptions | DelSingleOption): void {
|
|
|
145
152
|
|
|
146
153
|
if (dry) return
|
|
147
154
|
|
|
148
|
-
filenames.forEach(filepath => fs.
|
|
155
|
+
filenames.forEach(filepath => fs.rmSync(filepath, { force: true }))
|
|
149
156
|
|
|
150
157
|
// 2. glob only dirs, expand, delete only empty!
|
|
151
158
|
let dirnames = globby.sync(patterns, {
|
|
@@ -167,7 +174,7 @@ export function delSync(_opt: DelOptions | DelSingleOption): void {
|
|
|
167
174
|
for (const dirpath of dirnamesSorted) {
|
|
168
175
|
if (isEmptyDirSync(dirpath)) {
|
|
169
176
|
// console.log(`empty dir: ${dirpath}`)
|
|
170
|
-
fs.
|
|
177
|
+
fs.rmSync(dirpath, { force: true, recursive: true })
|
|
171
178
|
deletedDirs.push(dirpath)
|
|
172
179
|
}
|
|
173
180
|
}
|