From ab295daae408665da415d977aada390a194684d0 Mon Sep 17 00:00:00 2001 From: Charlotte Koch Date: Thu, 27 Jun 2024 10:45:25 -0700 Subject: It's actually the realdestbase which must not exist beforehand It's okay if the directory CONTAINING the newly-created project dir already exists. It's *specifically* the project dir itself which must not exist prior to `willora new`. --- bin/willora | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/willora b/bin/willora index f2de4f0..6dd8c6b 100755 --- a/bin/willora +++ b/bin/willora @@ -64,11 +64,6 @@ class Willora return 1 end - if File.exists?(@opts[:destination]) - @errormsg = "Destination directory already exists: #{@opts[:destination].inspect}" - return 1 - end - # Fill in some gaps before we continue. if !@opts[:nickname] @errormsg = "New project requires a nickname" @@ -80,12 +75,18 @@ class Willora return 1 end + realdestbase = File.join(@opts[:destination], @opts[:nickname]) + + if File.exists?(realdestbase) + @errormsg = "Directory already exists: #{realdestbase.inspect}" + return 1 + end + @opts[:title] = DEFAULT_TITLE if !@opts[:title] @opts[:author] = DEFAULT_AUTHOR if !@opts[:author] @opts[:publisher] = DEFAULT_PUBLISHER if !@opts[:publisher] # Create the new project directory and copy the files over. - realdestbase = File.join(@opts[:destination], @opts[:nickname]) FileUtils.mkdir_p(realdestbase, :verbose => true) alldirs << File.join(_willorabase, "Gemfile") -- cgit v1.2.3