diff --git a/lib/report/error_dictionary.js b/lib/report/error_dictionary.js index 9cc997b..c64a46b 100644 --- a/lib/report/error_dictionary.js +++ b/lib/report/error_dictionary.js @@ -1,5 +1,6 @@ var fs = require('fs'), - chalk = require('chalk'); + chalk = require('chalk'), + _ = require('lodash'); module.exports = { onend: function(data) { @@ -17,6 +18,20 @@ module.exports = { }); } }); + + buffer = _.uniq(buffer).sort(function(a, b) { + a = a.toLowerCase(); + b = b.toLowerCase(); + + if(a > b) { + return 1; + } else if(a === b) { + return 0; + } else { + return -1; + } + }); + try { fs.writeFileSync(filename, JSON.stringify(buffer, null, ' ')); console.log(chalk.cyan('JSON dictionary with typos: ./' + filename));