From 5cf3fd931eea6f04b9f59c97e30da443bf05f91c Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Tue, 17 Oct 2023 10:21:00 +0200 Subject: [PATCH] prettify scripts --- scripts/check.sh | 46 +++++++++++++++++++++++++++++----------- scripts/check_formats.sh | 11 ---------- scripts/format.sh | 35 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 23 deletions(-) delete mode 100755 scripts/check_formats.sh create mode 100755 scripts/format.sh diff --git a/scripts/check.sh b/scripts/check.sh index 253fe8447..ac155b5e7 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -1,17 +1,39 @@ #!/bin/bash -echo ------ cargo check -cargo c --all-features +set -o errexit +set -o nounset +set -o pipefail -echo ------ cargo clippy -cargo clippy --all-features -cargo clippy --tests +function rust() { + cargo fmt --check + cargo sort -c -w + cargo clippy --all-features --tests + cargo test +} -echo ------ cargo test -cargo t +function node() { + pnpm lint + pnpm check +} -echo ------ cargo fmt -cargo fmt --check - -echo ------ cargo sort -cargo sort -c -w +if [[ "$#" -eq 0 ]]; then + set -o xtrace + rust + node +else + case "$1" in + rust) + set -o xtrace + rust + ;; + node) + set -o xtrace + node + ;; + *) + echo "Invalid argument: $1" + exit 1 + ;; + esac + exit 0 +fi diff --git a/scripts/check_formats.sh b/scripts/check_formats.sh deleted file mode 100755 index b1e1a52c8..000000000 --- a/scripts/check_formats.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# Run pnpm format -pnpm format - -# Change directory to src-tauri -cd src-tauri - -# Run cargo fmt -cargo fmt - diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 000000000..464cdd705 --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +function rust() { + cargo fmt +} + +function node() { + pnpm format +} + +if [[ "$#" -eq 0 ]]; then + set -o xtrace + rust + node +else + case "$1" in + rust) + set -o xtrace + rust + ;; + node) + set -o xtrace + node + ;; + *) + echo "Invalid argument: $1" + exit 1 + ;; + esac + exit 0 +fi