Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Internal: Checker - return correct arguments for excluded files
Browse files Browse the repository at this point in the history
Fixes #1816
Closes gh-1817
  • Loading branch information
markelog authored and hzoo committed Sep 29, 2015
1 parent 4132219 commit f12830a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/checker.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ Checker.prototype._processPath = function(path, fileHandler) {
} }


return fileHandler(path).then(function(errors) { return fileHandler(path).then(function(errors) {
return [errors]; if (errors) {
return [errors];
}

return [];
}); });
}, this); }, this);
}, this); }, this);
Expand Down
30 changes: 29 additions & 1 deletion test/specs/checker.js
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,9 @@
var fs = require('fs');
var assert = require('assert'); var assert = require('assert');

var sinon = require('sinon'); var sinon = require('sinon');

var Checker = require('../../lib/checker'); var Checker = require('../../lib/checker');
var fs = require('fs');


describe('checker', function() { describe('checker', function() {
var checker; var checker;
Expand Down Expand Up @@ -34,6 +36,19 @@ describe('checker', function() {
assert(errors.length === 3); assert(errors.length === 3);
}); });
}); });

it('should return empty array for excluded dir', function() {
checker = new Checker();
checker.registerDefaultRules();
checker.configure({
disallowKeywords: ['with'],
excludeFiles: ['./test/**']
});
return checker.checkDirectory('./test/data/checker').then(function(errors) {
assert(Array.isArray(errors));
assert.equal(errors.length, 0);
});
});
}); });


describe('checkPath', function() { describe('checkPath', function() {
Expand Down Expand Up @@ -72,6 +87,19 @@ describe('checker', function() {
assert(true); assert(true);
}); });
}); });

it('should return empty array for excluded files', function() {
checker = new Checker();
checker.registerDefaultRules();
checker.configure({
disallowKeywords: ['with'],
excludeFiles: ['./test/**']
});
return checker.checkPath('./test/data/checker/file.js').then(function(errors) {
assert(Array.isArray(errors));
assert.equal(errors.length, 0);
});
});
}); });


describe('checkStdin', function() { describe('checkStdin', function() {
Expand Down

0 comments on commit f12830a

Please sign in to comment.