Skip to content

Commit dfde7f4

Browse files
committed
Better categorization
1 parent f9056c8 commit dfde7f4

3 files changed

Lines changed: 87 additions & 14 deletions

File tree

package-lock.json

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

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
"jest-trx-results-processor": "^3.0.2",
244244
"lint-staged": "^16.1.2",
245245
"lolex": "^6.0.0",
246+
"minimatch": "^10.0.3",
246247
"node-dev": "^8.0.0",
247248
"prettier": "^3.6.2",
248249
"selenium-webdriver": "^4.34.0",

scripts/printCommitStats.mjs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,24 @@
55
import chalk from 'chalk';
66
import { exec } from 'child_process';
77
import { parsePatch } from 'diff';
8+
import { minimatch } from 'minimatch';
89
import { promisify } from 'util';
910

1011
function getCategory(
1112
/** @type { string } */
1213
path
1314
) {
14-
return path.includes('/.github/')
15-
? 'others'
16-
: path.endsWith('.md')
17-
? 'doc'
18-
: path.includes('/__tests__/')
19-
? 'test'
20-
: path.includes('package-lock.json')
21-
? 'generated'
22-
: 'production';
15+
return minimatch(path, '*/packages/test/**')
16+
? 'test'
17+
: minimatch(path, '*/packages/**/src/**/*')
18+
? 'production'
19+
: minimatch(path, '**/*.md')
20+
? 'doc'
21+
: minimatch(path, '*/__tests__/**/*')
22+
? 'test'
23+
: minimatch(path, '**/package-lock.json')
24+
? 'generated'
25+
: 'others';
2326
}
2427

2528
function toIntegerOrFixed(
@@ -127,6 +130,6 @@ function toRatioString(
127130
const [prodRatio, testRatio] = toRatio(stats.get('production').numLineAdded, stats.get('test').numLineAdded);
128131

129132
console.log(
130-
`${testRatio > prodRatio ? '😇' : '🚨'} There are ${chalk.magenta(toIntegerOrFixed(testRatio))} lines of test code added for every ${chalk.magenta(toIntegerOrFixed(prodRatio))} lines of production code added.`
133+
`${prodRatio === 0 || testRatio > prodRatio ? '😇' : '🚨'} There are ${chalk.magenta(toIntegerOrFixed(testRatio))} lines of test code added for every ${chalk.magenta(toIntegerOrFixed(prodRatio))} lines of production code added.`
131134
);
132135
})();

0 commit comments

Comments
 (0)