mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-26 23:11:51 +02:00
Update build.sh to fix output messages
This commit is contained in:
parent
f740dc86d2
commit
8339354189
42
build.sh
42
build.sh
@ -31,27 +31,11 @@ next() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Prints a build step message.
|
# Prints a build step message.
|
||||||
SMSG_CACHE_MSG=()
|
|
||||||
SMSG_CACHE_META=()
|
|
||||||
SMSG_EXPECT=1
|
|
||||||
smsg() {
|
smsg() {
|
||||||
if [[ "$1" != "$SMSG_EXPECT" ]]; then
|
case "$2" in
|
||||||
SMSG_CACHE_MSG["$1"]="$2"
|
"SKIP") printc " %{YELLOW} %{DIM}%s [skipped]%{CLEAR}\n" "$1" 1>&2;;
|
||||||
SMSG_CACHE_META["$1"]="$3"
|
*) printc " %{YELLOW} %s...%{CLEAR}\n" "$1" 1>&2;;
|
||||||
return;
|
|
||||||
fi
|
|
||||||
|
|
||||||
((SMSG_EXPECT++))
|
|
||||||
case "$3" in
|
|
||||||
"SKIP") printc " %{YELLOW} %{DIM}%s [skipped]%{CLEAR}\n" "$2" 1>&2;;
|
|
||||||
*) printc " %{YELLOW} %s...%{CLEAR}\n" "$2" 1>&2;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Cached messages.
|
|
||||||
echo "${SMSG_CACHE_MSG[$SMSG_EXPECT]}" 1>&2
|
|
||||||
if [[ -n "${SMSG_CACHE_MSG[$SMSG_EXPECT]}" ]]; then
|
|
||||||
smsg "$SMSG_EXPECT" "${SMSG_CACHE_MSG[$SMSG_EXPECT]}" "${SMSG_CACHE_META[$SMSG_EXPECT]}"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: read
|
# Build step: read
|
||||||
@ -63,8 +47,8 @@ smsg() {
|
|||||||
# Output:
|
# Output:
|
||||||
# The file contents.
|
# The file contents.
|
||||||
step_read() {
|
step_read() {
|
||||||
smsg 1 "Reading"
|
|
||||||
cat "$1"
|
cat "$1"
|
||||||
|
smsg "Reading"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: preprocess
|
# Build step: preprocess
|
||||||
@ -78,8 +62,6 @@ step_read() {
|
|||||||
# Output:
|
# Output:
|
||||||
# The processed file contents.
|
# The processed file contents.
|
||||||
step_preprocess() {
|
step_preprocess() {
|
||||||
smsg 2 "Preprocessing"
|
|
||||||
|
|
||||||
local line
|
local line
|
||||||
while IFS='' read -r line; do
|
while IFS='' read -r line; do
|
||||||
# Skip certain lines.
|
# Skip certain lines.
|
||||||
@ -115,6 +97,8 @@ step_preprocess() {
|
|||||||
# Forward data.
|
# Forward data.
|
||||||
echo "$line"
|
echo "$line"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
smsg "Preprocessing"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: minify
|
# Build step: minify
|
||||||
@ -127,14 +111,14 @@ step_preprocess() {
|
|||||||
# The minified file contents.
|
# The minified file contents.
|
||||||
step_minify() {
|
step_minify() {
|
||||||
if [[ "$OPT_MINIFY" =~ ^all($|+.*) ]]; then
|
if [[ "$OPT_MINIFY" =~ ^all($|+.*) ]]; then
|
||||||
smsg 3 "Minifying" "SKIP"
|
|
||||||
cat
|
cat
|
||||||
|
smsg "Minifying" "SKIP"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
smsg 3 "Minifying"
|
|
||||||
printf "#!/usr/bin/env bash\n"
|
printf "#!/usr/bin/env bash\n"
|
||||||
pp_minify | pp_minify_unsafe
|
pp_minify | pp_minify_unsafe
|
||||||
|
smsg "Minifying"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: compress
|
# Build step: compress
|
||||||
@ -147,8 +131,8 @@ step_minify() {
|
|||||||
# The compressed self-executable script.
|
# The compressed self-executable script.
|
||||||
step_compress() {
|
step_compress() {
|
||||||
if ! "$OPT_COMPRESS"; then
|
if ! "$OPT_COMPRESS"; then
|
||||||
smsg 4 "Compressing" "SKIP"
|
|
||||||
cat
|
cat
|
||||||
|
smsg "Compressing" "SKIP"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -157,9 +141,9 @@ step_compress() {
|
|||||||
printf "(exec -a \"\$0\" bash -c 'eval \"\$(cat <&3)\"' \"\$0\" \"\$@\" 3< <(dd bs=1 if=\"\$0\" skip=::: 2>/dev/null | gunzip)); exit \$?;\n"
|
printf "(exec -a \"\$0\" bash -c 'eval \"\$(cat <&3)\"' \"\$0\" \"\$@\" 3< <(dd bs=1 if=\"\$0\" skip=::: 2>/dev/null | gunzip)); exit \$?;\n"
|
||||||
})"
|
})"
|
||||||
|
|
||||||
smsg 4 "Compressing"
|
|
||||||
sed "s/:::/$(wc -c <<< "$wrapper" | bc)/" <<< "$wrapper"
|
sed "s/:::/$(wc -c <<< "$wrapper" | bc)/" <<< "$wrapper"
|
||||||
gzip
|
gzip
|
||||||
|
smsg "Compressing"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: write
|
# Build step: write
|
||||||
@ -174,9 +158,9 @@ step_compress() {
|
|||||||
# Output:
|
# Output:
|
||||||
# The file contents.
|
# The file contents.
|
||||||
step_write() {
|
step_write() {
|
||||||
smsg 5 "Building"
|
|
||||||
tee "$1"
|
tee "$1"
|
||||||
chmod +x "$1"
|
chmod +x "$1"
|
||||||
|
smsg "Building"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: write
|
# Build step: write
|
||||||
@ -193,14 +177,14 @@ step_write() {
|
|||||||
|
|
||||||
step_write_install() {
|
step_write_install() {
|
||||||
if [[ "$OPT_INSTALL" != true ]]; then
|
if [[ "$OPT_INSTALL" != true ]]; then
|
||||||
smsg 6 "Installing" "SKIP"
|
|
||||||
cat
|
cat
|
||||||
|
smsg "Installing" "SKIP"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
smsg 6 "Installing"
|
|
||||||
tee "$1"
|
tee "$1"
|
||||||
chmod +x "$1"
|
chmod +x "$1"
|
||||||
|
smsg "Installing"
|
||||||
}
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user