Skip to content

Commit

Permalink
Merge pull request #148 from tsuyoshicho/fix/exitcode-20210515
Browse files Browse the repository at this point in the history
fix: script for exit code
  • Loading branch information
tsuyoshicho authored May 16, 2021
2 parents 48c920f + 981f682 commit ef35b55
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions script.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# shellcheck disable=SC2086,SC2089,SC2090

Expand Down Expand Up @@ -31,19 +31,25 @@ export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"


echo '::group:: Running textlint with reviewdog 🐶 ...'
textlint_exit_val="0"
reviewdog_exit_val="0"

# shellcheck disable=SC2086
textlint_check_output=$(npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS}" 2>&1) \
|| textlint_exit_val="$?"

# shellcheck disable=SC2086
npx textlint -f checkstyle "${INPUT_TEXTLINT_FLAGS}" \
| reviewdog -f=checkstyle \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-review}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
echo "${textlint_check_output}" | reviewdog -f=checkstyle \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER:-github-pr-review}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS} || reviewdog_exit_val="$?"
echo '::endgroup::'

# github-pr-review only diff adding
if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then
if [[ "${INPUT_REPORTER}" == "github-pr-review" ]]; then
echo '::group:: Running textlint fixing report 🐶 ...'
# fix
npx textlint --fix "${INPUT_TEXTLINT_FLAGS:-.}" || true
Expand All @@ -66,4 +72,12 @@ if [ "${INPUT_REPORTER}" = "github-pr-review" ]; then
echo '::endgroup::'
fi

# Throw error if an error occurred and fail_on_error is true
if [[ "${INPUT_FAIL_ON_ERROR}" == "true" \
&& ( "${textlint_exit_val}" != "0" \
|| "${reviewdog_exit_val}" != "0" ) \
]]; then
exit 1
fi

# EOF

0 comments on commit ef35b55

Please sign in to comment.