rrdir 9.0.1 → 10.0.0
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/README.md +1 -1
- package/index.js +14 -7
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# rrdir
|
|
2
|
-
[](https://www.npmjs.org/package/rrdir) [](https://www.npmjs.org/package/rrdir)
|
|
2
|
+
[](https://www.npmjs.org/package/rrdir) [](https://www.npmjs.org/package/rrdir) [](https://bundlephobia.com/package/rrdir)
|
|
3
3
|
|
|
4
4
|
> Recursive directory reader with a delightful API
|
|
5
5
|
|
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {readdir, stat, lstat} from "fs/promises";
|
|
2
2
|
import {readdirSync, statSync, lstatSync} from "fs";
|
|
3
3
|
import {sep} from "path";
|
|
4
|
-
import picomatch from "picomatch";
|
|
5
4
|
|
|
6
5
|
const sepBuffer = Buffer.from(sep);
|
|
7
6
|
|
|
@@ -11,9 +10,6 @@ const defaults = {
|
|
|
11
10
|
followSymlinks: false,
|
|
12
11
|
exclude: undefined,
|
|
13
12
|
include: undefined,
|
|
14
|
-
match: {
|
|
15
|
-
dot: true,
|
|
16
|
-
},
|
|
17
13
|
};
|
|
18
14
|
|
|
19
15
|
function makePath(entry, dir, encoding) {
|
|
@@ -33,10 +29,21 @@ function build(dirent, path, stats, opts) {
|
|
|
33
29
|
};
|
|
34
30
|
}
|
|
35
31
|
|
|
36
|
-
function
|
|
32
|
+
function makeMatcher(filters) {
|
|
33
|
+
return str => {
|
|
34
|
+
for (const filter of filters) {
|
|
35
|
+
const re = new RegExp(`${filter.replace(/\*+/g, ".*").replace(/\/\.\*/, ".*")}$`);
|
|
36
|
+
const matches = re.test(str);
|
|
37
|
+
if (matches) return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function makeMatchers({include, exclude}) {
|
|
37
44
|
return {
|
|
38
|
-
includeMatcher: include ?
|
|
39
|
-
excludeMatcher: exclude ?
|
|
45
|
+
includeMatcher: include ? makeMatcher(include) : null,
|
|
46
|
+
excludeMatcher: exclude ? makeMatcher(exclude) : null,
|
|
40
47
|
};
|
|
41
48
|
}
|
|
42
49
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrdir",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Recursive directory reader with a delightful API",
|
|
5
5
|
"author": "silverwind <me@silverwind.io>",
|
|
6
6
|
"repository": "silverwind/rrdir",
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"files": [
|
|
15
15
|
"index.js"
|
|
16
16
|
],
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"picomatch": "^2.3.1"
|
|
19
|
-
},
|
|
20
17
|
"devDependencies": {
|
|
21
18
|
"eslint": "8.23.1",
|
|
22
19
|
"eslint-config-silverwind": "54.0.2",
|