diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-19 11:36:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 11:36:05 -0400 |
commit | a6344f635de2464465317b2ceeb6e19aef056848 (patch) | |
tree | 3c101c3dbf38dfb26bfb74bb0a38daedc8166811 /test/yomichan-test.js | |
parent | 3b2663ba0957c65be959ba18dc80e13625e28f02 (diff) | |
parent | 99c1a6a6bc0ce55eb2f20703a7f7f69c4bcefd9d (diff) |
Merge pull request #446 from toasted-nutbread/dictionary-images
Dictionary images
Diffstat (limited to 'test/yomichan-test.js')
-rw-r--r-- | test/yomichan-test.js | 15 |
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; |