Merge pull request #617 from cdparks/fix-excludes

Fix for #616, making excluded-filepaths play nicely with -r
This commit is contained in:
Jeff Williams 2014-04-09 16:52:32 -07:00
commit b7782fc151
2 changed files with 25 additions and 1 deletions

View File

@ -57,7 +57,7 @@ exports.Filter.prototype.isIncluded = function(filepath) {
if (this.exclude) {
this.exclude.forEach(function(exclude) {
if ( exclude === filepath || exclude === path.dirname(filepath) ) {
if ( filepath.indexOf(exclude) === 0 ) {
included = false;
}
});

View File

@ -137,6 +137,30 @@ describe('jsdoc/src/filter', function() {
expect( files.indexOf('yes.js') ).toBeGreaterThan(-1);
expect( files.indexOf('module/yes.js') ).toBeGreaterThan(-1);
});
it('should be able to exclude descendants of excluded subdirectories', function() {
var files = [
'yes.js',
'topsecret/nested/nope.js',
'module/yes.js',
'module/topsecret/nested/nope.js'
];
myFilter = new filter.Filter({
includePattern: defaultIncludePattern,
excludePattern: defaultExcludePattern,
exclude: ['topsecret', 'module/topsecret']
});
files = files.filter(function($) {
return myFilter.isIncluded($);
});
expect(files.length).toBe(2);
expect( files.indexOf('yes.js') ).toBeGreaterThan(-1);
expect( files.indexOf('module/yes.js') ).toBeGreaterThan(-1);
expect( files.indexOf('topsecret/nested/nope.js') ).toBe(-1);
expect( files.indexOf('module/topsecret/nested/nope.js') ).toBe(-1);
});
});
});