Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
review: update the script with --write option
  • Loading branch information
2010YOUY01 committed Dec 11, 2025
commit 573fd6427179ad984a976f0a25139764a5abfdbb
26 changes: 20 additions & 6 deletions ci/scripts/doc_prettier_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,40 @@
# under the License.

SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
echo "$SCRIPT_PATH: Checking document format with prettier"

MODE="--check"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use

./ci/scripts/doc_prettier_check.sh --write

All the time now in my dev workflow 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have auto fixes for other lint violations now

./dev/rust_lint.sh --write --allow-dirty

I haven't used it extensively yet, so there may still be some bugs and potential improvements.

ACTION="Checking"
if [ $# -gt 0 ]; then
if [ "$1" = "--write" ]; then
MODE="--write"
ACTION="Formatting"
else
echo "Usage: $0 [--write]" >&2
exit 1
fi
fi

echo "$SCRIPT_PATH: $ACTION documents with prettier"

# Ensure `npx` is available
if ! command -v npx >/dev/null 2>&1; then
echo "npx is required to run the prettier check. Install Node.js (e.g., brew install node) and re-run." >&2
exit 1
fi

# if you encounter error, change '--check' to '--write' in the below command, and
# commit the change.
#
# Ignore subproject CHANGELOG.md because it is machine generated
npx [email protected] --check \
npx [email protected] $MODE \
'{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' \
'!datafusion/CHANGELOG.md' \
README.md \
CONTRIBUTING.md
status=$?

if [ $status -ne 0 ]; then
echo "Prettier check failed. To fix, rerun `prettier` with --write (change --check to --write in the script), commit the formatted files, and re-run the check." >&2
if [ "$MODE" = "--check" ]; then
echo "Prettier check failed. Re-run with --write (e.g., ./ci/scripts/doc_prettier_check.sh --write) to format files, commit the changes, and re-run the check." >&2
else
echo "Prettier format failed. Files may have been modified; commit any changes and re-run." >&2
fi
exit $status
fi