From ab80b4638b38dc390a59bb619e83406a257a35d5 Mon Sep 17 00:00:00 2001 From: Rob Tarr Date: Sat, 4 Aug 2018 22:28:29 -0400 Subject: [PATCH 1/4] feat: Use NVM for Node instead of brew - Install NVM - Uninstall brew installed Node - Install Node with NVM --- mac | 27 +++++++++++++++++++++++++-- node-versions.rb | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mac b/mac index a18cfce10..102ca70e8 100755 --- a/mac +++ b/mac @@ -59,6 +59,13 @@ brew_uninstall() { fi } +brew_cleanup() { + if brew_is_installed "$1"; then + fancy_echo "Cleaning up %s ..." "$1" + brew cleanup "$@" + fi +} + brew_install_or_upgrade() { if brew_is_installed "$1"; then if brew_is_upgradable "$1"; then @@ -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 + + # Load NVM + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +else + fancy_echo "NVM already installed. Skipping ..."bash "" +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 diff --git a/node-versions.rb b/node-versions.rb index 2854ade55..d9c0e2684 100755 --- a/node-versions.rb +++ b/node-versions.rb @@ -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/, '')}" } From 246b20c88fc777228e92c45bad4f030c65be0b6c Mon Sep 17 00:00:00 2001 From: Rob Tarr Date: Wed, 8 Aug 2018 22:05:57 -0400 Subject: [PATCH 2/4] fix: Remove extra space in NVM install --- mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac b/mac index 102ca70e8..d3d88178b 100755 --- a/mac +++ b/mac @@ -164,7 +164,7 @@ brew_tap 'caskroom/cask' # 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 + curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | $SHELL # Load NVM export NVM_DIR="$HOME/.nvm" From 66d35f8b6f68c1ce2a2ef256c2d5ed68063e8983 Mon Sep 17 00:00:00 2001 From: Rob Tarr Date: Wed, 8 Aug 2018 22:53:16 -0400 Subject: [PATCH 3/4] fix: Remove brew cleanup in favor of brew uninstall -f --- mac | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mac b/mac index d3d88178b..5e5991038 100755 --- a/mac +++ b/mac @@ -55,14 +55,7 @@ esac brew_uninstall() { if brew_is_installed "$1"; then fancy_echo "Uninstalling %s ..." "$1" - brew uninstall "$@" - fi -} - -brew_cleanup() { - if brew_is_installed "$1"; then - fancy_echo "Cleaning up %s ..." "$1" - brew cleanup "$@" + brew uninstall -f "$@" fi } @@ -176,9 +169,13 @@ fi nodeversions=`./node-versions.rb` mostrecentnode=$(echo "${nodeversions[@]:-1:1}" | tail -1) -# Iterate over LTS Node versions +# Remove any brew installed versions +for version in $nodeversions; do + brew_uninstall node@$version +done + +# Install LTS versions of Node for version in $nodeversions; do - brew_cleanup node@$version nvm install $version done From 572e0f78747ddd600abf01f3241417a91ea1457e Mon Sep 17 00:00:00 2001 From: Rob Tarr Date: Mon, 27 Aug 2018 09:29:49 -0400 Subject: [PATCH 4/4] fix: Removing typo --- mac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mac b/mac index 5e5991038..0f5fae151 100755 --- a/mac +++ b/mac @@ -163,7 +163,7 @@ if ! command -v nvm >/dev/null; then export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" else - fancy_echo "NVM already installed. Skipping ..."bash "" + fancy_echo "NVM already installed. Skipping ..." fi nodeversions=`./node-versions.rb`