From 80dff862821cd327b3ccfb19176db500d34201e0 Mon Sep 17 00:00:00 2001 From: d-beloved Date: Fri, 20 Dec 2024 13:02:53 +0100 Subject: [PATCH] make excludeFilePaths optional --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0cb886e..ff9c641 100644 --- a/src/index.ts +++ b/src/index.ts @@ -32,11 +32,11 @@ const getLinesOfCodeToExclude = async (filePaths: string[]): Promise => * * @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 => { +const getRepoLinesOfCode = async (owner: string, repo: string, excludeFilePaths: string[] = []): Promise => { const url = `https://api.github.com/repos/${owner}/${repo}/stats/code_frequency`; try { @@ -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; }