Add WORKSPACE to the things checked by buildifier. (#79)

Move the find args into a shell variable to simplify things.
This commit is contained in:
Thomas Van Lenten 2018-11-27 07:55:22 -05:00 committed by GitHub
parent 5b8a8d3e31
commit d9cd300c64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -27,17 +27,29 @@ fi
if [[ -n "${BUILDIFER:-}" ]]; then
FOUND_ISSUES="no"
# buildifier supports BUILD/WORKSPACE/*.bzl files, this provides the args
# to reuse in all the finds.
FIND_ARGS=(
\(
-name BUILD
-o
-name WORKSPACE
-o
-name "*.bzl"
\)
)
# Check for format issues?
if [[ "${FORMAT:-yes}" == "yes" ]] ; then
# bazelbuild/buildtools/issues/220 - diff doesn't include the file that needs updating
if ! find . \( -name BUILD -o -name "*.bzl" \) -print | xargs buildifier -d > /dev/null 2>&1 ; then
if ! find . "${FIND_ARGS[@]}" -print | xargs buildifier -d > /dev/null 2>&1 ; then
if [[ "${FOUND_ISSUES}" != "no" ]] ; then
echo ""
fi
echo "ERROR: BUILD/.bzl file formatting issue(s):"
echo ""
# bazelbuild/buildtools/issues/329 - sed out the exit status lines.
find . \( -name BUILD -o -name "*.bzl" \) -print -exec buildifier -v -d {} \; \
find . "${FIND_ARGS[@]}" -print -exec buildifier -v -d {} \; \
2>&1 | sed -E -e '/^exit status 1$/d'
echo ""
echo "Please download the latest buildifier"
@ -49,7 +61,7 @@ if [[ -n "${BUILDIFER:-}" ]]; then
# Check for lint issues?
if [[ "${LINT:-yes}" == "yes" ]] ; then
LINT_ISSUES=$(find . \( -name BUILD -o -name "*.bzl" \) -print | xargs buildifier --lint=warn 2>&1)
LINT_ISSUES=$(find . "${FIND_ARGS[@]}" -print | xargs buildifier --lint=warn 2>&1)
if [[ -n "${LINT_ISSUES}" ]] ; then
if [[ "${FOUND_ISSUES}" != "no" ]] ; then
echo ""