From b40e4ba1c813c997fcea24414d52d49af2629b2c Mon Sep 17 00:00:00 2001 From: Fabricio Sander Date: Thu, 25 Mar 2021 19:48:04 -0300 Subject: [PATCH] fix(issue-37): adds logic to handle prettier cmd output to shell dry-run exit --- entrypoint.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 023e697..2b53342 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -52,12 +52,21 @@ fi echo "Prettifing files..." echo "Files:" prettier $INPUT_PRETTIER_OPTIONS || echo "Problem running prettier with $INPUT_PRETTIER_OPTIONS" +PRETTIER_RESULT=$? + +# Ignore node modules and other action created files +rm -r node_modules/ || echo "No node_modules/ folder." +git reset --hard package-lock.json || rm package-lock.json || echo "No package-lock.json file." # 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