class MyFlutter::Tool
Public Instance Methods
install()
click to toggle source
# File lib/myFlutter.rb, line 11 def install() if File.exist?(@@flutter_root) puts("flutterSDK 已经安装了") else Dir.chdir(ENV['HOME']) puts("执行下载FLutter SDK") `git clone #{@@flutterSDK_url}` raise 'flutter sdk下载失败' unless $?.success? puts("flutter SDK下载成功") end annotation = "#flutter settings\n" path_setting = "export PATH=\"$PATH:#{@@flutter_root}/bin\"\n" bash_profile_path = ENV['HOME']+'/.bash_profile' if File.exist?("#{bash_profile_path}") puts "Export the settings into #{bash_profile_path}" content = File.readlines("#{bash_profile_path}") bash_file = File.open(ENV['HOME']+'/.bash_profile', 'a') bash_file << "\n" unless content.last.eql?("\n") bash_file << "#{annotation}" unless content.include?("#{annotation}") bash_file << "#{path_setting}" unless content.include?("#{path_setting}") bash_file.close end zshrc_path = ENV['HOME']+'/.zshrc' if File.exist?("#{zshrc_path}") puts "Export the settings into #{zshrc_path}" content = File.readlines("#{zshrc_path}") zshrc = File.open(ENV['HOME']+'/.zshrc', 'a') zshrc << "\n" unless content.last.eql?("\n") zshrc << "#{annotation}" unless content.include?("#{annotation}") zshrc << "#{path_setting}" unless content.include?("#{path_setting}") zshrc.close end end
uninstall()
click to toggle source
# File lib/myFlutter.rb, line 47 def uninstall() if File.exist?("#{@@flutter_root}") puts "deleting the flutter sdk..." `rm -rf #{@@flutter_root}` raise 'git clone failed' unless $?.success? end puts "Remove the exported flutter variables in ~/.bash_profile and ~/.zshrc, if not needed anymore." end