diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..acde4f1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,6 @@ +* text=auto +*.css text eol=lf +*.js text eol=lf +*.json text eol=lf +*.md text eol=lf +src/design-tokens.css text eol=lf diff --git a/scripts/gen-tokens.js b/scripts/gen-tokens.js index e98bdf4..ade6f64 100644 --- a/scripts/gen-tokens.js +++ b/scripts/gen-tokens.js @@ -424,7 +424,9 @@ function main () { } const problems = [] - const cur = fs.existsSync(CSS_OUT) ? fs.readFileSync(CSS_OUT, 'utf8') : '' + // Windows 默认 core.autocrlf=true 会把 CSS 检出成 CRLF;内容一致但字符串不等, + // 会误报「快照与 derive() 不一致」。比较前统一换行符(写入始终 LF,见 .gitattributes)。 + const cur = (fs.existsSync(CSS_OUT) ? fs.readFileSync(CSS_OUT, 'utf8') : '').replace(/\r\n/g, '\n') if (cur !== css) { // 逐行指出第一处差异,别让人对着两千行找 const a = cur.split('\n')