diff --git a/src/builders/dictionaryIndex.ts b/src/builders/dictionaryIndex.ts index 191a08a..d703d16 100644 --- a/src/builders/dictionaryIndex.ts +++ b/src/builders/dictionaryIndex.ts @@ -1,3 +1,5 @@ +import path from 'path'; +import fs from 'fs'; import { DictionaryIndexType } from '../types/yomitan/dictionaryindex'; export class DictionaryIndex { @@ -69,4 +71,12 @@ export class DictionaryIndex { return this.index; } + /** + * Exports the dictionary index to a JSON file (useful for auto updating dictionaries) + * @param directory - The directory to export the dictionary to + */ + async export(directory: string = './', fileName: string = 'index.json') { + const saveFullPath = path.join(directory, fileName); + fs.writeFileSync(saveFullPath, JSON.stringify(this.index)); + } }