lib/rconf/configurators/ruby_configurator.rb in rconf-0.7.3 vs lib/rconf/configurators/ruby_configurator.rb in rconf-0.7.4
- old
+ new
@@ -226,33 +226,12 @@
# Setup .bashrc for rvm support
#
# === Return
# true:: Always return true
def setup_bashrc
- candidates = ['.bashrc', '.bash_profile']
- candidates.map! { |c| File.join(ENV['HOME'], c) }
- bashrc_path = candidates.detect { |c| File.exist?(c) }
- if bashrc_path
- content = IO.read(bashrc_path)
- unless content.include?(rvm_bash_activation)
- i = content.index(/^\s*PATH=[^$PATH]/)
- if i
- next_line = content.index("\n", i + 1)
- if next_line
- content.insert(next_line + 1, rvm_bash_activation + "\n")
- else
- content += "\n" + rvm_bash_activation
- end
- else
- content = rvm_bash_activation + "\n" + content
- end
- FileUtils.mv(bashrc_path, bashrc_path + '.old')
- File.open(bashrc_path, 'w') { |f| f.puts content }
- post_note 'rvm was installed, please reload your shell to activate it and re-run rconf'
- aborting(true)
- end
- else
- report_error("Failed to update bashrc to activate rvm, no bashrc found")
+ if EnvironmentUpdater.update(rvm_bash_activation, ['PATH'])
+ post_note 'rvm was installed, please reload your shell to activate it and re-run rconf'
+ aborting(true)
end
end
# rvm bash activation code
#