5etools-utils 0.1.15 → 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/UtilFs.js +15 -8
- package/package.json +1 -1
package/lib/UtilFs.js
CHANGED
|
@@ -48,18 +48,25 @@ 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
|
|
|
57
|
-
async function pRunOnDirs (pFn) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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)));
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
function mkDirs (pathToCreate) {
|