Skip to content

Commit

Permalink
refactor: format install.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Oct 11, 2024
1 parent 812eee6 commit fc318b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- `DEFAULT_PATH="tests"`
- `LOG_PATH="out.log"`
- `LOAD_FILE="tests/bootstrap.sh"`
- Add check that git is installed to `install.sh`
- Add check that git is installed to `install.sh`

## [0.17.0](https://github.com/TypedDevs/bashunit/compare/0.16.0...0.17.0) - 2024-10-01

Expand Down
26 changes: 14 additions & 12 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash

# shellcheck disable=SC2155
# shellcheck disable=SC2164
# shellcheck disable=SC2103
declare -r BASHUNIT_GIT_REPO="https://github.com/TypedDevs/bashunit"

function check_git_is_installed() {
if ! command -v git >/dev/null 2>&1; then
Expand All @@ -11,8 +10,6 @@ function check_git_is_installed() {
fi
}

check_git_is_installed

function get_latest_tag() {
git ls-remote --tags "$BASHUNIT_GIT_REPO" |
awk '{print $2}' |
Expand All @@ -21,14 +18,6 @@ function get_latest_tag() {
head -n 1
}

# shellcheck disable=SC2155
declare -r LATEST_BASHUNIT_VERSION="$(get_latest_tag)"

DIR=${1-lib}
VERSION=${2-latest}
TAG="$LATEST_BASHUNIT_VERSION"


function build_and_install_beta() {
echo "> Downloading non-stable version: 'beta'"
git clone --depth 1 --no-tags https://github.com/TypedDevs/bashunit temp_bashunit 2>/dev/null
Expand Down Expand Up @@ -64,6 +53,19 @@ function install() {
chmod u+x "bashunit"
}

#########################
######### MAIN ##########
#########################

check_git_is_installed

DIR=${1-lib}
VERSION=${2-latest}

BASHUNIT_GIT_REPO="https://github.com/TypedDevs/bashunit"
LATEST_BASHUNIT_VERSION="$(get_latest_tag)"
TAG="$LATEST_BASHUNIT_VERSION"

cd "$(dirname "$0")"
rm -f "$DIR"/bashunit
[ -d "$DIR" ] || mkdir "$DIR"
Expand Down

0 comments on commit fc318b6

Please sign in to comment.