diff --git a/scripts/rust_pre_commit.sh b/scripts/rust_pre_commit.sh index dad8ef50c..537bfdc9e 100755 --- a/scripts/rust_pre_commit.sh +++ b/scripts/rust_pre_commit.sh @@ -1,21 +1,21 @@ #!/usr/bin/env bash set -e # shellcheck source=/dev/null -source "$HOME"/.cargo/env +[[ -r "$HOME"/.cargo/env ]] && source "$HOME"/.cargo/env PATHS="services/commtest" -cargo > /dev/null +command -v cargo > /dev/null -for PATH in $PATHS; do - pushd "$PATH" - echo "formatting $PATH..." +for directory in $PATHS; do + pushd "$directory" + echo "formatting ${directory}..." cargo fmt --all -- --check - echo "checking $PATH..." + echo "checking ${directory}..." cargo check - popd # $PATH + popd # $directory done echo "done formatting"