#!/usr/bin/env node /** 检查一组 hex 在 uni.scss 中是否有等值令牌 */ const fs = require('fs'); const scss = fs.readFileSync('uni.scss', 'utf8'); const HEXES = process.argv.slice(2); // 收集 uni.scss 中所有令牌定义 const tokenDefs = []; for (const line of scss.split(/\r?\n/)) { const m = line.match(/^\s*(\$[\w-]+)\s*:\s*(#[0-9a-fA-F]{3,8})\s*;/); if (m) tokenDefs.push({ token: m[1], hex: m[2].toUpperCase() }); } const byHex = {}; for (const t of tokenDefs) { if (!byHex[t.hex]) byHex[t.hex] = []; byHex[t.hex].push(t.token); } for (const h of HEXES) { const up = h.toUpperCase(); const tokens = byHex[up]; console.log(up + ' -> ' + (tokens ? tokens.join(', ') : '(无令牌)')); }