Permalink
Browse files

Enforce lint results order

  • Loading branch information...
1 parent 71cdeb9 commit f331ad89bc5f4d25c4faae4d5028d2c84391f111 @davglass davglass committed Oct 2, 2012
Showing with 25 additions and 7 deletions.
  1. +25 −7 lib/cmds/lint.js
View
@@ -28,10 +28,10 @@ mods = {
var files = fs.readdirSync(path.join(this.dir, 'js')),
metaFiles, lintFiles = [],
metaFilesDir = path.join(this.dir, 'meta'),
- dir = this.dir, results = [],
+ dir = this.dir,
self = this, stack = new util.Stack(),
options = lint[this.options.parsed.lint];
-
+
if (util.exists(metaFilesDir)) {
metaFiles = fs.readdirSync(metaFilesDir);
}
@@ -47,24 +47,42 @@ mods = {
lintFiles.push(path.join(dir, 'js', file));
}
});
-
+
lintFiles.forEach(function(file) {
self._lint(options, file, stack.add(function(res) {
- results.push({
+ var out = {
file: file,
results: res
- });
+ };
+ return out;
}));
});
stack.done(function() {
log.info('lint complete');
- self.print(results);
+ self.print(stack.results);
});
-
+
+ },
+ fileSort: function(a, b) {
+ if (!a.file || !b.file) {
+ return 0;
+ }
+ var an = a.file.toLowerCase(),
+ bn = b.file.toLowerCase(),
+ ret = 0;
+
+ if (an < bn) {
+ ret = -1;
+ }
+ if (an > bn) {
+ ret = 1;
+ }
+ return ret;
},
print: function(errors) {
var count = 0;
+ errors.sort(this.fileSort);
errors.forEach(function(item) {
if (!item.results) {
log.info(item.file + ' is OK');

0 comments on commit f331ad8

Please sign in to comment.