From cb9f57356e3110c110936cf059564b164f712396 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 5 Feb 2023 17:52:57 +0100 Subject: [PATCH] Load destination ENV file also --- bin/mrsk | 1 - lib/mrsk/cli/base.rb | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/mrsk b/bin/mrsk index dac9af62..1d85ee6c 100755 --- a/bin/mrsk +++ b/bin/mrsk @@ -3,7 +3,6 @@ # Prevent failures from being reported twice. Thread.report_on_exception = false -require "dotenv/load" require "mrsk" begin diff --git a/lib/mrsk/cli/base.rb b/lib/mrsk/cli/base.rb index 17a6c4dd..1e28e956 100644 --- a/lib/mrsk/cli/base.rb +++ b/lib/mrsk/cli/base.rb @@ -1,4 +1,5 @@ require "thor" +require "dotenv" require "mrsk/sshkit_with_ext" module Mrsk::Cli @@ -21,10 +22,19 @@ module Mrsk::Cli def initialize(*) super + load_envs initialize_commander(options) end private + def load_envs + if destination = options[:destination] + Dotenv.load(".env.#{destination}", ".env") + else + Dotenv.load(".env") + end + end + def initialize_commander(options) MRSK.tap do |commander| commander.config_file = Pathname.new(File.expand_path(options[:config_file]))