diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-27 07:14:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-27 12:14:20 +0000 |
commit | c4fea2251606fb0b3d0d761a544dac578f3d9048 (patch) | |
tree | 3dbd85877f0d7b3d9de78ace7809e809a7a212d4 /dev/util.js | |
parent | 2e9ea19207a7410f929bb908759d48cb2340f29c (diff) |
Update to zip.js for tests (#698)
* Use zip.js
* Set compression level to 0
* Update comments
Diffstat (limited to 'dev/util.js')
-rw-r--r-- | dev/util.js | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/dev/util.js b/dev/util.js index 5a4c5788..67d8d9d8 100644 --- a/dev/util.js +++ b/dev/util.js @@ -17,9 +17,7 @@ */ import fs from 'fs'; -import JSZip from 'jszip'; import path from 'path'; -import {parseJson} from './json.js'; /** * @param {string} baseDirectory @@ -47,48 +45,3 @@ export function getAllFiles(baseDirectory, predicate = null) { } return results; } - -/** - * Creates a zip archive from the given dictionary directory. - * @param {string} dictionaryDirectory - * @param {string} [dictionaryName] - * @returns {import('jszip')} - */ -export function createDictionaryArchive(dictionaryDirectory, dictionaryName) { - const fileNames = fs.readdirSync(dictionaryDirectory); - - // Const zipFileWriter = new BlobWriter(); - // const zipWriter = new ZipWriter(zipFileWriter); - const archive = new JSZip(); - - for (const fileName of fileNames) { - if (/\.json$/.test(fileName)) { - const content = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: 'utf8'}); - const json = parseJson(content); - if (fileName === 'index.json' && typeof dictionaryName === 'string') { - /** @type {import('dictionary-data').Index} */ (json).title = dictionaryName; - } - archive.file(fileName, JSON.stringify(json, null, 0)); - - // Await zipWriter.add(fileName, new TextReader(JSON.stringify(json, null, 0))); - } else { - const content = fs.readFileSync(path.join(dictionaryDirectory, fileName), {encoding: null}); - archive.file(fileName, content); - - // console.log('adding'); - // const r = new TextReader(content); - // console.log(r.readUint8Array(0, 10)); - // console.log('reader done'); - // await zipWriter.add(fileName, r); - // console.log('??'); - } - } - // Await zipWriter.close(); - - // Retrieves the Blob object containing the zip content into `zipFileBlob`. It - // is also returned by zipWriter.close() for more convenience. - // const zipFileBlob = await zipFileWriter.getData(); - return archive; - - // Return zipFileBlob; -} |