-
Notifications
You must be signed in to change notification settings - Fork 1
/
less-compile.sh
executable file
·44 lines (36 loc) · 953 Bytes
/
less-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
echo "Usage: bash less-compile.sh [lessDir [cssDir [mainFile [rootPath]]]]"
echo "This shell script will watch the changes of the .less files, and compile them into .css files."
echo "When you finish, press ^C to exit."
echo ""
lessDir="./css-less"
cssDir="./css"
mainFile="index.less"
rootPath="./"
if [ -n "$1" ]
then
lessDir="$1"
fi
if [ -n "$2" ]
then
cssDir="$2"
fi
if [ -n "$3" ]
then
mainFile="$3"
fi
if [ -n "$4" ]
then
rootPath="$4"
fi
echo -e "[LESS directiory]\n$(realpath "$lessDir")\n"
echo -e "[CSS directory]\n$(realpath "$cssDir")\n"
echo -e "[Main file]\n$(realpath "$mainFile")\n"
echo -e "[Root path]\n$(realpath "$rootPath")\n"
read -p "Continue? (y/n): " -r reply
# See: https://thoughtbot.com/blog/the-unix-shells-humble-if
if test $reply != "Y" && test $reply != "y"
then
echo -e "Abort."
exit
fi
npx less-watch-compiler "$lessDir" "$cssDir" --main-file "$mainFile" --less-args rootpath="$rootPath",rewrite-urls=all