Skip to content

Commit

Permalink
fix(babel): Handle ignored files in babel v7 (#4393)
Browse files Browse the repository at this point in the history
* fix(babel): Handle ignored files in babel v7

In babel v7 `babel-core.transform()` might return null if a file is ignored.
This makes babel-jest not throw a TypeError in this case.

* style: Remove trailing spaces

* Update index.js
  • Loading branch information
danez authored and cpojer committed Aug 31, 2017
1 parent 0b7b47b commit 60b93b9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/babel-jest/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ const createTransformer = (options: any) => {
]);
}

return babelTransform(src, theseOptions).code;
// babel v7 might return null in the case when the file has been ignored.
const transformResult = babelTransform(src, theseOptions);
return transformResult ? transformResult.code : src;
},
};
};
Expand Down

0 comments on commit 60b93b9

Please sign in to comment.