#!/bin/sh
# Libraryan wrapper: run our check, then chain to pre-existing hooks.
here=$(cd "$(dirname "$0")" && pwd)
bin="$here/../bin/libraryan"
"$bin" postcommit || true
name=post-commit
extra=$("$bin" chainpath 2>/dev/null)
common=$(git rev-parse --git-common-dir)
for h in "$common/hooks/$name" "${extra:+$extra/$name}"; do
  if [ -n "$h" ] && [ -f "$h" ] && [ -x "$h" ]; then
    "$h" "$@" || { [ "$name" = post-commit ] || exit 1; }
  fi
done
exit 0
