#!/usr/bin/env node import { spawnSync } from "node:child_process"; // Use PCRE2 lookbehind to avoid: // 1. Matches preceded by a word character (e.g. `Issue#123`) // 2. Matches preceded by `&` (e.g. HTML entities `'`) const SEARCH_PATTERN = '(? { // Output format is filename:line:content... // We just check if the line starts with a known ignored file. if (line.startsWith('js/webtorrent.min.js')) return false; if (line.startsWith('perf/hits-')) return false; return true; }); if (filteredLines.length > 0) { console.error('Hex colors detected outside tokens or SVG assets:'); console.error(filteredLines.join('\n')); console.error('\nAllowed exceptions: tokens (css/tokens.css) and vector logos (*.svg).'); process.exit(1); } } if (result.status && result.status !== 1) { console.error('git grep reported an error while scanning for hex values.'); if (result.stderr) { console.error(result.stderr.trimEnd()); } process.exit(result.status); } process.exit(0);