Simplify linting
parent
04989ff86d
commit
e5541c42a5
|
@ -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
|
||||
|
|
|
@ -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
|
19
scripts/lint
19
scripts/lint
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue