Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Issue #37 [BUG] Dry run reporting unpretty files when all files match styles #46

Merged
merged 11 commits into from
Apr 10, 2021
Merged
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).

| Parameter | Required | Default | Description |
| - | :-: | :-: | - |
| dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. |
| dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check |
| prettier_version | :x: | `false` | Specific prettier version (by default use latest) |
| prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) |
| commit_options | :x: | - | Custom git commit options |
Expand Down
13 changes: 9 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,20 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then
npm install --silent --global $INPUT_PRETTIER_PLUGINS
fi

echo "Prettifing files..."
PRETTIER_RESULT=0
echo "Prettifying files..."
echo "Files:"
prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"
prettier $INPUT_PRETTIER_OPTIONS || { PRETTIER_RESULT=$?; echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS"; }

# To keep runtime good, just continue if something was changed
if _git_changed; then
if $INPUT_DRY; then
echo "Prettier found unpretty files!"
exit 1
if [ "$PRETTIER_RESULT" -eq 1 ]; then
echo "Prettier found unpretty files!"
exit 1
else
echo "No unpretty files! Finishing dry-run."
fi
else
# Calling method to configure the git environemnt
_git_setup
Expand Down