Skip to content

Commit

Permalink
refactor shouldInstrument (jestjs#3757)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Jun 8, 2017
1 parent f3a16cb commit 4f84380
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/jest-runtime/src/ScriptTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ const getScriptCacheKey = (filename, config, instrument: boolean) => {

const shouldTransform = (filename: Path, config: ProjectConfig): boolean => {
if (!ignoreCache.has(config)) {
if (!config.transformIgnorePatterns) {
if (
!config.transformIgnorePatterns ||
config.transformIgnorePatterns.length === 0
) {
ignoreCache.set(config, null);
} else {
ignoreCache.set(
Expand All @@ -396,11 +399,7 @@ const shouldTransform = (filename: Path, config: ProjectConfig): boolean => {

const ignoreRegexp = ignoreCache.get(config);
const isIgnored = ignoreRegexp ? ignoreRegexp.test(filename) : false;
return (
!!config.transform &&
!!config.transform.length &&
(!config.transformIgnorePatterns.length || !isIgnored)
);
return !!config.transform && !!config.transform.length && !isIgnored;
};

const wrap = content =>
Expand Down

0 comments on commit 4f84380

Please sign in to comment.