Updated documentation and added new prettybat formatter

This commit is contained in:
Ethan P 2019-06-21 16:19:31 -07:00
parent 5f248064e0
commit 0b04dfa5f4
No known key found for this signature in database
GPG Key ID: 1F8DF8091CD46FBC
3 changed files with 8 additions and 14 deletions

View File

@ -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.
 

View File

@ -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
# -----------------------------------------------------------------------------

View File

@ -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) |