#!/bin/sh FILES=$(git diff --cached --name-only --diff-filter=ACM "*.js" | sed 's| |\\ |g') if [ ! -z "$FILES" ]; then # Prettify all selected files echo "$FILES" | xargs prettier --write if [ $? -ne 0 ]; then exit 1 fi # Add back the modified/prettified files to staging echo "$FILES" | xargs git add fi