docker-php-extension-installer/scripts/lint
2020-01-23 15:01:25 +01:00

31 lines
717 B
Bash
Executable File

#!/bin/sh
set -o errexit
set -o nounset
SRC_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && cd .. && pwd)"
cd "$SRC_DIR"
rc=0
echo '# Linting shell scripts'
if ! docker --version >/dev/null 2>/dev/null; then
echo 'Docker is not installed, or it is not running.' >&2
rc=1
elif ! docker run --rm -v "$SRC_DIR:/src" -w /src --entrypoint /src/scripts/invoke-shfmt mvdan/shfmt:v3.0.1 fix; then
echo 'ERROR!' >&2
rc=1
fi
echo '# Linting PHP files'
if ! composer --version >/dev/null 2>/dev/null; then
echo 'Composer is not installed.' >&2
elif ! test -f ./vendor/autoload.php; then
echo 'Composer dependencies are not installed.' >&2
rc=1
elif ! composer run-script lint; then
echo 'ERROR!' >&2
rc=1
fi
exit $rc