5etools-utils 0.1.17 → 0.1.20

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/lib/TestJson.js CHANGED
@@ -117,8 +117,10 @@ class JsonTester {
117
117
  this._addImplicits(data);
118
118
  const valid = this._ajv.validate(this._fnGetSchemaId(filePath), data);
119
119
 
120
- if (!valid) this._handleError({filePath, errors, errorsFull, data});
121
- if (isFailFast) break;
120
+ if (!valid) {
121
+ this._handleError({filePath, errors, errorsFull, data});
122
+ if (isFailFast) break;
123
+ }
122
124
  }
123
125
  }
124
126
 
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();
@@ -32,15 +33,18 @@ function readJSON (path, {isIncludeRaw = false} = {}) {
32
33
  * @param dir
33
34
  * @param [opts]
34
35
  * @param [opts.dirBlacklist]
36
+ * @param [state]
35
37
  */
36
- function listJsonFiles (dir, opts) {
38
+ function listJsonFiles (dir, opts, state) {
37
39
  const {dirBlacklist = null} = opts || {};
40
+ state = state || {};
41
+ state.dirBlacklist = state.dirBlacklist ? new Set([...dirBlacklist].map(it => path.normalize(it))) : new Set();
38
42
 
39
43
  const dirContent = fs.readdirSync(dir, "utf8")
40
44
  .map(file => dir === "." ? file : `${dir}/${file}`);
41
45
  return dirContent.reduce((acc, file) => {
42
46
  if (isDirectory(file)) {
43
- if (dirBlacklist == null || !dirBlacklist.has(file)) acc.push(...listJsonFiles(file, opts));
47
+ if (!state.dirBlacklist.has(path.normalize(file))) acc.push(...listJsonFiles(file, opts, state));
44
48
  } else {
45
49
  if (file.toLowerCase().endsWith(".json")) acc.push(file);
46
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "5etools-utils",
3
- "version": "0.1.17",
3
+ "version": "0.1.20",
4
4
  "description": "Shared utilities for the 5etools ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/Api.js",