From fa1f186729e6cf1d1c161c3346c38826411dd524 Mon Sep 17 00:00:00 2001 From: David Cornu Date: Thu, 8 Feb 2024 12:30:12 -0500 Subject: [PATCH] Check the `stylelint` exit code before proceeding --- script.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/script.sh b/script.sh index b80ebc4..fa33b45 100755 --- a/script.sh +++ b/script.sh @@ -51,6 +51,17 @@ echo "stylelint version: $(npx --no-install -c 'stylelint --version')" echo '::group:: Running stylelint with reviewdog 🐶 ...' stylelint_results=$(__run_stylelint) + +# stylelint exit codes are documented here: +# https://stylelint.io/user-guide/cli/#exit-codes +stylelint_rc=$? +if [ $stylelint_rc -ne 0 ] && [ $stylelint_rc -ne 2 ]; then + echo 'stylelint failed' + echo "${stylelint_results}" + echo '::endgroup::' + exit $stylelint_rc +fi + echo "${stylelint_results}" | __run_reviewdog reviewdog_rc=$?