UNPKG

910 BJavaScriptView Raw
1var fs = require("fs")
2var infile = __dirname + '/expansions.txt'
3var outfile_pre = __dirname + '/expansions'
4var outfile_json = outfile_pre + '.json'
5var outfile_txt = outfile_pre + '.txt'
6
7var list = fs
8 .readFileSync(infile, 'utf8')
9 .split("\n")
10 .map(function(e) { return e.trim() })
11 .filter(function(e) { return (e.length > 0) })
12 .filter(function(e) { return e.charAt(0).toLowerCase() === "n" })
13 .sort(function (a, b) {
14 return a.toLowerCase().localeCompare(b.toLowerCase());
15 })
16
17fs.writeFileSync(outfile_json, JSON.stringify(list, null, 2))
18
19fs.writeFileSync(outfile_txt, list.reduce(
20 function(p, c){
21 return p + c + '\n'
22 }, list.shift() + '\n')
23)
24// reappend the instructions
25fs.appendFileSync(
26 outfile_txt,
27 "#\n" +
28 "# please don't add your expansions down here!\n" +
29 "# insert them in alphabetical order to help reduce merge conflicts.\n" +
30 "#\n" +
31 "# <3\n"
32)
\No newline at end of file