summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlotte Koch <charlotte@magentastripe.com>2024-06-27 10:45:25 -0700
committerCharlotte Koch <charlotte@magentastripe.com>2024-06-27 10:45:25 -0700
commitab295daae408665da415d977aada390a194684d0 (patch)
treeff47f752b23199fa0ffdf2e5147ee07058d1c745
parente75ed4fd0a32765864bb06ec55dccf38ddae22d5 (diff)
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`.
-rwxr-xr-xbin/willora13
1 files 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")