From fd570b173a81c56dc6efdfc25fafc57cd4f862ef Mon Sep 17 00:00:00 2001 From: seles Date: Thu, 9 Apr 2015 12:58:11 +0300 Subject: [PATCH] Sort errors --- lib/report/error_dictionary.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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));