Simplify linting

pull/79/head
Michele Locati 2019-12-20 18:44:45 +01:00
parent 04989ff86d
commit e5541c42a5
No known key found for this signature in database
GPG Key ID: 98B7CE2E7234E28B
4 changed files with 36 additions and 27 deletions

View File

@ -24,7 +24,7 @@ jobs:
language: go
go: '1.13'
before_script: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt
script: shfmt -d -s -ln posix -i 0 -ci -kp install-php-extensions scripts/common scripts/lint scripts/travisci-test-extensions scripts/travisci-update-readme scripts/update-readme
script: ./scripts/invoke-shfmt check
- <<: *test-extensions-job-template
name: Test extensions on Alpine 3.7

28
scripts/invoke-shfmt Executable file
View File

@ -0,0 +1,28 @@
#!/bin/sh
set -o errexit
set -o nounset
PARAMS='-s -ln posix -i 0 -ci -kp'
case "${1:-}" in
check)
PARAMS="$PARAMS -d"
;;
fix)
PARAMS="$PARAMS -w"
;;
*)
fprintf 'Syntax: %s <check|fix>' "$0" >&2
exit 1
;;
esac
shfmt $PARAMS \
install-php-extensions \
scripts/common \
scripts/invoke-shfmt \
scripts/lint \
scripts/travisci-test-extensions \
scripts/travisci-update-readme \
scripts/update-readme

View File

@ -8,23 +8,14 @@ if ! docker --version >/dev/null 2>/dev/null; then
exit 1
fi
#SRC_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && cd .. pwd)"
SRC_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && cd .. pwd)"
if ! docker build -t docker-php-extension-installer-shfmt:latest -f scripts/Dockerfile-shfmt -q .; then
printf 'ERROR!' >&2
exit 1
fi
fix() {
printf 'Fixing %s... ' "$1"
if docker run --rm -v "$SRC_DIR:/src" -w /src docker-php-extension-installer-shfmt:latest shfmt -s -ln posix -i 0 -ci -kp -w "$1"; then
printf 'done.\n'
fi
}
fix install-php-extensions
fix scripts/common
fix scripts/lint
fix scripts/travisci-test-extensions
fix scripts/travisci-update-readme
fix scripts/update-readme
if ! docker run --rm -v "$SRC_DIR:/src" -w /src docker-php-extension-installer-shfmt:latest ./scripts/invoke-shfmt fix; then
printf 'ERROR!' >&2
exit 1
fi

View File

@ -11,12 +11,8 @@ set SRC_DIR=%CD%
docker build -t docker-php-extension-installer-shfmt:latest -f scripts\Dockerfile-shfmt -q .
if errorlevel 1 goto :err
call :fix install-php-extensions
call :fix scripts/common
call :fix scripts/lint
call :fix scripts/travisci-test-extensions
call :fix scripts/travisci-update-readme
call :fix scripts/update-readme
docker run --rm -v "%SRC_DIR%:/src" -w /src docker-php-extension-installer-shfmt:latest ./scripts/invoke-shfmt fix
if errorlevel 1 goto :err
goto :eof
:no-docker
@ -26,9 +22,3 @@ goto :eof
:err
echo ERROR! >&2
goto :eof
:fix
echo|set /p="Fixing %1... "
docker run --rm -v "%SRC_DIR%:/src" -w /src docker-php-extension-installer-shfmt:latest shfmt -s -ln posix -i 0 -ci -kp -w %1
if not errorlevel 1 echo done.
exit /b 0