From 483bc14572df828ff6ee482fe803325b67c98276 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Sat, 28 Jul 2018 23:11:00 +0200 Subject: [PATCH] feat$(glossary): Add keymaker script --- scripts/glossary/keyword.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/glossary/keyword.js diff --git a/scripts/glossary/keyword.js b/scripts/glossary/keyword.js new file mode 100644 index 000000000..45c5ef224 --- /dev/null +++ b/scripts/glossary/keyword.js @@ -0,0 +1,20 @@ +/* + This is the "keymaker" script that generates the glossary/keyword_database file. + Run using `npm run glossary:keymaker`. +*/ + +const fs = require('fs-extra'); +const util = require('../util'); + +const glossaryFiles = util.getFilesInDir('./glossary', false); + +try { + const output = glossaryFiles.reduce( + (accumulator, currentFilename) => + accumulator.toLowerCase().replace(/\.[^/.]+$/, "") + "\n" + + currentFilename.toLowerCase().replace(/\.[^/.]+$/, "")); + fs.writeFileSync('glossary/keyword_database', output); +} catch (err) { + console.log(`${chalk.red('ERROR!')} During glossary keyword_database generation: ${err}`); + process.exit(1); +} \ No newline at end of file