5etools-utils 0.1.13 → 0.1.16
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 +4 -4
- package/lib/UtilFs.js +18 -2
- package/package.json +1 -1
package/lib/TestJson.js
CHANGED
|
@@ -109,8 +109,8 @@ class JsonTester {
|
|
|
109
109
|
this._isSchemaLoaded = true;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
_doRunOnDir ({dir, errors, errorsFull, ...opts}) {
|
|
113
|
-
uf.listJsonFiles(dir,
|
|
112
|
+
_doRunOnDir ({dir, errors, errorsFull, ...opts} = {}) {
|
|
113
|
+
uf.listJsonFiles(dir, opts)
|
|
114
114
|
.forEach(filePath => {
|
|
115
115
|
um.info(this._tagLog, `\tValidating "${filePath}"...`);
|
|
116
116
|
|
|
@@ -127,7 +127,7 @@ class JsonTester {
|
|
|
127
127
|
* @param [opts]
|
|
128
128
|
* @param [opts.dirBlacklist]
|
|
129
129
|
*/
|
|
130
|
-
getErrors (dir, opts) {
|
|
130
|
+
getErrors (dir, opts = {}) {
|
|
131
131
|
um.info(this._tagLog, `Validating JSON against schema`);
|
|
132
132
|
|
|
133
133
|
this._doLoadSchema();
|
|
@@ -135,7 +135,7 @@ class JsonTester {
|
|
|
135
135
|
const errors = [];
|
|
136
136
|
const errorsFull = [];
|
|
137
137
|
|
|
138
|
-
this._doRunOnDir({errors, errorsFull, dir
|
|
138
|
+
this._doRunOnDir({...opts, errors, errorsFull, dir});
|
|
139
139
|
|
|
140
140
|
return {errors, errorsFull};
|
|
141
141
|
}
|
package/lib/UtilFs.js
CHANGED
|
@@ -48,12 +48,27 @@ function listJsonFiles (dir, opts) {
|
|
|
48
48
|
}, []);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
function _runOnDirs_getDirs () {
|
|
52
|
+
return fs.readdirSync(".", "utf8")
|
|
53
|
+
.filter(dir => isDirectory(dir) && !dir.startsWith(".") && !dir.startsWith("_") && dir !== "node_modules");
|
|
54
|
+
}
|
|
55
|
+
|
|
51
56
|
function runOnDirs (fn) {
|
|
52
|
-
|
|
53
|
-
.filter(dir => isDirectory(dir) && !dir.startsWith(".") && !dir.startsWith("_") && dir !== "node_modules")
|
|
57
|
+
_runOnDirs_getDirs()
|
|
54
58
|
.forEach(dir => fn(dir));
|
|
55
59
|
}
|
|
56
60
|
|
|
61
|
+
async function pRunOnDirs (pFn, {isSerial = false} = {}) {
|
|
62
|
+
const dirs = _runOnDirs_getDirs();
|
|
63
|
+
|
|
64
|
+
if (isSerial) {
|
|
65
|
+
for (const dir of dirs) await pFn(dir);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await Promise.allSettled(dirs.map(dir => pFn(dir)));
|
|
70
|
+
}
|
|
71
|
+
|
|
57
72
|
function mkDirs (pathToCreate) {
|
|
58
73
|
pathToCreate
|
|
59
74
|
.split(/[\\/]/g)
|
|
@@ -70,5 +85,6 @@ export {
|
|
|
70
85
|
readJSON,
|
|
71
86
|
listJsonFiles,
|
|
72
87
|
runOnDirs,
|
|
88
|
+
pRunOnDirs,
|
|
73
89
|
mkDirs,
|
|
74
90
|
};
|