diff --git a/packages/gradle/src/utils/get-gradle-report.ts b/packages/gradle/src/utils/get-gradle-report.ts index 2dbc0e99d77c2d..313664198e5966 100644 --- a/packages/gradle/src/utils/get-gradle-report.ts +++ b/packages/gradle/src/utils/get-gradle-report.ts @@ -170,7 +170,7 @@ export function processProjectReports( } const [_, file] = projectReportLines[index].split(fileSeparator); const propertyReportLines = existsSync(file) - ? readFileSync(file).toString().split(newLineSeparator) + ? readFileSync(file)?.toString()?.split(newLineSeparator) : []; let projectName: string, @@ -191,7 +191,7 @@ export function processProjectReports( const childProjects = line.substring('childProjects: {'.length); // remove curly braces {} around childProjects gradleProjectToChildProjects.set( gradleProject, - childProjects.split(',').map((c) => c.trim().split('=')[0]) // e.g. get project name from text like "app=project ':app', mylibrary=project ':mylibrary'" + childProjects?.split(',').map((c) => c?.trim()?.split('=')?.[0]) // e.g. get project name from text like "app=project ':app', mylibrary=project ':mylibrary'" ); } if (line.includes('Dir: ')) { @@ -240,7 +240,7 @@ export function processProjectReports( const [_, file] = projectReportLines[index].split(fileSeparator); const taskTypeMap = new Map(); const tasksFileLines = existsSync(file) - ? readFileSync(file).toString().split(newLineSeparator) + ? readFileSync(file)?.toString()?.split(newLineSeparator) : []; let i = 0; @@ -252,7 +252,11 @@ export function processProjectReports( if (tasksFileLines[i + 1] === dashes) { const type = line.substring(0, line.length - ' tasks'.length); i++; - while (tasksFileLines[++i] !== '') { + while ( + tasksFileLines[++i] !== '' && + i < tasksFileLines.length && + tasksFileLines[i]?.includes(' - ') + ) { const [taskName] = tasksFileLines[i].split(' - '); taskTypeMap.set(taskName, type); }