#!/usr/bin/env bash

# @todo Better detection for executables: php, composer.phar and robo.
robo="$(composer config 'bin-dir')/robo"

# Exit without error if "robo" doesn't exists or it has no corresponding task.
test -x "$robo" || exit 0
"$robo" help "githook:$cghHookName" 1> /dev/null 2>&1 || exit 0

if [ "$cghHasInput" = 'true' ]; then
    "$robo" "githook:$cghHookName" $@ <<< $(</dev/stdin) || exit $?
else
    "$robo" "githook:$cghHookName" $@ || exit $?
fi

exit 0
