@@ -24,9 +24,18 @@ namespace :asdf do
2424 if fetch ( :asdf_setup )
2525 on roles ( fetch ( :asdf_roles ) ) do
2626 if test ( "[ -d #{ fetch ( :asdf_path ) } ]" )
27- info "ASDF is installed on #{ fetch ( :asdf_path ) } "
27+ within ( fetch ( :asdf_path ) ) do
28+ version = capture ( :cat , "version.txt" ) . strip
29+ if fetch ( :asdf_version ) == version
30+ info "ASDF #{ fetch ( :asdf_version ) } is already installed on #{ fetch ( :asdf_path ) } "
31+ else
32+ execute :git , "checkout" , "v#{ fetch ( :asdf_version ) } "
33+ info "ASDF is updated from #{ version } to #{ fetch ( :asdf_version ) } (on #{ fetch ( :asdf_path ) } )"
34+ end
35+ end
2836 else
2937 execute ( :git , "clone" , fetch ( :asdf_repository ) , fetch ( :asdf_path ) , "--branch" , fetch ( :asdf_version ) )
38+ info "ASDF #{ fetch ( :asdf_version ) } is installed on #{ fetch ( :asdf_path ) } "
3039 end
3140 end
3241 end
@@ -61,20 +70,13 @@ namespace :asdf do
6170 end
6271
6372 namespace :uninstall do
64- desc "Uninstall ASDF Ruby version based on the .tool-versions of your project"
65- task :ruby do
66- on roles ( fetch ( :asdf_roles ) ) do
67- within ( release_path ) do
68- execute ( :asdf , "uninstall" , "ruby" )
69- end
70- end
71- end
72-
73- desc "Uninstall ASDF NodeJS version based on the .tool-versions of your project"
74- task :nodejs do
75- on roles ( fetch ( :asdf_roles ) ) do
76- within ( release_path ) do
77- execute ( :asdf , "uninstall" , "nodejs" )
73+ %i[ ruby nodejs ] . each do |tool |
74+ desc "Uninstall ASDF #{ tool } version based on the .tool-versions of your project"
75+ task tool do
76+ on roles ( fetch ( :asdf_roles ) ) do
77+ within ( release_path ) do
78+ execute ( :asdf , "uninstall" , tool . to_s )
79+ end
7880 end
7981 end
8082 end
@@ -87,22 +89,16 @@ namespace :asdf do
8789 asdf_prefix = fetch ( :asdf_prefix , -> { "#{ fetch ( :asdf_path ) } /bin/asdf exec" } )
8890 SSHKit . config . command_map [ :asdf ] = "#{ fetch ( :asdf_path ) } /bin/asdf"
8991
90- if fetch ( :asdf_tools ) . include? ( "ruby" )
91- if fetch ( :asdf_ruby_use_jemalloc )
92- on roles ( fetch ( :asdf_roles ) ) do
93- if test ( "[ -f #{ fetch ( :asdf_jemalloc_path ) } /jemalloc.h ]" )
94- SSHKit . config . default_env . merge! ( ruby_configure_opts : "--with-jemalloc=#{ fetch ( :asdf_jemalloc_path ) } " )
95- end
92+ if fetch ( :asdf_tools ) . include? ( "ruby" ) && fetch ( :asdf_ruby_use_jemalloc )
93+ on roles ( fetch ( :asdf_roles ) ) do
94+ if test ( "[ -f #{ fetch ( :asdf_jemalloc_path ) } /jemalloc.h ]" )
95+ SSHKit . config . default_env . merge! ( ruby_configure_opts : "--with-jemalloc=#{ fetch ( :asdf_jemalloc_path ) } " )
9696 end
9797 end
98-
99- fetch ( :asdf_map_ruby_bins ) . uniq . each do |command |
100- SSHKit . config . command_map . prefix [ command . to_sym ] . unshift ( asdf_prefix )
101- end
10298 end
10399
104- if fetch ( :asdf_tools ) . include? ( "nodejs" )
105- fetch ( :asdf_map_nodejs_bins ) . uniq . each do |command |
100+ fetch ( :asdf_tools ) . each do | tool |
101+ fetch ( :"asdf_map_ #{ tool } _bins" , [ ] ) . uniq . each do |command |
106102 SSHKit . config . command_map . prefix [ command . to_sym ] . unshift ( asdf_prefix )
107103 end
108104 end
@@ -119,7 +115,7 @@ namespace :load do
119115 task :defaults do
120116 set :asdf_path , fetch ( :asdf_path , "~/.asdf" )
121117 set :asdf_repository , fetch ( :asdf_repository , "https://github.com/asdf-vm/asdf.git" )
122- set :asdf_version , fetch ( :asdf_version , "v0.14.1 " )
118+ set :asdf_version , fetch ( :asdf_version , "0.15.0 " )
123119 set :asdf_setup , fetch ( :asdf_setup , true )
124120 set :asdf_roles , fetch ( :asdf_roles , :all )
125121 set :asdf_ruby_use_jemalloc , fetch ( :asdf_ruby_use_jemalloc , true )
0 commit comments