deploy: clean up code

This commit is contained in:
E. S 2025-04-28 14:53:59 +03:00
parent 107f3295d7
commit c0d40e6f97
3 changed files with 22 additions and 33 deletions

View File

@ -19,7 +19,8 @@ die() {
}
usage() {
local code="$1"
code="$1"
[ -z "$code" ] && code=0
cat <<EOF
usage: $PROGNAME [OPTIONS]
@ -28,28 +29,17 @@ Options:
-i input directory
-h show this help
EOF
exit $code
exit "$code"
}
input_args() {
[ -z "$1" ] && usage
while [ $# -gt 0 ]; do
case $1 in
-o)
OUTDIR="$2"
shift
;;
-i)
INDIR="$2"
shift
;;
-h)
usage
;;
*)
die "unexpected argument: $1"
;;
-o) OUTDIR="$2"; shift ;;
-i) INDIR="$2"; shift ;;
-h) usage ;;
*) die "unexpected argument: $1" ;;
esac
shift
done
@ -64,7 +54,6 @@ check_args() {
error "input directory not specified"
usage 1
}
if [ ! -d "$OUTDIR" ]; then
mkdir "$OUTDIR"
else

View File

@ -3,14 +3,14 @@
DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
ROOT="$(realpath "$DIR/../")"
CLEANCSS="$ROOT"/node_modules/clean-css-cli/bin/cleancss
. $DIR/build_common.sh
. "$DIR/build_common.sh"
build_scss() {
local entry_name="$1"
local theme="$2"
entry_name="$1"
theme="$2"
local input="$INDIR/entries/$entry_name/$theme.scss"
local output="$OUTDIR/$entry_name"
input="$INDIR/entries/$entry_name/$theme.scss"
output="$OUTDIR/$entry_name"
[ "$theme" = "dark" ] && output="${output}_dark"
output="${output}.css"
@ -18,10 +18,10 @@ build_scss() {
}
cleancss() {
local entry_name="$1"
local theme="$2"
entry_name="$1"
theme="$2"
local file="$OUTDIR/$entry_name"
file="$OUTDIR/$entry_name"
[ "$theme" = "dark" ] && file="${file}_dark"
file="${file}.css"
@ -31,9 +31,9 @@ cleancss() {
}
create_dark_patch() {
local entry_name="$1"
local light_file="$OUTDIR/$entry_name.css"
local dark_file="$OUTDIR/${entry_name}_dark.css"
entry_name="$1"
light_file="$OUTDIR/$entry_name.css"
dark_file="$OUTDIR/${entry_name}_dark.css"
"$DIR"/gen_css_diff.js "$light_file" "$dark_file" > "$dark_file.diff"
rm "$dark_file"

View File

@ -1,14 +1,14 @@
#!/bin/sh
DIR=$(cd "$(dirname "$(readlink -f "$0")")" && pwd)
. $DIR/build_common.sh
. "$DIR/build_common.sh"
# suckless version of webpack
# watch and learn, bitches!
build_chunk() {
local name="$1"
local output="$OUTDIR/$name.js"
local not_first=0
name="$1"
output="$OUTDIR/$name.js"
not_first=0
for file in "$INDIR/$name"/*.js; do
# insert newline before out comment
[ "$not_first" = "1" ] && echo "" >> "$output"