From 8548bd4ce3c0fcec1cfeca8ba4431b3aed764bf9 Mon Sep 17 00:00:00 2001 From: Spirit Date: Mon, 26 Aug 2024 17:17:44 +0300 Subject: [PATCH] accept an arguement as an html path --- html-minify.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/html-minify.sh b/html-minify.sh index bdc5f30..e5927de 100755 --- a/html-minify.sh +++ b/html-minify.sh @@ -9,7 +9,14 @@ command -v uglifyjs >/dev/null 2>&1 || { echo "Error: to install missing deps ru command -v cleancss >/dev/null 2>&1 || { echo "Error: to install missing deps run: npm i -g html-minifier uglify-js cleancss svgo" >&2; exit 1; } command -v svgo >/dev/null 2>&1 || { echo "Error: to install missing deps run: npm i -g html-minifier uglify-js cleancss svgo" >&2; exit 1; } -html_file=index.html +if [[ $# -eq 0 ]]; then + html_file=index.html +else + html_file="$1" + dir=$PWD + cd $(dirname $html_file) + html_file=$(basename $html_file) +fi if [[ -f "$html_file" ]]; then awk ' @@ -65,6 +72,6 @@ if [[ -f "$html_file" ]]; then echo generated "min.${html_file}" fi - # Clean up generated files rm min.*.js min.*.css min.*.svg "${html_file}.tmp" +cd $dir