Load destination ENV file also

This commit is contained in:
David Heinemeier Hansson
2023-02-05 17:52:57 +01:00
parent 02a5726072
commit cb9f57356e
2 changed files with 10 additions and 1 deletions

View File

@@ -3,7 +3,6 @@
# Prevent failures from being reported twice. # Prevent failures from being reported twice.
Thread.report_on_exception = false Thread.report_on_exception = false
require "dotenv/load"
require "mrsk" require "mrsk"
begin begin

View File

@@ -1,4 +1,5 @@
require "thor" require "thor"
require "dotenv"
require "mrsk/sshkit_with_ext" require "mrsk/sshkit_with_ext"
module Mrsk::Cli module Mrsk::Cli
@@ -21,10 +22,19 @@ module Mrsk::Cli
def initialize(*) def initialize(*)
super super
load_envs
initialize_commander(options) initialize_commander(options)
end end
private private
def load_envs
if destination = options[:destination]
Dotenv.load(".env.#{destination}", ".env")
else
Dotenv.load(".env")
end
end
def initialize_commander(options) def initialize_commander(options)
MRSK.tap do |commander| MRSK.tap do |commander|
commander.config_file = Pathname.new(File.expand_path(options[:config_file])) commander.config_file = Pathname.new(File.expand_path(options[:config_file]))