Bake in support for rustfmt
This commit is contained in:
50
rustfmt.sh
Executable file
50
rustfmt.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -uo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
source "$DIR/_reformat-common.bash"
|
||||
|
||||
log "in rustfmt.sh"
|
||||
|
||||
set -e
|
||||
|
||||
file="$1"
|
||||
|
||||
log what
|
||||
|
||||
pushd "$(dirname "$file")" 2>&1
|
||||
|
||||
if [[ "$WOULD_REFORMAT" = "would_reformat" ]]; then
|
||||
|
||||
log beavis
|
||||
|
||||
set +e
|
||||
out=$(rustfmt --check "$file" 2>&1 >/dev/null)
|
||||
retval="$?"
|
||||
set -e
|
||||
|
||||
log got back retval $retval
|
||||
|
||||
exit "$retval"
|
||||
fi
|
||||
|
||||
if [[ "$WOULD_REFORMAT" = "do_reformat" ]]; then
|
||||
|
||||
log in do reformat mode
|
||||
|
||||
out=$(rustfmt "$file" 2>&1 >/dev/null)
|
||||
retval="$?"
|
||||
|
||||
echo "$out"
|
||||
|
||||
log $out
|
||||
|
||||
exit "$retval"
|
||||
fi
|
||||
|
||||
log are we here now
|
||||
|
||||
exit 255
|
||||
Reference in New Issue
Block a user