Skip to content

Commit 6a0bd27

Browse files
authored
Merge pull request #500 from github/aeisenberg/paths-include
Change include path for lines of code counting
2 parents a77f6b0 + 8e61fc2 commit 6a0bd27

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

lib/count-loc.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/count-loc.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/count-loc.test.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/count-loc.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/count-loc.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,23 @@ test("ensure lines of code can handle includes", async (t) => {
6363
);
6464

6565
t.deepEqual(results, {
66-
javascript: 15,
66+
javascript: 12,
67+
});
68+
});
69+
70+
test("ensure lines of code can handle empty includes", async (t) => {
71+
// note that "**" is always included. The includes are for extra
72+
// directories outside the normal structure.
73+
const results = await countLoc(
74+
path.join(__dirname, "../tests/multi-language-repo"),
75+
["idontexist"],
76+
[],
77+
[Language.javascript],
78+
getRunnerLogger(true)
79+
);
80+
81+
t.deepEqual(results, {
82+
// should get no results
6783
});
6884
});
6985

src/count-loc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function countLoc(
6969
): Promise<Partial<Record<Language, number>>> {
7070
const result = await new LocDir({
7171
cwd,
72-
include: ["**"].concat(include || []),
72+
include: Array.isArray(include) && include.length > 0 ? include : ["**"],
7373
exclude,
7474
analysisLanguages: dbLanguages.flatMap((lang) => nameToLinguist[lang]),
7575
}).loadInfo();

0 commit comments

Comments
 (0)