-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_pixel_values.sh
More file actions
executable file
·41 lines (35 loc) · 1017 Bytes
/
Copy pathcheck_pixel_values.sh
File metadata and controls
executable file
·41 lines (35 loc) · 1017 Bytes
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
#!/bin/bash
found_error=false
check_file() {
pixel_lines=()
ignore_next=false
while IFS= read -r line; do
if [[ $ignore_next == true ]]; then
ignore_next=false
continue
fi
if [[ $line =~ \/\/*[[:space:]]*ignore-px-checker ]]; then
ignore_next=true
continue
fi
if [[ $line =~ :[[:space:]]*[^[:space:]]+[[:space:]]*px ]]; then
formatted_line=$(echo "$line" | sed 's/\(:\)[[:space:]]\+\([^[:space:]]\)/\1\2/')
pixel_lines+=("$formatted_line")
fi
done < <(grep -rn 'px' "$1")
if [ "${#pixel_lines[@]}" -ne 0 ]; then
found_error=true
echo "Found pixel values in $1:"
printf '%s\n' "${pixel_lines[@]}"
echo
fi
}
search_files() {
while IFS= read -r -d '' file; do
check_file "$file"
done < <(find "$1" -type f \( -name "*.scss" -o -name "*.css" \) -print0)
}
search_files "$1"
if [ "$found_error" = true ]; then
exit 1
fi