#!/usr/bin/env sh

RED='\033[0;31m'
YELLOW='\033[0;33m'
BOLD='\033[1m'
NC='\033[0m'

if ! npx --no -- commitlint --quiet --edit "$1" > /dev/null 2>&1; then
	if [ -t 1 ]; then
		printf "\n${RED}${BOLD}✖ Invalid commit message${NC}\n"
		printf "${YELLOW}Use Conventional Commits format:${NC} ${BOLD}type(scope): description${NC}\n\n"
	else
		printf "\n✖ Invalid commit message\n"
		printf "Use Conventional Commits format: type(scope): description\n\n"
	fi
	exit 1
fi
