Skip to content

Commit

Permalink
Allow exclusion of directories starting with a dot (#711)
Browse files Browse the repository at this point in the history
* Create test for desired behavior

* Pass dot: true option to Minimatch
  • Loading branch information
colatkinson authored and aciccarello committed Aug 17, 2018
1 parent 8384a95 commit 341084f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/application.ts
Expand Up @@ -248,7 +248,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
*/
public expandInputFiles(inputFiles?: string[]): string[] {
let files: string[] = [];
const exclude: Array<IMinimatch> = this.exclude ? this.exclude.map(pattern => new Minimatch(pattern)) : [];
const exclude: Array<IMinimatch> = this.exclude ? this.exclude.map(pattern => new Minimatch(pattern, {dot: true})) : [];

function isExcluded(fileName: string): boolean {
return exclude.some(mm => mm.match(fileName));
Expand Down
1 change: 1 addition & 0 deletions src/test/.dot/index.ts
@@ -0,0 +1 @@
export default {};
9 changes: 9 additions & 0 deletions src/test/typedoc.ts
@@ -1,6 +1,7 @@
import { Application } from '..';
import * as Path from 'path';
import Assert = require('assert');
import './.dot';

describe('TypeDoc', function() {
let application: Application;
Expand Down Expand Up @@ -55,5 +56,13 @@ describe('TypeDoc', function() {
Assert.equal(expanded.indexOf(Path.join(inputFiles, 'access', 'access.ts')), -1);
Assert.equal(expanded.indexOf(inputFiles), -1);
});
it('supports excluding directories beginning with dots', function() {
const inputFiles = __dirname;
application.options.setValue('exclude', '**/+(.dot)/**');
const expanded = application.expandInputFiles([inputFiles]);

Assert.equal(expanded.indexOf(Path.join(inputFiles, '.dot', 'index.d.ts')), -1);
Assert.equal(expanded.indexOf(inputFiles), -1);
});
});
});

0 comments on commit 341084f

Please sign in to comment.