rrdir 12.0.1 → 12.0.3

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/index.js +7 -3
  3. package/package.json +7 -18
package/README.md CHANGED
@@ -39,8 +39,8 @@ The directory to read, either absolute or relative. Pass a `Buffer` to switch th
39
39
 
40
40
  - `stats` *boolean*: Whether to include `entry.stats`. Will reduce performance. Default: `false`.
41
41
  - `followSymlinks` *boolean*: Whether to follow symlinks for both recursion and `stat` calls. Default: `false`.
42
- - `exclude` *Array*: Path globs to exclude, e.g. `["**/*.js"]`. Default: `undefined`.
43
- - `include` *Array*: Path globs to include, e.g. `["**/*.map"]`. Default: `undefined`.
42
+ - `exclude` *Array*: Path globs to exclude, e.g. `["**.js"]`. Default: `undefined`.
43
+ - `include` *Array*: Path globs to include, e.g. `["**.map"]`. Default: `undefined`.
44
44
  - `strict` *boolean*: Whether to throw immediately when reading an entry fails. Default: `false`.
45
45
  - `insensitive` *boolean*: Whether `include` and `exclude` match case-insensitively. Default: `false`.
46
46
 
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {readdir, stat, lstat} from "node:fs/promises";
2
2
  import {readdirSync, statSync, lstatSync} from "node:fs";
3
- import {sep} from "node:path";
3
+ import {sep, resolve} from "node:path";
4
4
  import picomatch from "picomatch";
5
5
 
6
6
  const sepBuffer = Buffer.from(sep);
@@ -36,9 +36,13 @@ function makeMatchers({include, exclude, insensitive}) {
36
36
  dot: true,
37
37
  flags: insensitive ? "i" : undefined,
38
38
  };
39
+
40
+ // resolve the path to an absolute one because picomatch can not deal properly
41
+ // with relative paths that start with ./ or .\
42
+ // https://github.com/micromatch/picomatch/issues/121
39
43
  return {
40
- includeMatcher: include?.length ? picomatch(include, opts) : null,
41
- excludeMatcher: exclude?.length ? picomatch(exclude, opts) : null,
44
+ includeMatcher: include?.length ? path => picomatch(include, opts)(resolve(path)) : null,
45
+ excludeMatcher: exclude?.length ? path => picomatch(exclude, opts)(resolve(path)) : null,
42
46
  };
43
47
  }
44
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rrdir",
3
- "version": "12.0.1",
3
+ "version": "12.0.3",
4
4
  "description": "Recursive directory reader with a delightful API",
5
5
  "author": "silverwind <me@silverwind.io>",
6
6
  "repository": "silverwind/rrdir",
@@ -12,27 +12,16 @@
12
12
  "node": ">=18"
13
13
  },
14
14
  "files": [
15
- "index.js"
15
+ "./index.js"
16
16
  ],
17
17
  "devDependencies": {
18
- "eslint": "8.47.0",
19
- "eslint-config-silverwind": "74.1.2",
20
- "updates": "14.3.5",
21
- "versions": "11.0.2",
22
- "vitest": "0.34.2",
18
+ "eslint": "8.52.0",
19
+ "eslint-config-silverwind": "79.0.4",
20
+ "updates": "15.0.3",
21
+ "versions": "12.0.0",
22
+ "vitest": "0.34.6",
23
23
  "vitest-config-silverwind": "3.0.0"
24
24
  },
25
- "keywords": [
26
- "recursive readdir",
27
- "readdir",
28
- "recursive",
29
- "walk",
30
- "walkdir",
31
- "directory",
32
- "crawl",
33
- "crawler",
34
- "scandir"
35
- ],
36
25
  "dependencies": {
37
26
  "picomatch": "2.3.1"
38
27
  }