Skip to content

Commit 80dff86

Browse files
committed
make excludeFilePaths optional
1 parent 25cb9ce commit 80dff86

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ const getLinesOfCodeToExclude = async (filePaths: string[]): Promise<number> =>
3232
*
3333
* @param owner The owner of the Github repository.
3434
* @param repo The name of the Github repository.
35-
* @param excludeFilePaths The file paths to exclude, relative to the root of the repository.
35+
* @param excludeFilePaths An optional array of file paths to exclude, relative to the root of the repository.
3636
* @returns The total number of lines of code in the repository, minus any lines of code in the given paths to exclude,
3737
* or a string describing an error if the data could not be fetched.
3838
*/
39-
const getRepoLinesOfCode = async (owner: string, repo: string, excludeFilePaths: string[]): Promise<number|string> => {
39+
const getRepoLinesOfCode = async (owner: string, repo: string, excludeFilePaths: string[] = []): Promise<number|string> => {
4040
const url = `https://api.github.com/repos/${owner}/${repo}/stats/code_frequency`;
4141

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

52-
if (excludeFilePaths && excludeFilePaths.length > 0) {
52+
if (excludeFilePaths.length > 0) {
5353
const locToExclude = await getLinesOfCodeToExclude(excludeFilePaths);
5454
return linesOfCode - locToExclude;
5555
}

0 commit comments

Comments
 (0)