(pattern?: string)
| 155 | } |
| 156 | |
| 157 | const linesOfCode = async (pattern?: string) => { |
| 158 | const isPatternMatch = (path: string) => pattern === undefined || micromatch.isMatch(path, pattern) |
| 159 | |
| 160 | const [createdFilesDiffs, modifiedFilesDiffs, deletedFilesDiffs] = await Promise.all([ |
| 161 | Promise.all(gitJSONRep.created_files.filter(isPatternMatch).map((path) => diffForFile(path))), |
| 162 | Promise.all(gitJSONRep.modified_files.filter(isPatternMatch).map((path) => diffForFile(path))), |
| 163 | Promise.all(gitJSONRep.deleted_files.filter(isPatternMatch).map((path) => diffForFile(path))), |
| 164 | ]) |
| 165 | |
| 166 | let additions = createdFilesDiffs |
| 167 | .map((diff) => (!diff ? 0 : diff.added === "" ? 0 : diff.added.split("\n").length)) |
| 168 | .reduce((mem, value) => mem + value, 0) |
| 169 | let deletions = deletedFilesDiffs |
| 170 | .map((diff) => (!diff ? 0 : diff.removed === "" ? 0 : diff.removed.split("\n").length)) |
| 171 | .reduce((mem, value) => mem + value, 0) |
| 172 | const modifiedLines = modifiedFilesDiffs.map((diff) => [ |
| 173 | !diff ? 0 : diff.added === "" ? 0 : diff.added.split("\n").length, |
| 174 | !diff ? 0 : diff.removed === "" ? 0 : diff.removed.split("\n").length, |
| 175 | ]) |
| 176 | |
| 177 | additions = modifiedLines.reduce((mem, value) => mem + value[0], additions) |
| 178 | deletions = modifiedLines.reduce((mem, value) => mem + value[1], deletions) |
| 179 | |
| 180 | return additions + deletions |
| 181 | } |
| 182 | |
| 183 | const byType = |
| 184 | (t: string) => |
nothing calls this directly
no test coverage detected