From: Nicolas Boisselier Date: Tue, 8 Oct 2024 21:41:10 +0000 (+0200) Subject: bin/nb-install X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=b5dc933c7c171dd9aa20bdf8857f85fa167dac6f;p=nb.git bin/nb-install --- diff --git a/.githooks/pre-commit b/.githooks/pre-commit index 6e538657..a6f74760 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -8,42 +8,39 @@ echo "Run $0" -which minify > /dev/null || exit -MINIFY="" -[ -z "$MINIFY" ] && minify --help 2>&1| grep -q '\-\-css' && MINIFY="ext" -[ -z "$MINIFY" ] && minify --help 2>&1| grep -q '\-\-output' && MINIFY="out" -[ -n "$MINIFY" ] || exit -#git status --porcelain|sed -E 's/^ *(\?\?|[A-Z]) +//' -#exec echo BYE - -git status --porcelain|sed -E 's/^ *(\?\?|[A-Z]) +//' | while read file; do - ext="" - case "$file" in - *.min.*) continue ;; - *.css) ext=css ;; - *.js) ext=js ;; - *) continue; - esac - min="$(echo "$file" | sed -E 's/\.([^\.]+)$/.min.\1/')" - [ -w "$min" ] || continue - - echo " Minify $file" - - if [ "$MINIFY" = "ext" ]; then - #echo "minify --$ext < "$file" > "$min.tmp"" - minify --$ext < "$file" > "$min.tmp" - elif [ "$MINIFY" = "out" ]; then - #echo "minify "$file" --output "$min.tmp"" - minify "$file" --output "$min.tmp" > /dev/null - fi - - if [ "$?" = "0" ]; then - #echo "cat "$min.tmp" > "$min"" - cat "$min.tmp" > "$min" - fi - - rm "$min.tmp" - -done +if which minify > /dev/null; then + MINIFY="" + [ -z "$MINIFY" ] && minify --help | grep -q '\-\-css' && MINIFY="ext" + [ -z "$MINIFY" ] && minify --help | grep -q '\-\-output' && MINIFY="out" + [ -z "$MINIFY" ] || git status --porcelain | sed 's/^ . //' | while read file; do + ext="" + case "$file" in + *.min.*) continue ;; + *.css) ext=css ;; + *.js) ext=js ;; + *) continue; + esac + min="$(echo "$file" | sed -E 's/\.([^\.]+)$/.min.\1/')" + [ -w "$min" ] || continue + + echo " Minify $file" + + if [ "$MINIFY" = "ext" ]; then + #echo "minify --$ext < "$file" > "$min.tmp"" + minify --$ext < "$file" > "$min.tmp" + elif [ "$MINIFY" = "out" ]; then + #echo "minify "$file" --output "$min.tmp"" + minify "$file" --output "$min.tmp" > /dev/null + fi + + if [ "$?" = "0" ]; then + #echo "cat "$min.tmp" > "$min"" + cat "$min.tmp" > "$min" + fi + + rm "$min.tmp" + + done +fi true diff --git a/bin/git-setup-hooks.sh b/bin/git-setup-hooks.sh index f734f39d..8debd5cf 100755 --- a/bin/git-setup-hooks.sh +++ b/bin/git-setup-hooks.sh @@ -17,7 +17,8 @@ for hook in "$HOOKS_DIR"/*; do [ -e "$GIT_HOOKS_DIR/$hook_name" ] && stat --format '%N' "$GIT_HOOKS_DIR/$hook_name" \ | grep -q "\-> '$HOOKS_DIR/$hook_name'$" \ && continue - echo " Installing Git hook $hook_name" + echo "Installing Git hook $hook_name" + printf ' ' ln -sf "$HOOKS_DIR/$hook_name" "$GIT_HOOKS_DIR/$hook_name" done # NB 08.10.24 else diff --git a/bin/nb-install b/bin/nb-install index 218b8ec8..4a7bb125 100755 --- a/bin/nb-install +++ b/bin/nb-install @@ -108,12 +108,12 @@ main() { # # Git hooks # - cd "$NB_ROOT" || exit - - if [ -w .git/hooks -a -r etc/git/hooks/pre-commit ]; then - fdiff etc/git/hooks/pre-commit .git/hooks/pre-commit >/dev/null 2>&1 \ - && cp -va etc/git/hooks/pre-commit .git/hooks/ - fi + # NB 08.10.24 Done by bin/git-setup-hooks.sh + # NB 08.10.24 cd "$NB_ROOT" || exit + # NB 08.10.24 if [ -w .git/hooks -a -r etc/git/hooks/pre-commit ]; then + # NB 08.10.24 fdiff etc/git/hooks/pre-commit .git/hooks/pre-commit >/dev/null 2>&1 \ + # NB 08.10.24 && cp -va etc/git/hooks/pre-commit .git/hooks/ + # NB 08.10.24 fi ############################################################################## #