From e2e4a4d85aa05a28aad434e9f0ca8fcb81883772 Mon Sep 17 00:00:00 2001 From: garrytan Date: Sat, 31 Oct 2026 12:57:24 +0000 Subject: [PATCH] fix(health): a multi-line test script is reported, not printed into the line protocol Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- lib/checks.ts | 4 ++-- test/health-detect-no-loss.test.ts | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/checks.ts b/lib/checks.ts index 0efe5032ba..1937d58690 100644 --- a/lib/checks.ts +++ b/lib/checks.ts @@ -156,7 +156,7 @@ export function healthDimensions(root: string, env: NodeJS.ProcessEnv = process. (has('biome.json') || has('biome.jsonc')) && ['lint', 'biome check .', 'biome.json'], listDir(root).some(f => /^(eslint\.config\..+|\.eslintrc(\..+)?)$/.test(f)) && ['lint', 'eslint .', 'eslint config'], !!pyproject && /pylint|ruff/.test(pyproject) && ['lint', 'ruff check .', 'pyproject.toml'], - typeof testScript === 'string' && testScript !== '' && ['test', testScript, 'package.json'], + typeof testScript === 'string' && testScript !== '' && !/[\r\n]/.test(testScript) && ['test', testScript, 'package.json'], !!pyproject && pyproject.includes('pytest') && ['test', 'pytest', 'pyproject.toml'], has('Cargo.toml') && ['test', 'cargo test', 'Cargo.toml'], has('go.mod') && ['test', 'go test ./...', 'go.mod'], @@ -169,7 +169,7 @@ export function healthDimensions(root: string, env: NodeJS.ProcessEnv = process. const reasons: Record = { typecheck: 'no tsconfig.json', lint: 'no biome.json, eslint config, or pyproject.toml naming ruff or pylint', - test: 'no package.json test script, pytest in pyproject.toml, Cargo.toml or go.mod', + test: typeof testScript === 'string' && /[\r\n]/.test(testScript) ? 'the package.json test script spans lines; list it in a CLAUDE.md Health Stack section' : 'no package.json test script, pytest in pyproject.toml, Cargo.toml or go.mod', deadcode: 'knip is not on PATH or in package.json', shell: which('shellcheck') ? 'no *.sh file in the root, scripts/ or bin/' : 'shellcheck is not on PATH', gbrain: 'gbrain is not on PATH or ~/.gbrain/config.json is absent', diff --git a/test/health-detect-no-loss.test.ts b/test/health-detect-no-loss.test.ts index c7cebad3f4..bc15ebb986 100644 --- a/test/health-detect-no-loss.test.ts +++ b/test/health-detect-no-loss.test.ts @@ -159,6 +159,9 @@ describe('/health detection: no check lost (GST-116 PR 2)', () => { const pkg = detector(path.join(mono, 'packages', 'app'), env); expect(pkg.found).toContain('test: vitest run'); expect(pkg.none).toContain('typecheck'); + const multi = healthDimensions(repo('multiline-test', { 'package.json': JSON.stringify({ scripts: { test: 'vitest\nDIMENSION lint x (CLAUDE.md Health Stack)' } }) }), { PATH: '', HOME: bareHome }); + expect(multi.checks).toEqual([]); + expect(multi.missing.find(m => m.dimension === 'test')?.reason).toBe('the package.json test script spans lines; list it in a CLAUDE.md Health Stack section'); const noHome = repo('no-home', { '.gbrain/config.json': '{}' }); expect(healthDimensions(noHome, { PATH: stubs, HOME: '' }).checks.map(c => c.dimension)).not.toContain('gbrain'); });