yait

Yet Another Init Tool
Log | Files | Refs | README | LICENSE

pre-commit (465B)


      1 #!/bin/sh
      2 #
      3 # Run pre-commit checks on bin/yait. Requires `shellcheck` and a POSIX
      4 # shell (duh).
      5 
      6 me=$(basename "$0")
      7 
      8 fmt() {
      9     echo "${me}[$$]: $*"
     10 }
     11 
     12 script_path="./bin/yait"
     13 
     14 if git diff --cached --name-only | grep -q "$script_path"; then
     15     if shellcheck --enable=all --shell=sh "$script_path"; then
     16         fmt "All tests passed."
     17         exit 0
     18     else
     19         fmt "Syntax errors found in $script_path. Commit aborted."
     20         exit 1
     21     fi
     22 fi
     23 
     24 exit 0