Skip to content

Commit

Permalink
Merge pull request #500 from github/aeisenberg/paths-include
Browse files Browse the repository at this point in the history
Change include path for lines of code counting
  • Loading branch information
Andrew Eisenberg authored and GitHub committed May 13, 2021
2 parents a77f6b0 + 8e61fc2 commit 6a0bd27
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/count-loc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/count-loc.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion lib/count-loc.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/count-loc.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion src/count-loc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,23 @@ test("ensure lines of code can handle includes", async (t) => {
);

t.deepEqual(results, {
javascript: 15,
javascript: 12,
});
});

test("ensure lines of code can handle empty includes", async (t) => {
// note that "**" is always included. The includes are for extra
// directories outside the normal structure.
const results = await countLoc(
path.join(__dirname, "../tests/multi-language-repo"),
["idontexist"],
[],
[Language.javascript],
getRunnerLogger(true)
);

t.deepEqual(results, {
// should get no results
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/count-loc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function countLoc(
): Promise<Partial<Record<Language, number>>> {
const result = await new LocDir({
cwd,
include: ["**"].concat(include || []),
include: Array.isArray(include) && include.length > 0 ? include : ["**"],
exclude,
analysisLanguages: dbLanguages.flatMap((lang) => nameToLinguist[lang]),
}).loadInfo();
Expand Down

0 comments on commit 6a0bd27

Please sign in to comment.