UNPKG

@dcoffey/espells

Version:

Pure JS/TS spellchecker, using Hunspell dictionaries. Based on Spylls.

23 lines 743 B
#!/usr/bin/env node import { Espells } from './index.js'; import { readFileSync } from 'fs'; import { join } from 'path'; function checkSpelling(word) { const aff = readFileSync(join(process.cwd(), 'en_GB.aff'), 'utf-8'); const dic = readFileSync(join(process.cwd(), 'en_GB.dic'), 'utf-8'); let spellChecker = new Espells({ aff, dic }); const result = spellChecker.lookup(word); console.log(result); console.log(result.correct ? 'correct' : 'incorrect'); } function main() { const args = process.argv.slice(2); if (args.length !== 1) { console.error('Usage: espells-cli [word]'); process.exit(1); } console.log(args); checkSpelling(args[0]); } main(); //# sourceMappingURL=cli.js.map