Fix env template path check and tests

This commit is contained in:
David Heinemeier Hansson
2024-05-14 10:07:31 -07:00
parent 938ac375a1
commit e58d2f67f2
2 changed files with 4 additions and 3 deletions

View File

@@ -186,7 +186,7 @@ class Kamal::Cli::Main < Kamal::Cli::Base
env_path = ".env" env_path = ".env"
end end
if File.exist?(env_template_path) if Pathname.new(File.expand_path(env_template_path)).exist?
File.write(env_path, ERB.new(File.read(env_template_path), trim_mode: "-").result, perm: 0600) File.write(env_path, ERB.new(File.read(env_template_path), trim_mode: "-").result, perm: 0600)
unless options[:skip_push] unless options[:skip_push]

View File

@@ -12,7 +12,7 @@ class CliMainTest < CliTestCase
run_command("setup").tap do |output| run_command("setup").tap do |output|
assert_match /Ensure Docker is installed.../, output assert_match /Ensure Docker is installed.../, output
assert_match /Push env files.../, output assert_match /Evaluate and push env files.../, output
end end
end end
@@ -34,7 +34,7 @@ class CliMainTest < CliTestCase
run_command("setup", "--skip_push").tap do |output| run_command("setup", "--skip_push").tap do |output|
assert_match /Ensure Docker is installed.../, output assert_match /Ensure Docker is installed.../, output
assert_match /Push env files.../, output assert_match /Evaluate and push env files.../, output
# deploy # deploy
assert_match /Acquiring the deploy lock/, output assert_match /Acquiring the deploy lock/, output
assert_match /Log into image registry/, output assert_match /Log into image registry/, output
@@ -429,6 +429,7 @@ class CliMainTest < CliTestCase
end end
test "envify" do test "envify" do
Pathname.any_instance.expects(:exist?).returns(true).times(3)
File.expects(:read).with(".env.erb").returns("HELLO=<%= 'world' %>") File.expects(:read).with(".env.erb").returns("HELLO=<%= 'world' %>")
File.expects(:write).with(".env", "HELLO=world", perm: 0600) File.expects(:write).with(".env", "HELLO=world", perm: 0600)