From 2e95c72d575b425d0bc94fbb5db67c0a8f4b7ca2 Mon Sep 17 00:00:00 2001 From: Brooke Kuhlmann Date: Wed, 28 Jul 2021 21:46:41 -0600 Subject: [PATCH] Updated Node package install script to use NPM Yarn has fallen out of favor in the community so have switched to native NPM support instead. --- bin/install_node_packages | 2 +- lib/utilities.sh | 10 +++++----- lib/verifiers.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/install_node_packages b/bin/install_node_packages index 3c30a96..937678c 100755 --- a/bin/install_node_packages +++ b/bin/install_node_packages @@ -10,7 +10,7 @@ IFS=$'\n\t' SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_node_packages" if [[ -x "$SCRIPT_PATH" ]]; then - check_yarn_install + check_npm_install "$SCRIPT_PATH" else printf "WARNING: Node packages install script does not exist or is not executable.\n" diff --git a/lib/utilities.sh b/lib/utilities.sh index dba1949..c4f1d80 100644 --- a/lib/utilities.sh +++ b/lib/utilities.sh @@ -101,15 +101,15 @@ get_install_root() { } export -f get_install_root -# Checks Yarn has been installed and exits if otherwise. +# Checks NPM has been installed and exits if otherwise. # Parameters: None. -check_yarn_install() { - if ! command -v yarn > /dev/null; then - printf "%s\n" "ERROR: Yarn can't be found. Please ensure Homebrew and Yarn have been installed." +check_npm_install() { + if ! command -v npm > /dev/null; then + printf "%s\n" "ERROR: NPM can't be found. Please ensure Homebrew and NPM have been installed." exit 1 fi } -export -f check_yarn_install +export -f check_npm_install # Checks Mac App Store (mas) CLI has been installed and exits if otherwise. # Parameters: None. diff --git a/lib/verifiers.sh b/lib/verifiers.sh index 71f42c6..0fc3890 100644 --- a/lib/verifiers.sh +++ b/lib/verifiers.sh @@ -129,13 +129,13 @@ export -f verify_path # Checks for missing Node packages. verify_node_packages() { - local packages=$(yarn global list --json | grep '"type":"info"') - printf "\nChecking Node packages...\n" while read line; do - if [[ "$line" == "yarn global add"* ]]; then + if [[ "$line" == "npm "* ]]; then local package=$(printf "$line" | awk '{print $4}') + local packages=($(npm list --global --depth=0 | grep "$package")) + verify_listed_application "$package" "${packages[*]}" fi done < "$MAC_OS_CONFIG_PATH/bin/install_node_packages"