Skip to content

Commit

Permalink
Abstract ASDF sourcing in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarter committed Feb 14, 2020
1 parent 7897125 commit 395ce5c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,25 @@ def install_asdf
def update_asdf
puts '===== Updating asdf to latest version'.yellow

popen ". #{ASDF_INSTALL_DIR}/asdf.sh && asdf update"
asdf_command('asdf update')
end

def install_asdf_plugins
puts '===== Installing asdf plugins'.yellow

ASDF_PLUGINS.each do |plugin|
puts "Installing #{plugin} plugin...".light_blue
popen(". #{ASDF_INSTALL_DIR}/asdf.sh && asdf plugin-add #{plugin}")
asdf_command("asdf plugin-add #{plugin}")
end
end

def install_asdf_languages
puts '===== Installing asdf languages latest version'.yellow
ASDF_PLUGINS.each do |plugin|
puts "Installing #{plugin}...".light_blue
popen(". #{ASDF_INSTALL_DIR}/asdf.sh && asdf install #{plugin} latest")
asdf_command(
"asdf install #{plugin} latest && asdf global #{plugin} $(asdf latest #{plugin})"
)
end
end

Expand Down Expand Up @@ -209,6 +211,10 @@ def install_python_packages
popen("pip3 install #{PIPS3.join(' ')}")
end

def asdf_command(cmd)
popen(". #{ASDF_INSTALL_DIR}/asdf.sh && #{cmd}")
end

def popen(cmd)
puts 'Running: '.light_blue + cmd.to_s
IO.popen(cmd) do |io|
Expand Down

0 comments on commit 395ce5c

Please sign in to comment.