forked from danny-avila/agents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-line-endings.sh
More file actions
executable file
·68 lines (58 loc) · 1.91 KB
/
fix-line-endings.sh
File metadata and controls
executable file
·68 lines (58 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Script to convert all CRLF line endings to LF in the project
echo "Fixing line endings from CRLF to LF..."
echo
# Function to convert files
convert_files() {
local pattern=$1
local description=$2
echo "Converting $description files..."
find . -type f -name "$pattern" \
-not -path "./node_modules/*" \
-not -path "./dist/*" \
-not -path "./.git/*" \
-not -path "./coverage/*" \
-not -path "./types/*" \
-print0 | while IFS= read -r -d '' file; do
# Check if file has CRLF endings
if file "$file" | grep -q "CRLF"; then
echo " Converting: $file"
# Convert CRLF to LF
sed -i 's/\r$//' "$file"
fi
done
}
# Convert TypeScript and JavaScript files
convert_files "*.ts" "TypeScript"
convert_files "*.tsx" "TypeScript JSX"
convert_files "*.js" "JavaScript"
convert_files "*.jsx" "JavaScript JSX"
convert_files "*.mjs" "JavaScript module"
# Convert configuration files
convert_files "*.json" "JSON"
convert_files "*.yml" "YAML"
convert_files "*.yaml" "YAML"
convert_files ".eslintrc*" "ESLint config"
convert_files ".prettierrc*" "Prettier config"
convert_files "*.md" "Markdown"
# Convert other common files
convert_files "*.sh" "Shell script"
convert_files "Dockerfile*" "Docker"
convert_files ".env*" "Environment"
convert_files ".gitignore" "Git ignore"
convert_files "LICENSE" "License"
echo
echo "Line ending conversion complete!"
# Show statistics
echo
echo "Checking for any remaining CRLF files..."
remaining=$(find . -type f \( -name "*.ts" -o -name "*.tsx" -o -name "*.js" -o -name "*.jsx" -o -name "*.json" \) \
-not -path "./node_modules/*" \
-not -path "./dist/*" \
-not -path "./.git/*" \
-exec file {} \; | grep -c "CRLF")
if [ "$remaining" -eq 0 ]; then
echo "✅ All files now use LF line endings!"
else
echo "⚠️ Found $remaining files still with CRLF endings"
fi