summaryrefslogtreecommitdiff
path: root/dev/util.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-20 00:47:15 -0500
committerGitHub <noreply@github.com>2023-12-20 05:47:15 +0000
commit8b943cc97fab890085448122e7c13dd035d0e238 (patch)
treea7a749a44771c6a82b1b72bb35cc0c81d57ddb54 /dev/util.js
parentb13fbd47941fc20cf623871396e34a6dfe9b4dba (diff)
JSON validation (#394)
* Set up JSON testing * Add schema validation * Use parseJson * Finish types * Disambiguate ext/json-schema from node dependency with the same name * Add support for specifying the jsconfig file * Don't expose types * Update types * Use dictionary map type * Fix types * Fix AJV warnings * Move types * Move anb rename file * Move common mocks * Simplify types
Diffstat (limited to 'dev/util.js')
-rw-r--r--dev/util.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/dev/util.js b/dev/util.js
index 6a7fa8f5..542ad6a2 100644
--- a/dev/util.js
+++ b/dev/util.js
@@ -72,7 +72,7 @@ export function getArgs(args, argMap) {
/**
* @param {string} baseDirectory
- * @param {?(fileName: string) => boolean} predicate
+ * @param {?(fileName: string, isDirectory: boolean) => boolean} predicate
* @returns {string[]}
*/
export function getAllFiles(baseDirectory, predicate = null) {
@@ -86,11 +86,13 @@ export function getAllFiles(baseDirectory, predicate = null) {
const relativeFileName = path.relative(baseDirectory, fullFileName);
const stats = fs.lstatSync(fullFileName);
if (stats.isFile()) {
- if (typeof predicate !== 'function' || predicate(relativeFileName)) {
+ if (typeof predicate !== 'function' || predicate(relativeFileName, false)) {
results.push(relativeFileName);
}
} else if (stats.isDirectory()) {
- directories.push(fullFileName);
+ if (typeof predicate !== 'function' || predicate(relativeFileName, true)) {
+ directories.push(fullFileName);
+ }
}
}
}