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 1 commit
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
27 changes: 25 additions & 2 deletions mac
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ brew_uninstall() {
fi
}

brew_cleanup() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

if brew_is_installed "$1"; then
fancy_echo "Cleaning up %s ..." "$1"
brew cleanup "$@"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we replace brew_uninstall with this? Kinda seems like cleanup is better.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice 2 different references for the parameter $1 and $@... maybe that's why the cleanup isn't happening?

fi
}

brew_install_or_upgrade() {
if brew_is_installed "$1"; then
if brew_is_upgradable "$1"; then
Expand Down Expand Up @@ -153,14 +160,30 @@ 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a biggie, but there's a weird extra few spaces before $SHELL. ¯_(ツ)_/¯

Kinda sucks they don't have a stable tag 😞


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the bash "" at the end?

fi

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

# Install each versions
# Iterate over LTS Node versions
for version in $nodeversions; do
brew_install_or_upgrade $version
brew_cleanup node@$version
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/, '')}" }