mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 22:26:38 +03:00
Fix local target failure exit codes
AI assistance disclosure: Codex implemented and tested this fix under maintainer direction.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user