Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds includePattern as options #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion 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,9 +49,18 @@ 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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ignorePattern, includePattern, caseSensitive, filename: providedFilename,
ignorePattern,
includePattern,
caseSensitive,
filename: providedFilename,

:-) please don't use prettier on a repo that doesn't have it configured

} = state.opts;
const { file, filename } = state;
let newPath;
if (includePattern) {
includeRegex = includeRegex || new RegExp(includePattern);

if (!includeRegex.test(importPath)) {
return undefined;
}
}
if (ignorePattern) {
// Only set the ignoreRegex once:
ignoreRegex = ignoreRegex || new RegExp(ignorePattern);
Expand Down
Loading