2023-01-09 21:55:47 -08:00
|
|
|
{{- if (ne .host.distro.family "windows") -}}
|
2022-12-24 02:46:21 -08:00
|
|
|
#!/usr/bin/env bash
|
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.
|
2022-12-24 02:46:21 -08:00
|
|
|
|
|
|
|
# Node.js version: {{ output "node" "--version" }}
|
|
|
|
|
2023-01-24 20:36:59 -08:00
|
|
|
{{ includeTemplate "universal/profile-before" }}
|
|
|
|
{{ includeTemplate "universal/logg-before" }}
|
2022-12-25 00:34:15 -08:00
|
|
|
|
2023-08-07 22:29:21 -07:00
|
|
|
export VOLTA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/volta"
|
2023-07-17 10:41:49 -07:00
|
|
|
export PATH="$VOLTA_HOME/bin:$PATH"
|
|
|
|
|
2022-12-24 02:46:21 -08:00
|
|
|
### 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
|
2023-01-09 21:55:47 -08:00
|
|
|
|
|
|
|
{{ end -}}
|