rrdir 11.0.0 → 11.0.1
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 +12 -11
- package/package.json +5 -5
package/index.js
CHANGED
|
@@ -30,22 +30,20 @@ function build(dirent, path, stats, opts) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export function pathGlobToRegex(glob, {flags = undefined
|
|
34
|
-
if (sep === "\\") sep = "\\\\";
|
|
33
|
+
export function pathGlobToRegex(glob, {flags = undefined} = {flags: undefined}) {
|
|
35
34
|
return new RegExp(`${glob
|
|
36
35
|
.replace(/[|\\{}()[\]^$+.-]/g, "\\$&")
|
|
37
|
-
.replace(
|
|
38
|
-
.replace(
|
|
39
|
-
.replace(
|
|
40
|
-
.replace(
|
|
41
|
-
.replace(/([^.])\*/g, (_, p1) => `${p1}[^${sep}]*`)
|
|
36
|
+
.replace(/\*\*\/\*/, ".*")
|
|
37
|
+
.replace(/\*\*/g, ".*")
|
|
38
|
+
.replace(/\//g, "[/\\\\]")
|
|
39
|
+
.replace(/([^.])\*/g, (_, p1) => `${p1}[^/\\\\]*`)
|
|
42
40
|
.replaceAll("**", "*")
|
|
43
41
|
.replaceAll("?", ".")
|
|
44
42
|
}$`, flags);
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
function makeMatcher(filters, flags) {
|
|
48
|
-
const regexes = filters.map(filter => pathGlobToRegex(filter, {flags
|
|
46
|
+
const regexes = filters.map(filter => pathGlobToRegex(filter, {flags}));
|
|
49
47
|
return str => {
|
|
50
48
|
for (const regex of regexes) {
|
|
51
49
|
if (regex.test(str)) return true;
|
|
@@ -84,7 +82,8 @@ export async function* rrdir(dir, opts = {}, {includeMatcher, excludeMatcher, en
|
|
|
84
82
|
if (excludeMatcher?.(encoding === "buffer" ? String(path) : path)) continue;
|
|
85
83
|
|
|
86
84
|
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink();
|
|
87
|
-
const
|
|
85
|
+
const encodedPath = encoding === "buffer" ? String(path) : path;
|
|
86
|
+
const isIncluded = !includeMatcher || includeMatcher(encodedPath);
|
|
88
87
|
let stats;
|
|
89
88
|
|
|
90
89
|
if (isIncluded) {
|
|
@@ -135,7 +134,8 @@ export async function rrdirAsync(dir, opts = {}, {includeMatcher, excludeMatcher
|
|
|
135
134
|
if (excludeMatcher?.(encoding === "buffer" ? String(path) : path)) return;
|
|
136
135
|
|
|
137
136
|
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink();
|
|
138
|
-
const
|
|
137
|
+
const encodedPath = encoding === "buffer" ? String(path) : path;
|
|
138
|
+
const isIncluded = !includeMatcher || includeMatcher(encodedPath);
|
|
139
139
|
let stats;
|
|
140
140
|
|
|
141
141
|
if (isIncluded) {
|
|
@@ -188,7 +188,8 @@ export function rrdirSync(dir, opts = {}, {includeMatcher, excludeMatcher, encod
|
|
|
188
188
|
if (excludeMatcher?.(encoding === "buffer" ? String(path) : path)) continue;
|
|
189
189
|
|
|
190
190
|
const isSymbolicLink = opts.followSymlinks && dirent.isSymbolicLink();
|
|
191
|
-
const
|
|
191
|
+
const encodedPath = encoding === "buffer" ? String(path) : path;
|
|
192
|
+
const isIncluded = !includeMatcher || includeMatcher(encodedPath);
|
|
192
193
|
let stats;
|
|
193
194
|
|
|
194
195
|
if (isIncluded) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrdir",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.1",
|
|
4
4
|
"description": "Recursive directory reader with a delightful API",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/rrdir",
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
"index.js"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"eslint": "8.
|
|
19
|
-
"eslint-config-silverwind": "
|
|
20
|
-
"updates": "
|
|
21
|
-
"versions": "
|
|
18
|
+
"eslint": "8.39.0",
|
|
19
|
+
"eslint-config-silverwind": "67.0.1",
|
|
20
|
+
"updates": "14.1.0",
|
|
21
|
+
"versions": "11.0.0",
|
|
22
22
|
"vitest": "0.30.1"
|
|
23
23
|
},
|
|
24
24
|
"keywords": [
|