5etools-utils 0.1.18 → 0.1.19

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 (2) hide show
  1. package/lib/UtilFs.js +3 -1
  2. package/package.json +1 -1
package/lib/UtilFs.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as fs from "fs";
2
+ import * as path from "path";
2
3
 
3
4
  function isDirectory (path) {
4
5
  return fs.lstatSync(path).isDirectory();
@@ -35,12 +36,13 @@ function readJSON (path, {isIncludeRaw = false} = {}) {
35
36
  */
36
37
  function listJsonFiles (dir, opts) {
37
38
  const {dirBlacklist = null} = opts || {};
39
+ const dirBlacklist_ = dirBlacklist ? new Set(dirBlacklist.map(it => path.normalize(it))) : new Set();
38
40
 
39
41
  const dirContent = fs.readdirSync(dir, "utf8")
40
42
  .map(file => dir === "." ? file : `${dir}/${file}`);
41
43
  return dirContent.reduce((acc, file) => {
42
44
  if (isDirectory(file)) {
43
- if (dirBlacklist == null || !dirBlacklist.has(file)) acc.push(...listJsonFiles(file, opts));
45
+ if (!dirBlacklist_.has(path.normalize(file))) acc.push(...listJsonFiles(file, opts));
44
46
  } else {
45
47
  if (file.toLowerCase().endsWith(".json")) acc.push(file);
46
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",