mirror of
https://github.com/eth-p/bat-extras.git
synced 2024-12-13 17:50:56 +01:00
Add unimplemented extra minification
This commit is contained in:
parent
93843cd067
commit
2a8de58809
21
build.sh
21
build.sh
@ -88,7 +88,7 @@ step_preprocess() {
|
|||||||
echo "# --- BEGIN LIBRARY FILE: ${BASH_REMATCH[1]} ---"
|
echo "# --- BEGIN LIBRARY FILE: ${BASH_REMATCH[1]} ---"
|
||||||
cat "$LIB/${BASH_REMATCH[1]}" | {
|
cat "$LIB/${BASH_REMATCH[1]}" | {
|
||||||
if [[ "$OPT_MINIFY" = "lib" ]]; then
|
if [[ "$OPT_MINIFY" = "lib" ]]; then
|
||||||
pp_strip_comments | pp_minify
|
pp_strip_comments | pp_minify | pp_minify_unsafe
|
||||||
else
|
else
|
||||||
cat
|
cat
|
||||||
fi
|
fi
|
||||||
@ -111,7 +111,7 @@ step_preprocess() {
|
|||||||
# Output:
|
# Output:
|
||||||
# The minified file contents.
|
# The minified file contents.
|
||||||
step_minify() {
|
step_minify() {
|
||||||
if [[ "$OPT_MINIFY" != "all" ]]; then
|
if [[ "$OPT_MINIFY" =~ ^all($|+.*) ]]; then
|
||||||
smsg "Minifying" "SKIP"
|
smsg "Minifying" "SKIP"
|
||||||
cat
|
cat
|
||||||
return 0
|
return 0
|
||||||
@ -119,7 +119,7 @@ step_minify() {
|
|||||||
|
|
||||||
smsg "Minifying"
|
smsg "Minifying"
|
||||||
printf "#!/usr/bin/env bash\n"
|
printf "#!/usr/bin/env bash\n"
|
||||||
pp_minify
|
pp_minify | pp_minify_unsafe
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build step: write
|
# Build step: write
|
||||||
@ -172,11 +172,24 @@ pp_strip_comments() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Minify a Bash source file.
|
# Minify a Bash source file.
|
||||||
# https://github.com/precious/bash_minifier
|
# https://github.com/mvdan/sh
|
||||||
pp_minify() {
|
pp_minify() {
|
||||||
shfmt -mn
|
shfmt -mn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Minifies the output script (unsafely).
|
||||||
|
# Right now, this doesn't do anything.
|
||||||
|
# This should be applied after shfmt minification.
|
||||||
|
pp_minify_unsafe() {
|
||||||
|
if ! [[ "$OPT_MINIFY" =~ ^.*+unsafe(+.*)*$ ]]; then
|
||||||
|
cat
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat
|
||||||
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Options.
|
# Options.
|
||||||
OPT_INSTALL=false
|
OPT_INSTALL=false
|
||||||
|
Loading…
Reference in New Issue
Block a user