-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_icon.sh
executable file
·43 lines (31 loc) · 1.19 KB
/
generate_icon.sh
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
#!/bin/bash
# Check if the first argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <filename>"
exit 1
fi
# Directory of the .js files
cd private/fa/pro-$1-svg-icons
first_letter=$(echo $1 | cut -c1)
prefix="fa"
fixed_string="${prefix}${first_letter} ${prefix}"
new_file_name="${prefix}${first_letter}_list.js"
# Output directory path
output_dir="../../../IconList"
echo "Output directory: $output_dir"
# Ensure the output directory exists
mkdir -p "$output_dir"
# Start of the JS file
echo "export const zzz = [" > "$output_dir/$new_file_name"
# Loop through all .js files that start with 'fa' in the current directory
for file in ${prefix}*.js; do
# Extract the filename without extension
basename="${file%.*}" # Strip the extension
rest_of_name="${basename#$prefix}" # Get the rest of the name after 'fa'
# Convert camelCase to kebab-case for the rest of the name
kebab_case=$(echo "$rest_of_name" | sed -r 's/([a-z0-9])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]')
# Append to the JS file with the new format
echo " '$fixed_string-$kebab_case'," >> "$output_dir/$new_file_name"
done
# Close the array in the JS file
echo "]" >> "$output_dir/$new_file_name"