Skip to content

Commit

Permalink
Improved the filename search regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Prakash-Verma committed Apr 21, 2021
1 parent fb5e913 commit 8681776
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions builder/strictify/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function getAllErrors(errMessage: string, projectRoot: string) {
function findAllIndices(errMessage: string, projectRoot: string) {
const stopIndex = errMessage.length - 1;

const regexStr = projectRoot ? `${projectRoot}/src` : 'src';
const regexStr = getErrorMatchingRegex(projectRoot);
const regex = new RegExp(regexStr, 'g');

const it = errMessage.matchAll(regex);
Expand All @@ -66,8 +66,16 @@ function findAllIndices(errMessage: string, projectRoot: string) {
return allIndices;
}

function getErrorMatchingRegex(projectRoot: string) {
if (projectRoot) {
projectRoot = projectRoot.replace(/\/$/, '');
return `${projectRoot}/src`;
}
return 'src';
}

export function getListOfFilesWithError(errorMessage: string) {
const allErrors = errorMessage.match(/src.*\.(ts|html)/g);
const allErrors = errorMessage.match(/src\/.*\.(ts|html)/g);
if (allErrors) {
allErrors.sort();
}
Expand Down

0 comments on commit 8681776

Please sign in to comment.