-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathload_icons.sh
executable file
·36 lines (28 loc) · 1.15 KB
/
load_icons.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
#! /bin/bash
# Creates JS file containing an array of icon data (icon name and url)
# Used to bypass writing out 100 objects in the initIcons function in creator-assets/controllers.coffee
# ------------------------------------------------
# Outputs list of file names into lsoutput.log
ls -a ./src/assets/icons > lsoutput.log
last_line=$(wc -l < lsoutput.log)
current_line_number=0
output="./src/assets/icons.js"
FMT='{name:"%s",url:"%s"},'
FMT_LAST_LINE='{name:"%s",url:"%s"}'
printf 'icons = [' > $output
# Reads lsoutput.log and inserts each filename into JSON file
while read -r CURRENT_LINE
current_line_number=$(($current_line_number + 1))
do
if [[ $current_line_number -ne $last_line ]]; then
if [[ $CURRENT_LINE == *".png" ]]; then
printf "$FMT" "$CURRENT_LINE" "assets/icons/$CURRENT_LINE" >> $output
fi
else
printf "$FMT_LAST_LINE" "$CURRENT_LINE" "assets/icons/$CURRENT_LINE" >> $output
break
fi
done < lsoutput.log
printf "]" >> $output
rm lsoutput.log
# Go to src/assets/icons.js and copy paste it into the initIcons function in creator-assets/controllers.coffee