Skip to content

Commit

Permalink
Merge pull request #24 from MarvNC:set-revision-package-version
Browse files Browse the repository at this point in the history
Set Revision to Use Project Version
  • Loading branch information
MarvNC authored Jan 22, 2024
2 parents 5f7c068 + abf93e2 commit f9fde25
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

0 comments on commit f9fde25

Please sign in to comment.