mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-16 13:49:48 +00:00
feat!: refactor base, config, dfm and scripts
This commit is contained in:
@@ -2,11 +2,17 @@
|
||||
# Install npm packages globally.
|
||||
#
|
||||
# shellcheck source=shared.sh
|
||||
eval "$HOME/.dotfiles/scripts/shared.sh"
|
||||
eval "$DOTFILES/config/shared.sh"
|
||||
|
||||
# Enable verbosity with VERBOSE=1
|
||||
VERBOSE="${VERBOSE:-0}"
|
||||
|
||||
msg "Starting to install npm packages"
|
||||
|
||||
! x-have "npm" && msg_err "npm could not be found." && exit 0
|
||||
if ! command -v npm &> /dev/null; then
|
||||
msg_err "npm could not be found."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
packages=(
|
||||
# This is a tool to check if your files consider your .editorconfig rules.
|
||||
@@ -18,27 +24,48 @@ packages=(
|
||||
"corepack"
|
||||
)
|
||||
|
||||
for pkg in "${packages[@]}"; do
|
||||
# Trim spaces
|
||||
pkg=${pkg// /}
|
||||
# Skip comments
|
||||
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
|
||||
# Function to install npm packages
|
||||
install_packages()
|
||||
{
|
||||
for pkg in "${packages[@]}"; do
|
||||
# Trim spaces
|
||||
pkg=${pkg// /}
|
||||
# Skip comments
|
||||
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
|
||||
|
||||
if [[ $(npm ls -g -p "$pkg") != "" ]]; then
|
||||
msg_run_done "$pkg" "already installed"
|
||||
else
|
||||
msg_run "Installing npm package:" "$pkg"
|
||||
npm install -g --no-fund --no-progress --no-timing "$pkg"
|
||||
fi
|
||||
if npm ls -g -p "$pkg" &> /dev/null; then
|
||||
msg_run_done "$pkg" "already installed"
|
||||
else
|
||||
msg_run "Installing npm package:" "$pkg"
|
||||
npm install -g --no-fund --no-progress --no-timing "$pkg"
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
}
|
||||
|
||||
echo ""
|
||||
done
|
||||
# Function to upgrade all global npm packages
|
||||
upgrade_global_packages()
|
||||
{
|
||||
msg_run "Upgrading all global packages"
|
||||
npm -g --no-progress --no-timing --no-fund outdated
|
||||
npm -g --no-timing --no-fund upgrade
|
||||
}
|
||||
|
||||
msg_run "Upgrading all global packages"
|
||||
npm -g --no-progress --no-timing --no-fund outdated
|
||||
npm -g --no-timing --no-fund upgrade
|
||||
# Function to clean npm cache
|
||||
clean_npm_cache()
|
||||
{
|
||||
msg_run "Cleaning up npm cache"
|
||||
npm cache verify
|
||||
npm cache clean --force
|
||||
npm cache verify
|
||||
}
|
||||
|
||||
msg_run "Cleaning up npm cache"
|
||||
npm cache verify
|
||||
npm cache clean --force
|
||||
npm cache verify
|
||||
main()
|
||||
{
|
||||
install_packages
|
||||
upgrade_global_packages
|
||||
clean_npm_cache
|
||||
msg_yay "npm package installations complete"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user