Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use NVM for Node instead of brew #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions mac
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ esac
brew_uninstall() {
if brew_is_installed "$1"; then
fancy_echo "Uninstalling %s ..." "$1"
brew uninstall "$@"
brew uninstall -f "$@"
fi
}

Expand Down Expand Up @@ -153,14 +153,34 @@ brew_tap 'caskroom/cask'
###########################
# NODEJS
##########################

# Install NVM
if ! command -v nvm >/dev/null; then
fancy_echo "Installing NVM ..."
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | $SHELL

# Load NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
else
fancy_echo "NVM already installed. Skipping ..."
fi

nodeversions=`./node-versions.rb`
mostrecentnode=$(echo "${nodeversions[@]:-1:1}" | tail -1)

# Install each versions
# Remove any brew installed versions
for version in $nodeversions; do
brew_install_or_upgrade $version
brew_uninstall node@$version
done

# Install LTS versions of Node
for version in $nodeversions; do
nvm install $version
done

nvm alias default $mostrecentnode

# Link the last, most recent version
brew unlink $mostrecentnode
brew link --force $mostrecentnode
Expand Down
2 changes: 1 addition & 1 deletion node-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
url = URI('https://raw.githubusercontent.com/nodejs/Release/master/schedule.json')
result = Net::HTTP.get(url)
lts = JSON.parse(result).select {|key, value| value.key?("lts") and Date.parse(value["start"]) < Date.today }
lts.each {|key, value| puts "node@#{key.gsub(/v/, '')}" }
lts.each {|key, value| puts "#{key.gsub(/v/, '')}" }