-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.js
32 lines (29 loc) · 1.01 KB
/
build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ISC via https://github.com/npm/npm-expansions/blob/5322c9dd9716927622fffa89e8756931faa11d9c/bin/build.js
var fs = require('fs')
var path = require('path')
var inpath = path.resolve('./node_modules/word-o-mat/word-o-mat.roboFontExt/resources')
fs.readdir(inpath, function (err, files) {
if (err) {
console.error(err)
} else {
files.forEach(function (file) {
// console.log(file)
convert(file)
})
}
})
var convert = function (infile) {
var filename = infile.split(path.extname(infile))[0] + '.json'
var outfile = path.resolve('./lib/resources/', filename)
var list = fs
.readFileSync(path.resolve(inpath, infile), 'utf8')
.split('*****')[1]
.split('\n')
.map(function (e) { return e.trim() })
.filter(function (e) { return (e.length > 0) })
// .filter(function (e) { return e.charAt(0).toLowerCase() === 'n' })
.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase())
})
fs.writeFileSync(outfile, JSON.stringify(list, null, 2))
}