diff --git a/scripts/build.js b/scripts/build.js index a738fcb..6150b83 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -11,6 +11,10 @@ const buildFolder = path.join(scriptDir, '..', "build"); const buildRawFolder = path.join(buildFolder, "raw"); const atlas = {} const files = fs.readdirSync(mapsFolder) +const isRule = (line) => { + return line.length < 10 && line.indexOf('=') > -1 +} +const isComment = (line) => !isRule(line) files.forEach((file) => { const filePath = path.join(mapsFolder, file); @@ -18,7 +22,8 @@ files.forEach((file) => { const fontName = path.parse(file).name; const fontMap = {}; data.split('\n').forEach(l => { - if (l.startsWith('#')) return; + l = l.trim(); + if (isComment(l)) return; const [lhs, rhs] = l.split('=').map(w => w.trim()); if (lhs) fontMap[lhs] = rhs; }) diff --git a/scripts/find-longest.js b/scripts/find-longest.js new file mode 100644 index 0000000..77cf4a4 --- /dev/null +++ b/scripts/find-longest.js @@ -0,0 +1,22 @@ +const fs = require('fs'); +const filename = process.argv[2]; +if (!filename) { + console.error("Please specify filename"); + process.exit(1); +} +const text = fs.readFileSync(filename, 'utf-8'); +const known = {} +let longest = "" +let longestLength = 0 +text + .split('\n') + .forEach(l => { + if (l.startsWith('#')) return; + if (l.length > longestLength) { + longest = l; + longestLength = l.length + } + }) + +console.log(longest) +console.log(longestLength) \ No newline at end of file