install.fairie/home/.chezmoiscripts/universal/run_onchange_before_09-node-version.sh.tmpl

30 lines
1 KiB
Cheetah
Raw Normal View History

{{- if (ne .host.distro.family "windows") -}}
#!/usr/bin/env bash
Update 21 files - /home/.chezmoiscripts/universal/run_onchange_after_85-remove-shortcuts.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_95-bootstrap-zsh-plugins.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_98-cleanup.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_99-restart-gnome.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_08-install-zx.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-node-version.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_10-remove-bloatware.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_91-configure-gpg.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_85-remove-shortcuts.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_94-bash-it.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_95-bootstrap-zsh-plugins.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_98-cleanup.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_after_99-restart-gnome.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_08-install-zx.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-install-go.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_09-node-version.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_10-remove-bloatware.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_11-install-docker.sh.tmpl - /home/.chezmoiscripts/universal/run_onchange_before_91-configure-gpg.sh.tmpl
2023-04-11 20:57:02 -07:00
# @file Node.js Version
# @brief Ensures a recent version of Node.js is available to the user by leveraging Volta
# @description
# This script installs the latest version of Node.js with Volta if the default Node.js version
# is an outdated version.
# Node.js version: {{ output "node" "--version" }}
2023-01-24 20:36:59 -08:00
{{ includeTemplate "universal/profile-before" }}
{{ includeTemplate "universal/logg-before" }}
export VOLTA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/volta"
2023-07-17 10:41:49 -07:00
export PATH="$VOLTA_HOME/bin:$PATH"
### Ensure recent version of Node.js is being used
if command -v volta > /dev/null; then
if ! test "$(node --version | sed 's/^v//' | awk '{print $1}' | awk -F'.' ' ( $1 > 15) ')"; then
logg info 'Installing latest version of Node.js'
volta install node@latest
else
logg info 'Node.js appears to meet the minimum version requirements (version >15)'
fi
else
logg warn 'Volta is not installed - skipping logic that ensures Node.js meets the version requirement of >15'
fi
{{ end -}}