Skip to content

Commit

Permalink
make excludeFilePaths optional
Browse files Browse the repository at this point in the history
  • Loading branch information
d-beloved committed Dec 20, 2024
1 parent 25cb9ce commit 80dff86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const getLinesOfCodeToExclude = async (filePaths: string[]): Promise<number> =>
*
* @param owner The owner of the Github repository.
* @param repo The name of the Github repository.
* @param excludeFilePaths The file paths to exclude, relative to the root of the repository.
* @param excludeFilePaths An optional array of file paths to exclude, relative to the root of the repository.
* @returns The total number of lines of code in the repository, minus any lines of code in the given paths to exclude,
* or a string describing an error if the data could not be fetched.
*/
const getRepoLinesOfCode = async (owner: string, repo: string, excludeFilePaths: string[]): Promise<number|string> => {
const getRepoLinesOfCode = async (owner: string, repo: string, excludeFilePaths: string[] = []): Promise<number|string> => {
const url = `https://api.github.com/repos/${owner}/${repo}/stats/code_frequency`;

try {
Expand All @@ -49,7 +49,7 @@ const getRepoLinesOfCode = async (owner: string, repo: string, excludeFilePaths:
return "Github - No data found for the given repository";
}

if (excludeFilePaths && excludeFilePaths.length > 0) {
if (excludeFilePaths.length > 0) {
const locToExclude = await getLinesOfCodeToExclude(excludeFilePaths);
return linesOfCode - locToExclude;
}
Expand Down

0 comments on commit 80dff86

Please sign in to comment.