Skip to content

Commit

Permalink
chore(scaffolding): update run.rb [ci-skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Apr 18, 2021
1 parent 0be5ec2 commit 4aff7ac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scaffolding/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using PactBroker::StringRefinements

MODEL_CLASS_FULL_NAME = "PactBroker::Foos::Foo"
DRY_RUN = false
DRY_RUN = true

TEMPLATE_DIR = Pathname.new(File.join(__dir__, "templates"))
MIGRATIONS_DIR = PactBroker.project_root.join("db", "migrations")
Expand Down Expand Up @@ -222,7 +222,11 @@ def generate_file(template, destination)
file_content = ERB.new(File.read(template)).result(binding).tap { |it| puts it }
if !DRY_RUN
FileUtils.mkdir_p(File.dirname(destination))
File.open(destination, "w") { |file| file << file_content }
if File.exist?(destination)
raise "File #{destination} already exists"
else
File.open(destination, "w") { |file| file << file_content }
end
end
end

Expand All @@ -235,3 +239,5 @@ def generate_file(template, destination)
generate_service_spec_file
generate_repository_file
generate_repository_spec_file

puts "THIS WAS A DRY RUN. Set DRY_RUN = true to generate the files." if DRY_RUN

0 comments on commit 4aff7ac

Please sign in to comment.