-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.sh
executable file
·55 lines (40 loc) · 1.12 KB
/
compile.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
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Configuration
CSS_SOURCE_PATH="./src/css";
CSS_ASSETS_PATH="./assets/css";
CSS_DEST_FILE="./assets/css/app.css";
IMPORTS_FILE="$CSS_SOURCE_PATH/.imports";
# Colors and prefixes
DEFAULT="\e[0m";
SUCCESS="\e[0;32mSUCCESS: ";
ERROR="\e[0;31mERROR: ";
if ! [ $(find $CSS_SOURCE_PATH -name '.imports') ]; then
echo -e "${ERROR}Imports file missing.$DEFAULT";
exit;
fi
if ! [ -d $CSS_ASSETS_PATH ]; then
mkdir $CSS_ASSETS_PATH;
fi
RESULT=$(cat "$CSS_SOURCE_PATH/app.css");
SECTION="";
for line in $(cat $IMPORTS_FILE); do
if [ ${line:0:1} = "_" ]; then
if ! [ -d $CSS_SOURCE_PATH/${line:1} ]; then
echo -e "${ERROR}Missing section '$line'$DEFAULT";
exit;
else
SECTION=${line:1};
fi
continue;
fi
if ! [ SECTION = "" ]; then
FILE="$CSS_SOURCE_PATH/$SECTION/$line";
if [ -f $FILE ]; then
RESULT+=$(cat $FILE);
else
echo -e "${ERROR}Missing file '$FILE' ($SECTION).$DEFAULT";
fi
fi
done
echo $RESULT > $CSS_DEST_FILE;
echo -e "${SUCCESS}Compiled assets.${DEFAULT}";