Skip to content

Commit

Permalink
Merge pull request #2626 from IntersectMBO/command_vs_type
Browse files Browse the repository at this point in the history
refactor: replace `type` with `command -v` for checks
  • Loading branch information
mkoura committed Sep 17, 2024
2 parents 4328eee + 4c1afec commit 1f50ffd
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/cli_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
tests_repo="$(readlink -m "${0%/*}/..")"

get_coverage() {
if [ ! -e "$tests_repo/.cli_coverage" ] || ! hash cardano-cli; then
if [ ! -e "$tests_repo/.cli_coverage" ] || ! command -v cardano-cli >/dev/null 2>&1; then
return 1
fi
oldpwd="$PWD"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ init_lint:
.PHONY: lint
lint:
pre-commit run -a
if type pytype >/dev/null 2>&1; then pytype cardano_node_tests; fi
if command -v pytype >/dev/null 2>&1; then pytype cardano_node_tests; fi


# generate sphinx documentation
Expand Down
2 changes: 1 addition & 1 deletion cardano_node_tests/cluster_scripts/babbage/start-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ wait_for_epoch() {
}

enable_submit_api() {
type cardano-submit-api >/dev/null 2>&1 || return 1
command -v cardano-submit-api >/dev/null 2>&1 || return 1

# TODO: `--metrics-port` is not available in older cardano-node releases, see node issue #4280
# If the metrics port is not available, we can start the `cardano-submit-api` only on the first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ cardano_cli_log() {
}

enable_submit_api() {
type cardano-submit-api >/dev/null 2>&1 || return 1
command -v cardano-submit-api >/dev/null 2>&1 || return 1

# TODO: `--metrics-port` is not available in older cardano-node releases, see node issue #4280
# If the metrics port is not available, we can start the `cardano-submit-api` only on the first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cardano_cli_log() {
}

enable_submit_api() {
type cardano-submit-api >/dev/null 2>&1 || return 1
command -v cardano-submit-api >/dev/null 2>&1 || return 1

# TODO: `--metrics-port` is not available in older cardano-node releases, see node issue #4280
# If the metrics port is not available, we can start the `cardano-submit-api` only on the first
Expand Down
4 changes: 2 additions & 2 deletions cardano_node_tests/cluster_scripts/testnets/start-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ EoF
fi

# enable cardano-submit-api service
if type cardano-submit-api >/dev/null 2>&1 && [ -e "$TESTNET_CONF_DIR/submit-api-config.json" ]; then
if command -v cardano-submit-api >/dev/null 2>&1 && [ -e "$TESTNET_CONF_DIR/submit-api-config.json" ]; then
# copy cardano-submit-api config file
cp "$TESTNET_CONF_DIR/submit-api-config.json" "$STATE_CLUSTER/submit-api-config.json"

Expand Down Expand Up @@ -174,7 +174,7 @@ done
[ "$sync_progress" = "100.00" ] || { echo "Failed to sync the realy node, line $LINENO" >&2; exit 1; } # assert

# start cardano-submit-api
if type cardano-submit-api >/dev/null 2>&1 && [ -e "$STATE_CLUSTER/submit-api-config.json" ]; then
if command -v cardano-submit-api >/dev/null 2>&1 && [ -e "$STATE_CLUSTER/submit-api-config.json" ]; then
echo "Starting cardano-submit-api"
supervisorctl -s http://127.0.0.1:%%SUPERVISOR_PORT%% start submit_api
fi
Expand Down
2 changes: 1 addition & 1 deletion poetry_update_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ -n "${IN_NIX_SHELL:-""}" ]; then
echo "This script is not supposed to run inside nix shell." >&2
abort_install=1
fi
if ! type poetry >/dev/null 2>&1; then
if ! command -v poetry >/dev/null 2>&1; then
echo "Poetry is not installed. Please install it first." >&2
abort_install=1
fi
Expand Down
4 changes: 2 additions & 2 deletions setup_dev_venv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ -n "${IN_NIX_SHELL:-""}" ]; then
echo "This script is not supposed to run inside nix shell." >&2
abort_install=1
fi
if ! type poetry >/dev/null 2>&1; then
if ! command -v poetry >/dev/null 2>&1; then
echo "Poetry is not installed. Please install it first." >&2
abort_install=1
fi
Expand All @@ -38,7 +38,7 @@ if [ -n "${VIRTUAL_ENV:-""}" ]; then
fi

# use the same python version as in nix shell
if ! type "python$PYTHON_VERSION" >/dev/null 2>&1; then
if ! command -v "python$PYTHON_VERSION" >/dev/null 2>&1; then
echo "Python $PYTHON_VERSION is not installed. Please install it first." >&2
abort_install=1
fi
Expand Down

0 comments on commit 1f50ffd

Please sign in to comment.