aboutsummaryrefslogtreecommitdiff
path: root/test/yomichan-test.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-14 13:48:50 -0400
committerGitHub <noreply@github.com>2020-03-14 13:48:50 -0400
commit1cacbb6202b823d318fabdc0ef5a498923d9c95a (patch)
tree74db749fa2b8e577d37de868a67a684908bb4be0 /test/yomichan-test.js
parentf7bbcb6df403ca565b6dcf3ab468967f830b527d (diff)
parentadbdca6a8bbb68ea046fe55b070cddb501ce40aa (diff)
Merge pull request #409 from toasted-nutbread/update-global-declaration-format
Update global declaration format
Diffstat (limited to 'test/yomichan-test.js')
-rw-r--r--test/yomichan-test.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/yomichan-test.js b/test/yomichan-test.js
index 0fc97b4b..5fa7730b 100644
--- a/test/yomichan-test.js
+++ b/test/yomichan-test.js
@@ -50,8 +50,29 @@ function createTestDictionaryArchive(dictionary, dictionaryName) {
return archive;
}
+function getAllFiles(baseDirectory, predicate=null) {
+ const results = [];
+ const directories = [path.resolve(baseDirectory)];
+ while (directories.length > 0) {
+ const directory = directories.shift();
+ for (const fileName of fs.readdirSync(directory)) {
+ const fullFileName = path.resolve(directory, fileName);
+ const stats = fs.statSync(fullFileName);
+ if (stats.isFile()) {
+ if (typeof predicate !== 'function' || predicate(fullFileName, directory, baseDirectory)) {
+ results.push(fullFileName);
+ }
+ } else if (stats.isDirectory()) {
+ directories.push(fullFileName);
+ }
+ }
+ }
+ return results;
+}
+
module.exports = {
createTestDictionaryArchive,
+ getAllFiles,
get JSZip() { return getJSZip(); }
};