From f910f1c1bdf2c96ff40093dad50216b7b940a490 Mon Sep 17 00:00:00 2001 From: qiqi Date: Tue, 24 Nov 2026 08:21:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(build):=20token=20=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=AE=B9=E5=BF=8D=20CRLF=EF=BC=8C=E5=8A=A0=20.gitattributes?= =?UTF-8?q?=EF=BC=9BWindows=20=E4=B8=8D=E5=86=8D=E8=AF=AF=E6=8A=A5?= =?UTF-8?q?=E5=BF=AB=E7=85=A7=E4=B8=8D=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 6 ++++++ scripts/gen-tokens.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .gitattributes 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')