#!/bin/sh

# Exit immediately if a pipeline returns non-zero status
# http://www.gnu.org/software/bash/manual/bashref.html#The-Set-Builtin
set -e

LIST="."

if [ -n "$npm_config_staged" ]; then
  LIST=`git diff --cached --name-only | grep -E '\\.(js|json)$'`
fi

FIX=""
if [ -n "$npm_config_fix" ]; then
  FIX="--fix"
fi

if [ "$LIST" ]; then eslint $FIX $LIST; fi
