diff --git a/README.md b/README.md index b9d257d..917bb08 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,8 @@ There are three different options for minification: | `--minify=lib` | Embedded library scripts will be minified. [default] | | `--minify=all` | Everything will be minified. | -This uses [bash_minifier](https://github.com/precious/bash_minifier) to perform minification, and requires Python 2 to be installed as either `python2` or `python`. +This uses [shfmt](https://github.com/mvdan/sh) to perform minification. +   diff --git a/build.sh b/build.sh index 791f05c..ca62974 100755 --- a/build.sh +++ b/build.sh @@ -6,7 +6,6 @@ # Issues: https://github.com/eth-p/bat-extras/issues # ----------------------------------------------------------------------------- HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -DL="$HERE/.download" BIN="$HERE/bin" SRC="$HERE/src" LIB="$HERE/lib" @@ -162,13 +161,7 @@ pp_strip_comments() { # Minify a Bash source file. # https://github.com/precious/bash_minifier pp_minify() { - local python="python" - if command -v python2 &>/dev/null; then - python="python2" - fi - - "$python" "$DL/minifier.py" - printf "\n" + shfmt -mn } # ----------------------------------------------------------------------------- @@ -196,14 +189,13 @@ else fi # ----------------------------------------------------------------------------- -# Download resources. +# Check for resources. -[[ -d "$DL" ]] || mkdir "$DL" [[ -d "$BIN" ]] || mkdir "$BIN" -if [[ "$OPT_MINIFY" != "none" ]] && ! [[ -f "$DL/minifier.py" ]]; then - printc "%{YELLOW}Downloading %{BLUE}https://github.com/precious/bash_minifier%{YELLOW}...%{CLEAR}\n" 1>&2 - curl -sL "https://gitcdn.xyz/repo/precious/bash_minifier/master/minifier.py" > "$DL/minifier.py" +if [[ "$OPT_MINIFY" != "none" ]] && ! command -v shfmt &>/dev/null; then + printc "%{RED}Warning: cannot find shfmt. Unable to minify scripts.%{CLEAR}\n" + OPT_MINIFY=none fi # ----------------------------------------------------------------------------- diff --git a/doc/prettybat.md b/doc/prettybat.md index a757d80..adc4df5 100644 --- a/doc/prettybat.md +++ b/doc/prettybat.md @@ -30,6 +30,7 @@ See `man bat` for more information. | YAML | [prettier](https://prettier.io/) | | HTML | [prettier](https://prettier.io/) | | Rust | [rustfmt](https://github.com/rust-lang/rustfmt) | +| Bash | [shfmt](https://github.com/mvdan/sh) |