deploy: clean up code
This commit is contained in:
parent
107f3295d7
commit
c0d40e6f97
@ -19,7 +19,8 @@ die() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
local code="$1"
|
code="$1"
|
||||||
|
[ -z "$code" ] && code=0
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
usage: $PROGNAME [OPTIONS]
|
usage: $PROGNAME [OPTIONS]
|
||||||
|
|
||||||
@ -28,28 +29,17 @@ Options:
|
|||||||
-i input directory
|
-i input directory
|
||||||
-h show this help
|
-h show this help
|
||||||
EOF
|
EOF
|
||||||
exit $code
|
exit "$code"
|
||||||
}
|
}
|
||||||
|
|
||||||
input_args() {
|
input_args() {
|
||||||
[ -z "$1" ] && usage
|
[ -z "$1" ] && usage
|
||||||
|
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
-o)
|
-o) OUTDIR="$2"; shift ;;
|
||||||
OUTDIR="$2"
|
-i) INDIR="$2"; shift ;;
|
||||||
shift
|
-h) usage ;;
|
||||||
;;
|
*) die "unexpected argument: $1" ;;
|
||||||
-i)
|
|
||||||
INDIR="$2"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
-h)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
die "unexpected argument: $1"
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
@ -64,7 +54,6 @@ check_args() {
|
|||||||
error "input directory not specified"
|
error "input directory not specified"
|
||||||
usage 1
|
usage 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ ! -d "$OUTDIR" ]; then
|
if [ ! -d "$OUTDIR" ]; then
|
||||||
mkdir "$OUTDIR"
|
mkdir "$OUTDIR"
|
||||||
else
|
else
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
|
DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
|
||||||
ROOT="$(realpath "$DIR/../")"
|
ROOT="$(realpath "$DIR/../")"
|
||||||
CLEANCSS="$ROOT"/node_modules/clean-css-cli/bin/cleancss
|
CLEANCSS="$ROOT"/node_modules/clean-css-cli/bin/cleancss
|
||||||
. $DIR/build_common.sh
|
. "$DIR/build_common.sh"
|
||||||
|
|
||||||
build_scss() {
|
build_scss() {
|
||||||
local entry_name="$1"
|
entry_name="$1"
|
||||||
local theme="$2"
|
theme="$2"
|
||||||
|
|
||||||
local input="$INDIR/entries/$entry_name/$theme.scss"
|
input="$INDIR/entries/$entry_name/$theme.scss"
|
||||||
local output="$OUTDIR/$entry_name"
|
output="$OUTDIR/$entry_name"
|
||||||
[ "$theme" = "dark" ] && output="${output}_dark"
|
[ "$theme" = "dark" ] && output="${output}_dark"
|
||||||
output="${output}.css"
|
output="${output}.css"
|
||||||
|
|
||||||
@ -18,10 +18,10 @@ build_scss() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleancss() {
|
cleancss() {
|
||||||
local entry_name="$1"
|
entry_name="$1"
|
||||||
local theme="$2"
|
theme="$2"
|
||||||
|
|
||||||
local file="$OUTDIR/$entry_name"
|
file="$OUTDIR/$entry_name"
|
||||||
[ "$theme" = "dark" ] && file="${file}_dark"
|
[ "$theme" = "dark" ] && file="${file}_dark"
|
||||||
file="${file}.css"
|
file="${file}.css"
|
||||||
|
|
||||||
@ -31,9 +31,9 @@ cleancss() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_dark_patch() {
|
create_dark_patch() {
|
||||||
local entry_name="$1"
|
entry_name="$1"
|
||||||
local light_file="$OUTDIR/$entry_name.css"
|
light_file="$OUTDIR/$entry_name.css"
|
||||||
local dark_file="$OUTDIR/${entry_name}_dark.css"
|
dark_file="$OUTDIR/${entry_name}_dark.css"
|
||||||
|
|
||||||
"$DIR"/gen_css_diff.js "$light_file" "$dark_file" > "$dark_file.diff"
|
"$DIR"/gen_css_diff.js "$light_file" "$dark_file" > "$dark_file.diff"
|
||||||
rm "$dark_file"
|
rm "$dark_file"
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
|
DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
|
||||||
. $DIR/build_common.sh
|
. "$DIR/build_common.sh"
|
||||||
|
|
||||||
# suckless version of webpack
|
# suckless version of webpack
|
||||||
# watch and learn, bitches!
|
# watch and learn, bitches!
|
||||||
build_chunk() {
|
build_chunk() {
|
||||||
local name="$1"
|
name="$1"
|
||||||
local output="$OUTDIR/$name.js"
|
output="$OUTDIR/$name.js"
|
||||||
local not_first=0
|
not_first=0
|
||||||
for file in "$INDIR/$name"/*.js; do
|
for file in "$INDIR/$name"/*.js; do
|
||||||
# insert newline before out comment
|
# insert newline before out comment
|
||||||
[ "$not_first" = "1" ] && echo "" >> "$output"
|
[ "$not_first" = "1" ] && echo "" >> "$output"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user