feat: prevent the same mod from being installed multiple times (#14)
* prevent the same mod from being installed multiple times * use flag instead of variable for exit check
This commit is contained in:
@@ -63,8 +63,12 @@ function get_mod_name_and_index() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$entry" || -z "$mod_index" || -z "$mod_name" ]]; then
|
if [[ -z "$entry" || -z "$mod_index" || -z "$mod_name" ]]; then
|
||||||
echo -e "${RED}Error${NC}: Mod not found." >&2
|
if [[ "$1" == "--do-not-exit" ]]; then
|
||||||
exit 1
|
mod_index=-1
|
||||||
|
else
|
||||||
|
echo -e "${RED}Error${NC}: Mod not found." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
status=$(echo "$entry" | awk -F, '{print $2}')
|
status=$(echo "$entry" | awk -F, '{print $2}')
|
||||||
@@ -662,6 +666,13 @@ function mod_install() {
|
|||||||
# verify minimum information required
|
# 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; }
|
[[ -z "$mod_name" || ${#mod_files[@]} -eq 0 ]] && { echo -e "${RED}Error${NC}: Mod name and files are required." >&2; exit 1; }
|
||||||
|
|
||||||
|
get_mod_name_and_index "--do-not-exit" "$mod_name" "$do_not_exit"
|
||||||
|
|
||||||
|
if [[ $mod_index -ne -1 ]]; then
|
||||||
|
echo -e "${RED}Error${NC}: The mod '$mod_name' is already installed.";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
# verify mod files exist
|
# verify mod files exist
|
||||||
for file in "${mod_files[@]}"; do
|
for file in "${mod_files[@]}"; do
|
||||||
[[ ! -f "$file" ]] && { echo -e "${RED}Error${NC}: Mod file $file does not exist." >&2; exit 1; }
|
[[ ! -f "$file" ]] && { echo -e "${RED}Error${NC}: Mod file $file does not exist." >&2; exit 1; }
|
||||||
|
|||||||
Reference in New Issue
Block a user