Fix local target failure exit codes

AI assistance disclosure: Codex implemented and tested this fix under maintainer direction.
This commit is contained in:
Paul Bakaus
2026-09-02 18:48:43 -07:00
parent 7437368526
commit 2001c81686
2 changed files with 25 additions and 1 deletions
+5 -1
View File
@@ -364,7 +364,11 @@ async function detectCli() {
const resolved = path.resolve(target);
let stat;
try { stat = fs.statSync(resolved); }
catch { process.stderr.write(`Warning: cannot access ${target}\n`); continue; }
catch {
hadOperationalFailure = true;
process.stderr.write(`Warning: cannot access ${target}\n`);
continue;
}
if (stat.isDirectory()) {
// Check for framework dev server config (skip in JSON/quiet modes to avoid polluting output)
+20
View File
@@ -138,6 +138,26 @@ describe('detect CLI browser failures', () => {
expect(findings.some(finding => finding.antipattern === 'bounce-easing')).toBe(true);
expect(result.stderr).toContain('puppeteer is required for URL scanning');
});
test('exits 1 when an explicitly requested local target cannot be accessed', () => {
const result = runWithoutPuppeteer(['missing.css']);
expect(result.status).toBe(1);
expect(result.stdout).toBe('[]\n');
expect(result.stderr).toContain('Warning: cannot access missing.css');
});
test('missing local target takes precedence over findings from another target', () => {
const result = runWithoutPuppeteer(
['missing.css', 'page.css'],
{ 'page.css': '.hero { animation: bounce 1s linear infinite; }\n' },
);
const findings = JSON.parse(result.stdout);
expect(result.status).toBe(1);
expect(findings.some(finding => finding.antipattern === 'bounce-easing')).toBe(true);
expect(result.stderr).toContain('Warning: cannot access missing.css');
});
});
describe('splitScanUrl', () => {