From ef74e10de2a27fef0a39ebee2e4c0b503689c0f1 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 3 May 2018 21:22:23 +0100 Subject: Clear out terraform working directories during development --- lib/terraform_working_directory.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/terraform_working_directory.rb b/lib/terraform_working_directory.rb index b561edf..38df0c7 100644 --- a/lib/terraform_working_directory.rb +++ b/lib/terraform_working_directory.rb @@ -31,6 +31,13 @@ class TerraformWorkingDirectory end def within_working_directory + if Rails.env.development? && Dir.exist?(working_directory) + # For the purposes of development, always clear the working + # directory. This ensures that fresh terraform configuration + # will be copied over + FileUtils.remove_dir(working_directory) + end + source = File.expand_path(@source) FileUtils.mkdir_p working_directory -- cgit v1.2.3