-
-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
Milestone
Description
What would be the proper way to abort a bash script if the dotnet CLI tool issues any warnings? I'm going to be formatting files in a CI pipeline during PRs and committing the changes back to the branch, so I do not want the script to move forward if CSharpier returns any warnings during the formatting process.
This is what I came up with initially, but it feels hackish and only works in my regular terminal not my CI pipeline, which seems to still include everything from stdout into the $errors variable, not just warnings and errors.
errors=$(dotnet csharpier . --write-stdout --loglevel Warning 2>&1)
if [ $? -ne 0 ] || [ -n "$errors" ]; then
echo "$errors"
echo "CSharpier formatting failed; aborting."
exit 1
fi
I also tried this to see if any files remained unformatted, but CSharpier still returns exit code 0 with the --check flag when it warns there are files it cannot format.
dotnet csharpier .
dotnet csharpier --check .
if [ $? -ne 0 ]; then
echo "CSharpier formatting failed; aborting."
exit 1
fi
Metadata
Metadata
Assignees
Labels
No labels