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.
This commit is contained in:
parent
a77f6b0a58
commit
8e61fc214a
6 changed files with 30 additions and 6 deletions
|
|
@ -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
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue