Skip to content

Commit

Permalink
feat(): reduce generated moduleNameMapper entry to one line
Browse files Browse the repository at this point in the history
using an optimized regex which matches either an empty string or the subpath after the packageRoot
  • Loading branch information
SimonNiliusSAP committed Jul 15, 2021
1 parent edfb575 commit f9f45a2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/library/library.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ function updateJestConfig(
if (!jestOptions.moduleNameMapper) {
jestOptions.moduleNameMapper = {};
}
const packageKeyRegex = '^' + packageKey + '$';
const deepPackagePathRegex = '^' + packageKey + '/(.*)' + '$';
const packageKeyRegex = '^' + packageKey + '(|/.*)$';
const packageRoot = join('<rootDir>' as Path, distRoot);
jestOptions.moduleNameMapper[deepPackagePathRegex] = join(packageRoot, '$1');
jestOptions.moduleNameMapper[packageKeyRegex] = packageRoot;
jestOptions.moduleNameMapper[packageKeyRegex] = join(packageRoot, '$1');
}

function updateNpmScripts(
Expand Down

0 comments on commit f9f45a2

Please sign in to comment.