From abf93e2ef47c36cae3608beb385b170b1a42da19 Mon Sep 17 00:00:00 2001 From: MarvNC Date: Mon, 22 Jan 2024 12:33:40 -0800 Subject: [PATCH] Update setRevision() to use getVersion() --- src/convert.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/convert.js b/src/convert.js index a21ecc9..bb61ff2 100644 --- a/src/convert.js +++ b/src/convert.js @@ -35,7 +35,7 @@ const exportDirectory = './dist'; Converted using https://github.com/MarvNC/yomichan-dict-builder` ) .setTitle(`Words.hk 粵典 [${dateString}]`) - .setRevision(`wordshk-${dateString}`); + .setRevision(`${getVersion()}`); await dictionary.setIndex(dictionaryIndex.build()); for (const entry of dictionaryEntries) { @@ -51,3 +51,13 @@ const exportDirectory = './dist'; await dictionary.export(exportDirectory); console.log(`Exported dictionary to ${exportDirectory}.`); })(); + +/** + * Get the version from the package.json file. + * @returns {string} The version. + */ +function getVersion() { + const packageJsonPath = path.join(process.cwd(), 'package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + return packageJson.version; +}