From c2c9ebf14e67848fd04846e6f17f8ad5da327fa9 Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Sat, 20 Jul 2019 10:38:41 -0600 Subject: [PATCH] Added file install function. Was originally removed in this commit (a895090ca91d) and has been restored in order to handle situations where we have only a single file install. For example, the MacOS Config project needs this function in order to properly install the Pathogem (Vim) file. --- lib/installers.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/installers.sh b/lib/installers.sh index 9d8f3d7..c2b57fc 100644 --- a/lib/installers.sh +++ b/lib/installers.sh @@ -123,7 +123,6 @@ install_program() { local install_path=$(get_install_path "$program_name") if [[ ! -e "$install_path" ]]; then - printf "Installing: $install_path...\n" download_file "$url" "$program_name" mv "$MAC_OS_WORK_PATH/$program_name" "$install_path" chmod 755 "$install_path" @@ -172,6 +171,23 @@ install_git_project() { } export -f install_git_project +# Installs a single file. +# Parameters: $1 (required) - URL, $2 (required) - Install path. +install_file() { + local file_url="$1" + local file_name=$(get_file_name "$1") + local install_path="$2" + + if [[ ! -e "$install_path" ]]; then + download_file "$file_url" "$file_name" + mkdir -p $(dirname "$install_path") + mv "$MAC_OS_WORK_PATH/$file_name" "$install_path" + printf "Installed: $file_name.\n" + verify_path "$install_path" + fi +} +export -f install_file + # Downloads remote file to local disk. # Parameters: $1 (required) - URL, $2 (required) - File name, $3 (optional) - HTTP header. download_file() {