Skip to content

Commit d4ca525

Browse files
author
Simon Renoult
committed
refactor: filter js/ts files at the git command level
1 parent a25c271 commit d4ca525

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

.idea/workspace.xml

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

src/count-commits-per-file.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function countCommitsPerFile(
2727
return stdout
2828
.split(PER_LINE)
2929
.map(trim)
30-
.filter(jsOrTsOnly)
30+
.filter(removeEmptyLines)
3131
.map(toCommitCountPerFile(directory))
3232
.filter(ignoreFilesThatNoLongerExist);
3333
}
@@ -56,18 +56,18 @@ function buildCommand(directory, { firstParent, since }): string {
5656
const firstParentFlag = firstParent ? "--first-parent" : "";
5757
const sinceParameter = since ? `--since="${since}"` : "";
5858
return [
59-
`git -C ${directory} log ${sinceParameter} ${firstParentFlag} --name-only --format=''`,
59+
`git -C ${directory} log ${sinceParameter} ${firstParentFlag} --name-only --format='' '*.[tj]s'`,
6060
"sort",
6161
"uniq --count"
6262
].join(" | ");
6363
}
6464

65-
function trim(s): string {
65+
function trim(s: string): string {
6666
return s.trim();
6767
}
6868

69-
function jsOrTsOnly(s): string {
70-
return s.endsWith(".js") || s.endsWith(".ts");
69+
function removeEmptyLines(s: string): boolean {
70+
return s.length !== 0;
7171
}
7272

7373
function toCommitCountPerFile(directory) {

0 commit comments

Comments
 (0)