cargo-check.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env sh
  2. # Copyright 2019-2022 Tauri Programme within The Commons Conservancy
  3. # SPDX-License-Identifier: Apache-2.0
  4. # SPDX-License-Identifier: MIT
  5. # note: you can pass in the cargo sub-commands used to check manually.
  6. # allowed commands: check, clippy, fmt, test
  7. # default: clippy, fmt, test
  8. # exit the script early if any of the commands return an error
  9. set -e
  10. # set the script arguments if none are found
  11. if [ -z "$*" ]; then
  12. set -- "clippy" "fmt" "test"
  13. fi
  14. # run n+1 times, where n is the amount of mutually exclusive features.
  15. # the extra run is for all the crates without mutually exclusive features.
  16. # as many features as possible are enabled at for each command
  17. run() {
  18. command=$1
  19. shift 1
  20. cargo "$command" --workspace --all-targets --all-features "$@"
  21. }
  22. for command in "$@"; do
  23. case "$command" in
  24. check | test)
  25. run "$command"
  26. ;;
  27. clippy)
  28. run clippy -- -D warnings
  29. ;;
  30. fmt)
  31. echo "[$command] checking formatting"
  32. cargo +nightly fmt -- --check
  33. ;;
  34. *)
  35. echo "[cargo-check.sh] Unknown cargo sub-command: $command"
  36. exit 1
  37. ;;
  38. esac
  39. done