Skip to content

Commit

Permalink
feat: adds includePattern option
Browse files Browse the repository at this point in the history
  • Loading branch information
Morgan authored and ljharb committed May 29, 2019
1 parent 5efa467 commit 18d3c51
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import transformSvg from './transformSvg';
import fileExistsWithCaseSync from './fileExistsWithCaseSync';

let ignoreRegex;
let includeRegex;

export default declare(({
assertVersion,
Expand Down Expand Up @@ -48,10 +49,17 @@ export default declare(({
if (typeof importPath !== 'string') {
throw new TypeError('`applyPlugin` `importPath` must be a string');
}
const { ignorePattern, caseSensitive, filename: providedFilename } = state.opts;
const { ignorePattern, includePattern, caseSensitive, filename: providedFilename } = state.opts;
const { file, filename } = state;
let newPath;
if (ignorePattern) {
if (includePattern) {
// Only set the includeRegex once:
includeRegex = includeRegex || new RegExp(includePattern);
// Test if we should ignore this:
if (!includeRegex.test(importPath)) {
return;
}
} else if (ignorePattern) {
// Only set the ignoreRegex once:
ignoreRegex = ignoreRegex || new RegExp(ignorePattern);
// Test if we should ignore this:
Expand Down

0 comments on commit 18d3c51

Please sign in to comment.