rrdir 10.0.1 → 10.0.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/index.js +9 -21
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -56,21 +56,17 @@ export async function* rrdir(dir, opts = {}, {includeMatcher, excludeMatcher, en
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
let dirents = [];
|
|
59
|
-
|
|
60
59
|
try {
|
|
61
60
|
dirents = await readdir(dir, {encoding, withFileTypes: true});
|
|
62
61
|
} catch (err) {
|
|
63
|
-
if (opts.strict)
|
|
64
|
-
|
|
65
|
-
} else {
|
|
66
|
-
yield {path: dir, err};
|
|
67
|
-
}
|
|
62
|
+
if (opts.strict) throw err;
|
|
63
|
+
yield {path: dir, err};
|
|
68
64
|
}
|
|
69
65
|
if (!dirents.length) return;
|
|
70
66
|
|
|
71
67
|
for (const dirent of dirents) {
|
|
72
68
|
const path = makePath(dirent, dir, encoding);
|
|
73
|
-
if (excludeMatcher
|
|
69
|
+
if (excludeMatcher?.(encoding === "buffer" ? String(path) : path)) continue;
|
|
74
70
|
|
|
75
71
|
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink();
|
|
76
72
|
const isIncluded = !includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path);
|
|
@@ -111,21 +107,17 @@ export async function rrdirAsync(dir, opts = {}, {includeMatcher, excludeMatcher
|
|
|
111
107
|
|
|
112
108
|
const results = [];
|
|
113
109
|
let dirents = [];
|
|
114
|
-
|
|
115
110
|
try {
|
|
116
111
|
dirents = await readdir(dir, {encoding, withFileTypes: true});
|
|
117
112
|
} catch (err) {
|
|
118
|
-
if (opts.strict)
|
|
119
|
-
|
|
120
|
-
} else {
|
|
121
|
-
results.push({path: dir, err});
|
|
122
|
-
}
|
|
113
|
+
if (opts.strict) throw err;
|
|
114
|
+
results.push({path: dir, err});
|
|
123
115
|
}
|
|
124
116
|
if (!dirents.length) return results;
|
|
125
117
|
|
|
126
118
|
await Promise.all(dirents.map(async dirent => {
|
|
127
119
|
const path = makePath(dirent, dir, encoding);
|
|
128
|
-
if (excludeMatcher
|
|
120
|
+
if (excludeMatcher?.(encoding === "buffer" ? String(path) : path)) return;
|
|
129
121
|
|
|
130
122
|
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink();
|
|
131
123
|
const isIncluded = !includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path);
|
|
@@ -168,21 +160,17 @@ export function rrdirSync(dir, opts = {}, {includeMatcher, excludeMatcher, encod
|
|
|
168
160
|
|
|
169
161
|
const results = [];
|
|
170
162
|
let dirents = [];
|
|
171
|
-
|
|
172
163
|
try {
|
|
173
164
|
dirents = readdirSync(dir, {encoding, withFileTypes: true});
|
|
174
165
|
} catch (err) {
|
|
175
|
-
if (opts.strict)
|
|
176
|
-
|
|
177
|
-
} else {
|
|
178
|
-
results.push({path: dir, err});
|
|
179
|
-
}
|
|
166
|
+
if (opts.strict) throw err;
|
|
167
|
+
results.push({path: dir, err});
|
|
180
168
|
}
|
|
181
169
|
if (!dirents.length) return results;
|
|
182
170
|
|
|
183
171
|
for (const dirent of dirents) {
|
|
184
172
|
const path = makePath(dirent, dir, encoding);
|
|
185
|
-
if (excludeMatcher
|
|
173
|
+
if (excludeMatcher?.(encoding === "buffer" ? String(path) : path)) continue;
|
|
186
174
|
|
|
187
175
|
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink();
|
|
188
176
|
const isIncluded = !includeMatcher || includeMatcher(encoding === "buffer" ? String(path) : path);
|