class Shred::Commands::Dotenv
Public Instance Methods
heroku()
click to toggle source
# File lib/shred/commands/dotenv.rb, line 19 def heroku app_name = cfg('heroku.app_name') vars = cfg('heroku.vars') custom = cfg('custom.vars', required: false) run_shell_command(ShellCommand.new(command_lines: 'heroku auth:whoami')) heroku = StringIO.new run_shell_command(ShellCommand.new( command_lines: "heroku config --app #{app_name} --shell", output: heroku )) outvars = {} heroku.string.split("\n").each do |line| key, value = line.split('=', 2) outvars[key] = value if vars.include?(key) end if custom custom.each do |key, value| outvars[key] = interpolate_value(value) end end File.open('.env', 'w') do |dotenv| outvars.sort_by(&:first).each do |(key, value)| dotenv.write("#{key}='#{value}'\n") end end console.say_ok("Heroku config written to .env") end