fix(scripts): exempt .env template files from diff-coverage gate

.env.example and siblings are config/template files with no executable
code. The coverage:diff script now matches them via the same dotfile
pattern used for .gitignore and .npmrc.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 18:22:19 +00:00
parent d5c01209ea
commit d67a89179e
2 changed files with 14 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ const ALLOWED_GLOBS = [
/\.ya?ml$/,
/\.gitignore$/,
/\.npmrc$/,
/(^|\/)\.env(\.[^/]+)?$/, // .env, .env.example, .env.local, etc.
// Shell scripts (not Vitest-covered)
/\.sh$/,
/\.bash$/,

View File

@@ -154,6 +154,19 @@ describe("computeDiffCoverage", () => {
assert.equal(result.summary.filesChanged, 4);
});
test("skips .env template files (.env, .env.example, .env.local)", () => {
const lcov = parseLcov(lcovText);
const diff = new Map([
[".env.example", new Set([1, 2, 3])],
[".env.local", new Set([1])],
[".env", new Set([1])],
]);
const result = computeDiffCoverage(diff, lcov);
assert.equal(result.status, "pass");
assert.equal(result.summary.filesGated, 0);
assert.equal(result.summary.filesChanged, 3);
});
test("end-to-end fixture: mixed pass/fail/skip/no-data", () => {
const lcov = parseLcov(lcovText);
const diff = parseGitDiff(diffText);