From c651de177f4e9f7ac2a020b3fe2fdb57701f32de Mon Sep 17 00:00:00 2001 From: Donal McBreen Date: Tue, 12 Sep 2023 11:54:47 +0100 Subject: [PATCH] Fix empty file warning when uploading env files --- lib/kamal/utils.rb | 2 +- test/utils_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/kamal/utils.rb b/lib/kamal/utils.rb index 6ab1648b1..c61d4cf8a 100644 --- a/lib/kamal/utils.rb +++ b/lib/kamal/utils.rb @@ -33,7 +33,7 @@ def env_file_with_secrets(env) end.string # Ensure the file has some contents to avoid the SSHKIT empty file warning - env_file || "\n" + env_file.presence || "\n" end # Returns a list of shell-dashed option arguments. If the value is true, it's treated like a value-less option. diff --git a/test/utils_test.rb b/test/utils_test.rb index cef0a7fa2..3edfe8f5c 100644 --- a/test/utils_test.rb +++ b/test/utils_test.rb @@ -33,6 +33,10 @@ class UtilsTest < ActiveSupport::TestCase Kamal::Utils.env_file_with_secrets(env) end + test "env file empty" do + assert_equal "\n", Kamal::Utils.env_file_with_secrets({}) + end + test "env file secret" do ENV["PASSWORD"] = "hello" env = {