#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo "\n🤖 [ precommit hook ] linting before committing..."


# If errors, make it clear they cannot commit
if ! lint_outcome=$( cd app && npm run lint ); then
    echo "🚨 [ precommit hook ] lint encountered blocking issues, fix them before committing\n"
    echo "$lint_outcome"
    exit 1
fi

# If warnings, suggest they fix them
if echo $lint_outcome | grep -q "warning"; then
    echo "⚠️ [ precommit hook ] lint encountered warnings, consider fixing them before pushing\n"
    echo "$lint_outcome"
    exit 0
fi

echo "✅ [ precommit hook ] lint encountered no blocking issues\n"
