fix: directory checking in wrong place
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERSION="0.3.8"
|
VERSION="0.3.9"
|
||||||
|
|
||||||
# --- Globals ---
|
# --- Globals ---
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ function get_mod_name_and_index() {
|
|||||||
entry=$(grep "^${mod_index}," "$DB_FILE")
|
entry=$(grep "^${mod_index}," "$DB_FILE")
|
||||||
mod_name=$(echo "$entry" | awk -F, '{print $3}')
|
mod_name=$(echo "$entry" | awk -F, '{print $3}')
|
||||||
elif [[ -n "$mod_name" ]]; then # if mod name exists
|
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)
|
mod_index=$(echo "$entry" | awk -F, '{print $1}' | head -1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -662,19 +662,6 @@ function mod_install() {
|
|||||||
if [[ -z "$mod_name" ]]; then
|
if [[ -z "$mod_name" ]]; then
|
||||||
mod_name=$(echo "$mod_dir" | sed 's:/*$::' | awk -F/ '{print $NF}' | sed -E 's/-[0-9]+-.*//')
|
mod_name=$(echo "$mod_dir" | sed 's:/*$::' | awk -F/ '{print $NF}' | sed -E 's/-[0-9]+-.*//')
|
||||||
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
|
|
||||||
|
|
||||||
# check for mod variants and handle
|
# check for mod variants and handle
|
||||||
# if the mod directory contains more than 1 directory, it means there are multiple variants for the mod
|
# 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
|
done
|
||||||
fi
|
fi
|
||||||
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
|
# hash table - in case multiple named files are needed for 1 mod install, store the patch count
|
||||||
declare -A patch_count
|
declare -A patch_count
|
||||||
|
|||||||
Reference in New Issue
Block a user