From 2694cf5d5fe1174a02c50a5969be2dbb3fd7ef20 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 11 Jan 2023 17:43:07 +0100 Subject: [PATCH] Make init more resilient and communicative --- lib/tasks/mrsk/mrsk.rake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/tasks/mrsk/mrsk.rake b/lib/tasks/mrsk/mrsk.rake index 573d0eb0..0f1ea9cc 100644 --- a/lib/tasks/mrsk/mrsk.rake +++ b/lib/tasks/mrsk/mrsk.rake @@ -15,11 +15,15 @@ namespace :mrsk do desc "Create config stub in config/deploy.yml" task :init do - require "fileutils" - FileUtils.cp_r \ - Pathname.new(File.expand_path("templates/deploy.yml", __dir__)), - Rails.root.join("config/deploy.yml") - info "Created configuration file in config/deploy.yml" + if (deploy_file = Rails.root.join("config/deploy.yml")).exist? + puts "Config file already exists in config/deploy.yml (remove first to create a new one)" + else + require "fileutils" + FileUtils.cp_r Pathname.new(File.expand_path("templates/deploy.yml", __dir__)), deploy_file + + puts "Created configuration file in config/deploy.yml" + end + end desc "Remove Traefik, app, and registry session from servers"