
hook=$(basename "${0}")

# @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:$hook" 1> /dev/null 2>&1 || exit 0

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