Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change include path for lines of code counting
Previously, we were always using `**` in the include path. the
effect of this was to always count lines in the entire
repository unless explicitly added to the paths-ignore. This
was incorrect behaviour. Now we only using `**` if the include
path is otherwise empty.
Andrew Eisenberg committed May 13, 2021

Unverified

No user is associated with the committer email.
1 parent a77f6b0 commit 8e61fc2
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
@@ -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
});
});

2 changes: 1 addition & 1 deletion src/count-loc.ts
@@ -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();

0 comments on commit 8e61fc2

Please sign in to comment.