#!/bin/sh
# pre-commit -- quietly type-check before committing.
#
# Installed by `make prepare` / `npm run hooks`, which points
# core.hooksPath at .githooks/.
#
#   git commit --no-verify     skip once
#   SKIP_PRECOMMIT=1 ...       skip (for scripted commits)

set -u

[ "${SKIP_PRECOMMIT:-}" = "" ] || exit 0

hook_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) || exit 1
. "$hook_dir/_quiet"

cd "$(git rev-parse --show-toplevel)" || exit 1

hook_action="commit"
hook_skip_hint="'git commit --no-verify' or SKIP_PRECOMMIT=1"
quiet_run "npm run tslint" npm run tslint
