Skip to content

Commit

Permalink
Merge pull request #26 from MarvNC:add-export-index-json
Browse files Browse the repository at this point in the history
Add Exporting of Index Json
  • Loading branch information
MarvNC authored Jul 24, 2024
2 parents a8055af + 454e0b2 commit 3232341
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/builders/dictionaryIndex.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'path';
import fs from 'fs';
import { DictionaryIndexType } from '../types/yomitan/dictionaryindex';

export class DictionaryIndex {
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 3232341

Please sign in to comment.