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.
This commit is contained in:
@@ -10,7 +10,7 @@ IFS=$'\n\t'
|
|||||||
SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_node_packages"
|
SCRIPT_PATH="$MAC_OS_CONFIG_PATH/bin/install_node_packages"
|
||||||
|
|
||||||
if [[ -x "$SCRIPT_PATH" ]]; then
|
if [[ -x "$SCRIPT_PATH" ]]; then
|
||||||
check_yarn_install
|
check_npm_install
|
||||||
"$SCRIPT_PATH"
|
"$SCRIPT_PATH"
|
||||||
else
|
else
|
||||||
printf "WARNING: Node packages install script does not exist or is not executable.\n"
|
printf "WARNING: Node packages install script does not exist or is not executable.\n"
|
||||||
|
|||||||
@@ -101,15 +101,15 @@ get_install_root() {
|
|||||||
}
|
}
|
||||||
export -f 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.
|
# Parameters: None.
|
||||||
check_yarn_install() {
|
check_npm_install() {
|
||||||
if ! command -v yarn > /dev/null; then
|
if ! command -v npm > /dev/null; then
|
||||||
printf "%s\n" "ERROR: Yarn can't be found. Please ensure Homebrew and Yarn have been installed."
|
printf "%s\n" "ERROR: NPM can't be found. Please ensure Homebrew and NPM have been installed."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f check_yarn_install
|
export -f check_npm_install
|
||||||
|
|
||||||
# Checks Mac App Store (mas) CLI has been installed and exits if otherwise.
|
# Checks Mac App Store (mas) CLI has been installed and exits if otherwise.
|
||||||
# Parameters: None.
|
# Parameters: None.
|
||||||
|
|||||||
@@ -129,13 +129,13 @@ export -f verify_path
|
|||||||
|
|
||||||
# Checks for missing Node packages.
|
# Checks for missing Node packages.
|
||||||
verify_node_packages() {
|
verify_node_packages() {
|
||||||
local packages=$(yarn global list --json | grep '"type":"info"')
|
|
||||||
|
|
||||||
printf "\nChecking Node packages...\n"
|
printf "\nChecking Node packages...\n"
|
||||||
|
|
||||||
while read line; do
|
while read line; do
|
||||||
if [[ "$line" == "yarn global add"* ]]; then
|
if [[ "$line" == "npm "* ]]; then
|
||||||
local package=$(printf "$line" | awk '{print $4}')
|
local package=$(printf "$line" | awk '{print $4}')
|
||||||
|
local packages=($(npm list --global --depth=0 | grep "$package"))
|
||||||
|
|
||||||
verify_listed_application "$package" "${packages[*]}"
|
verify_listed_application "$package" "${packages[*]}"
|
||||||
fi
|
fi
|
||||||
done < "$MAC_OS_CONFIG_PATH/bin/install_node_packages"
|
done < "$MAC_OS_CONFIG_PATH/bin/install_node_packages"
|
||||||
|
|||||||
Reference in New Issue
Block a user