install.fairie/home/dot_local/bin/post-installx/executable_post-volta.sh

27 lines
932 B
Bash
Raw Normal View History

2024-05-04 21:05:33 -07:00
#!/usr/bin/env bash
# @file Volta initialization
# @brief This script initializes Volta and ensures the latest version of node and yarn are installed
2024-05-27 20:45:14 -07:00
set -Eeuo pipefail
2024-05-27 20:50:11 -07:00
trap "gum log -sl error 'Script encountered an error!'" ERR
2024-05-27 04:15:03 -07:00
2024-05-04 21:05:33 -07:00
export VOLTA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/volta"
export PATH="$VOLTA_HOME/bin:$PATH"
2024-05-27 04:15:03 -07:00
### Disconnect from CloudFlare WARP (if connected)
if command -v warp-cli > /dev/null; then
2024-05-27 20:50:11 -07:00
warp-cli disconnect && gum log -sl info 'CloudFlare WARP temporarily disconnected while Volta installs Node / Yarn'
2024-05-27 04:15:03 -07:00
fi
### Configure Volta if it is installed
2024-05-04 21:05:33 -07:00
if command -v volta > /dev/null; then
2024-05-27 20:50:11 -07:00
gum log -sl info 'Running volta setup'
2024-05-04 21:05:33 -07:00
volta setup
2024-05-27 20:50:11 -07:00
gum log -sl info 'Installing latest version of Node.js via Volta'
2024-05-04 21:05:33 -07:00
volta install node@latest
2024-05-27 20:50:11 -07:00
gum log -sl info 'Installing latest version of Yarn via Volta'
2024-05-04 21:05:33 -07:00
volta install yarn@latest
else
2024-05-27 20:50:11 -07:00
gum log -sl info 'Volta is not installed'
2024-05-04 21:05:33 -07:00
fi