Skip to content

Commit

Permalink
Update jest-haste-map ignorePattern to accept RegExp or Function
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-savage committed Mar 3, 2017
1 parent 6e9cfeb commit ef28d7b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Options = {
extensions: Array<string>,
forceNodeFilesystemAPI?: boolean,
hasteImplModulePath?: string,
ignorePattern: RegExp,
ignorePattern: RegExp | Function,
maxWorkers: number,
mocksPattern?: string,
name: string,
Expand All @@ -62,7 +62,7 @@ type InternalOptions = {
extensions: Array<string>,
forceNodeFilesystemAPI: boolean,
hasteImplModulePath?: string,
ignorePattern: RegExp,
ignorePattern: RegExp | Function,
maxWorkers: number,
mocksPattern: ?RegExp,
name: string,
Expand Down Expand Up @@ -688,7 +688,13 @@ class HasteMap extends EventEmitter {
* Helpers
*/
_ignore(filePath: Path): boolean {
return this._options.ignorePattern.test(filePath) ||
const ignorePattern = this._options.ignorePattern;
const ignoreMatched =
Object.prototype.toString.call(ignorePattern) === '[object RegExp]'
? ignorePattern.test(filePath) // $FlowFixMe
: ignorePattern(filePath);

return ignoreMatched ||
(!this._options.retainAllFiles && this._isNodeModulesDir(filePath));
}

Expand Down

0 comments on commit ef28d7b

Please sign in to comment.