aboutsummaryrefslogtreecommitdiff
path: root/test/yomichan-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/yomichan-test.js')
-rw-r--r--test/yomichan-test.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/test/yomichan-test.js b/test/yomichan-test.js
index 3351ecdf..b4f5ac7c 100644
--- a/test/yomichan-test.js
+++ b/test/yomichan-test.js
@@ -38,12 +38,17 @@ function createTestDictionaryArchive(dictionary, dictionaryName) {
const archive = new (getJSZip())();
for (const fileName of fileNames) {
- const source = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: 'utf8'});
- const json = JSON.parse(source);
- if (fileName === 'index.json' && typeof dictionaryName === 'string') {
- json.title = dictionaryName;
+ if (/\.json$/.test(fileName)) {
+ const content = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: 'utf8'});
+ const json = JSON.parse(content);
+ if (fileName === 'index.json' && typeof dictionaryName === 'string') {
+ json.title = dictionaryName;
+ }
+ archive.file(fileName, JSON.stringify(json, null, 0));
+ } else {
+ const content = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: null});
+ archive.file(fileName, content);
}
- archive.file(fileName, JSON.stringify(json, null, 0));
}
return archive;