Skip to content

Commit 2ab90e5

Browse files
committed
fix(windows): keep shebang scripts LF on checkout
The previous .gitattributes only pinned *.sh/*.bash to LF. With core.autocrlf=true a Windows clone still checked out bin/cli.js and scripts/*.mjs with CRLF, so the '#!/usr/bin/env node' line kept a trailing \r: Vite's shebang strip missed it and importing scripts/restart.mjs from a test failed with 'Invalid or unexpected token'. Pin *.js/*.mjs/*.cjs/*.py to LF too.
1 parent d8591d0 commit 2ab90e5

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

.gitattributes

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
# shell scripts with CRLF and bash fails with: "$'\r': command not found".
44
* text=auto
55

6-
# Files that MUST stay LF even on Windows (executed by bash/sh).
6+
# Files that MUST stay LF even on Windows.
7+
# - .sh/.bash are executed by bash, which chokes on a trailing \r.
8+
# - .js/.mjs/.cjs/.py carry `#!/usr/bin/env ...` lines (bin/cli.js,
9+
# scripts/*.mjs, eval helpers). A CR there breaks the interpreter lookup on
10+
# Unix and survives Vite's shebang stripping on Windows, so importing those
11+
# files from a test blows up with "Invalid or unexpected token".
712
*.sh text eol=lf
813
*.bash text eol=lf
14+
*.js text eol=lf
15+
*.mjs text eol=lf
16+
*.cjs text eol=lf
17+
*.py text eol=lf
918

1019
# Binary files: no conversion.
1120
*.png binary

0 commit comments

Comments
 (0)