diff --git a/README.md b/README.md index 6fb4f6f..965ae9a 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/entrypoint.sh b/entrypoint.sh index b51fd1a..811218a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,9 +55,10 @@ if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then 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"; } # Ignore node modules and other action created files rm -r node_modules/ || echo "No node_modules/ folder." @@ -66,8 +67,12 @@ git reset --hard package-lock.json || rm package-lock.json || echo "No package- # 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