fix: directory checking in wrong place
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
VERSION="0.3.8"
|
||||
VERSION="0.3.9"
|
||||
|
||||
# --- Globals ---
|
||||
|
||||
@@ -57,7 +57,7 @@ function get_mod_name_and_index() {
|
||||
entry=$(grep "^${mod_index}," "$DB_FILE")
|
||||
mod_name=$(echo "$entry" | awk -F, '{print $3}')
|
||||
elif [[ -n "$mod_name" ]]; then # if mod name exists
|
||||
entry=$(grep ",$mod_name," "$DB_FILE")
|
||||
entry=$(grep -F ",$mod_name," "$DB_FILE")
|
||||
mod_index=$(echo "$entry" | awk -F, '{print $1}' | head -1)
|
||||
fi
|
||||
|
||||
@@ -662,19 +662,6 @@ function mod_install() {
|
||||
if [[ -z "$mod_name" ]]; then
|
||||
mod_name=$(echo "$mod_dir" | sed 's:/*$::' | awk -F/ '{print $NF}' | sed -E 's/-[0-9]+-.*//')
|
||||
fi
|
||||
fi
|
||||
|
||||
# verify minimum information required
|
||||
[[ -z "$mod_name" || ${#mod_files[@]} -eq 0 ]] && { echo -e "${RED}Error${NC}: Mod name and files are required." >&2; exit 1; }
|
||||
|
||||
# verify duplicate mod names
|
||||
get_mod_name_and_index --do-not-exit
|
||||
[[ $mod_index -ne -1 ]] && { echo -e "${RED}Error${NC}: The mod '$mod_name' is already installed."; exit 1; }
|
||||
|
||||
# verify mod files exist
|
||||
for file in "${mod_files[@]}"; do
|
||||
[[ ! -f "$file" ]] && { echo -e "${RED}Error${NC}: Mod file $file does not exist." >&2; exit 1; }
|
||||
done
|
||||
|
||||
# check for mod variants and handle
|
||||
# if the mod directory contains more than 1 directory, it means there are multiple variants for the mod
|
||||
@@ -717,6 +704,19 @@ function mod_install() {
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# verify minimum information required
|
||||
[[ -z "$mod_name" || ${#mod_files[@]} -eq 0 ]] && { echo -e "${RED}Error${NC}: Mod name and files are required." >&2; exit 1; }
|
||||
|
||||
# verify duplicate mod names
|
||||
get_mod_name_and_index --do-not-exit
|
||||
[[ $mod_index -ne -1 ]] && { echo -e "${RED}Error${NC}: The mod '$mod_name' is already installed."; exit 1; }
|
||||
|
||||
# verify mod files exist
|
||||
for file in "${mod_files[@]}"; do
|
||||
[[ ! -f "$file" ]] && { echo -e "${RED}Error${NC}: Mod file $file does not exist." >&2; exit 1; }
|
||||
done
|
||||
|
||||
# hash table - in case multiple named files are needed for 1 mod install, store the patch count
|
||||
declare -A patch_count
|
||||
|
||||
Reference in New Issue
Block a user