From eec175e2328d8c976c80987e706744c2e60f11c7 Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Sun, 14 Mar 2021 11:21:59 -0600 Subject: [PATCH] Added mas check to App Store install script Necessary to ensure mas is installed before executing the script. This reduces the strain on downstream projects/scripts from having to do this check. This was previously part of the macOS Configuration project but has been moved here as central location for core functionality. --- bin/install_app_store | 1 + lib/utilities.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/bin/install_app_store b/bin/install_app_store index e62b14e..c0dfaa7 100755 --- a/bin/install_app_store +++ b/bin/install_app_store @@ -9,6 +9,7 @@ IFS=$'\n\t' SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_app_store" if [[ -x "$SCRIPT_PATH" ]]; then + check_mas_install "$SCRIPT_PATH" else printf "WARNING: App Store install script does not exist or is not executable.\n" diff --git a/lib/utilities.sh b/lib/utilities.sh index 48a50a5..0cb44e1 100644 --- a/lib/utilities.sh +++ b/lib/utilities.sh @@ -95,6 +95,17 @@ get_install_root() { } export -f get_install_root +# Checks Mac App Store (mas) CLI has been installed and exits if otherwise. +# Parameters: None. +check_mas_install() { + if ! command -v mas > /dev/null; then + printf "%s\n" "ERROR: Mac App Store (mas) CLI can't be found." + printf "%s\n" " Please ensure Homebrew and mas (i.e. brew install mas) have been installed." + exit 1 + fi +} +export -f check_mas_install + # Configures shell for new machines and ensures PATH is properly configured for running scripts. # Parameters: None. configure_environment() {