title: How to run a script on every commit
body: <p>I want to run a script locally whenever someone in RepoA, makes a commit on a branch</p>
  
  <pre><code>currentBranch=$(git rev-parse --abbrev-ref HEAD)
  
  if [[ $currentBranch = *"my-"* ]]; then
    echo "contains my"
  else
    echo "Hold on there! you need to rename your branch before you commit!
    "
  fi
  </code></pre>
  
  <p>I have this running so far which works, whenever I run <code>npm run test:script</code> it runs > <code>"test:script": "./branchname.sh"</code></p>
  
  <p>however, I have some issues. one how can I run this every time someone commits?</p>
  
  <p>I have tried putting it in my package.json</p>
  
  <pre><code>  "pre-commit": [
      "lint",
      "test:script"
    ],
  </code></pre>
  
  <p>but it doesn't run on <em>every</em> commit</p>
  
  <p>also, how can I get the commit itself to abort if the script fails, i.e. jump into the else block</p>