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

27 lines
932 B
Bash
Raw Normal View History

2024-05-05 04:05:33 +00: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-28 03:45:14 +00:00
set -Eeuo pipefail
2024-05-28 03:50:11 +00:00
trap "gum log -sl error 'Script encountered an error!'" ERR
2024-05-27 11:15:03 +00:00
2024-05-05 04:05:33 +00:00
export VOLTA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/volta"
export PATH="$VOLTA_HOME/bin:$PATH"
2024-05-27 11:15:03 +00:00
### Disconnect from CloudFlare WARP (if connected)
if command -v warp-cli > /dev/null; then
2024-05-28 03:50:11 +00:00
warp-cli disconnect && gum log -sl info 'CloudFlare WARP temporarily disconnected while Volta installs Node / Yarn'
2024-05-27 11:15:03 +00:00
fi
### Configure Volta if it is installed
2024-05-05 04:05:33 +00:00
if command -v volta > /dev/null; then
2024-05-28 03:50:11 +00:00
gum log -sl info 'Running volta setup'
2024-05-05 04:05:33 +00:00
volta setup
2024-05-28 03:50:11 +00:00
gum log -sl info 'Installing latest version of Node.js via Volta'
2024-05-05 04:05:33 +00:00
volta install node@latest
2024-05-28 03:50:11 +00:00
gum log -sl info 'Installing latest version of Yarn via Volta'
2024-05-05 04:05:33 +00:00
volta install yarn@latest
else
2024-05-28 03:50:11 +00:00
gum log -sl info 'Volta is not installed'
2024-05-05 04:05:33 +00:00
fi