diff --git a/src/convertWikipedia.js b/src/convertWikipedia.js index 79d7c71..d1922eb 100644 --- a/src/convertWikipedia.js +++ b/src/convertWikipedia.js @@ -6,14 +6,16 @@ import { Dictionary, TermEntry } from 'yomichan-dict-builder'; import { parseLine } from './parseLine.js'; import { languagesAllowed } from './constants.js'; -import { version } from '../package.json'; - const linkCharacter = '⧉'; -const outputZipName = (lang) => `${lang} Wikipedia (v${version}).zip`; +const outputZipName = (lang, version) => `${lang} Wikipedia (v${version}).zip`; const shortAbstractFile = (lang) => `short-abstracts_lang=${lang.toLowerCase()}.ttl`; (async () => { + const version = await getVersion(); + + console.log(`Using version ${version}`); + const { lang, date } = readArgs(); console.log(`Converting ${lang} Wikipedia dump from ${date}...`); @@ -179,3 +181,9 @@ function readArgs() { } return { lang, date: dateInput }; } + +function getVersion() { + const packageJsonPath = path.join(process.cwd(), 'package.json'); + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + return packageJson.version; +}