#!/usr/bin/env sh

# immediate exit after an error
set -e

testing() {
    echo
    echo "πŸ”Ž Checking ${1}"
}

testing 'JS & CSS 🎨'
yarn check
yarn lint

testing 'PHP βš™οΈ'
composer validate
composer phpcs
composer phpstan
./vendor/bin/phpunit

testing 'translations πŸ—ΊοΈ'
find resources/lang -type f -name '*.po' -exec sh -c 'msgfmt "${1%.*}.po" -o"${1%.*}.mo"' shell {} \;
[ "$(find resources/lang -type f -name '*.po' | wc -l)" -eq "$(find resources/lang -type f -name '*.mo' | wc -l)" ]
find resources/lang -type f -name '*.mo' -exec rm {} \;

echo 'βœ… Done πŸŽ‰'