Skip to content

Commit

Permalink
Improve regex to replace root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed Feb 22, 2019
1 parent bb17736 commit f9d0ca6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/babel-jest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const createTransformer = (
function getRootDirRegExp(rootDir: Config.Path): RegExp {
if (!rootDirRegExpCache[rootDir]) {
rootDirRegExpCache[rootDir] = new RegExp(
`^${escapeStrForRegex(rootDir)}(${escapeStrForRegex(path.sep)}|$)`,
`^${escapeStrForRegex(rootDir)}(?=${escapeStrForRegex(path.sep)}|$)`,
);
}

Expand All @@ -86,7 +86,7 @@ const createTransformer = (
// babel options to relativize paths
return JSON.stringify(babelOptions.options, (_key, value) => {
if (typeof value === 'string') {
return value.replace(rootDirRegExp, '<rootDir>$1');
return value.replace(rootDirRegExp, '<rootDir>');
}
return value;
});
Expand Down

0 comments on commit f9d0ca6

Please sign in to comment.