mo3ta-coverage 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +11 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mo3ta-coverage",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Run tests and report uncovered changed lines in a PR",
5
5
  "main": "index.js",
6
6
  "bin": {
package/src/cli.js CHANGED
@@ -40,10 +40,13 @@ function getChangedFiles(BASE_BRANCH) {
40
40
 
41
41
  try {
42
42
  const output = execSync(command).toString();
43
- console.log(`Changed files:\n${output}`);
44
- return output
43
+ const changedFiles = output
45
44
  .split('\n')
46
- .filter(f => f.trim().length > 0 && f.match(/\.(js|ts|jsx|tsx)$/));
45
+ .filter(f => f.trim().length > 0 && f.match(/\.(js|ts|jsx|tsx)$/))
46
+ // Defensive: ignore dependency/build/coverage artifacts even if git tracked them
47
+ .filter(f => !f.match(/(^|\/)(node_modules|coverage|dist|build)\/|(^|\/)\.git\//));
48
+ console.log(`Changed files:\n${changedFiles.join('\n')}`);
49
+ return changedFiles;
47
50
  } catch (error) {
48
51
  console.error('Error getting changed files:', error.message || error);
49
52
  return [];
@@ -340,9 +343,13 @@ function reportUncoveredChangedLines(changedFiles, LCOV_PATH, BASE_BRANCH, COVER
340
343
 
341
344
  // Cumulative coverage check
342
345
  if (totalChanged > 0) {
343
- const { overallCoverage, icon } = summarizeCoverageResult(totalChanged, totalNotCovered, COVERAGE_LIMIT);
346
+ const { overallCoverage, passed, icon } = summarizeCoverageResult(totalChanged, totalNotCovered, COVERAGE_LIMIT);
344
347
  console.log(`\n${icon} Overall coverage for all changed lines: ${overallCoverage.toFixed(2)}% (limit: ${COVERAGE_LIMIT}%)`);
345
348
  console.log(`Not covered lines: ${totalNotCovered} out of ${totalChanged} changed lines`);
346
349
  formatMissedLinesSummary(uncoveredByFile).forEach(line => console.log(line));
350
+
351
+ if (!passed) {
352
+ process.exit(1);
353
+ }
347
354
  }
348
355
  }