Skip to content

Commit 335a32a

Browse files
authored
Merge pull request #583 from headius/make_config_dir
Create config dir if it is missing
2 parents 5b1d3a1 + 4d20148 commit 335a32a

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

lib/warbler/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class Config
1515
include RakeHelper
1616

1717
TOP_DIRS = %w(app db config lib log script vendor)
18-
FILE = "config/warble.rb"
18+
CONFIG_DIR = "config"
19+
FILE = "#{CONFIG_DIR}/warble.rb"
1920
BUILD_GEMS = %w(warbler rake rcov)
2021

2122
include Traits

lib/warbler/task.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,15 @@ def define_config_task
151151
if File.exist?(Warbler::Config::FILE) && ENV["FORCE"].nil?
152152
puts "There's another bird sitting on my favorite branch"
153153
puts "(file '#{Warbler::Config::FILE}' already exists. Pass argument FORCE=1 to override)"
154-
elsif !File.directory?("config")
155-
puts "I'm confused; my favorite branch is missing"
156-
puts "(directory 'config' is missing)"
157-
else
158-
cp "#{Warbler::WARBLER_HOME}/warble.rb", Warbler::Config::FILE
154+
next
155+
end
156+
157+
if !File.directory?(Warbler::Config::CONFIG_DIR)
158+
puts "config dir is missing, creating it"
159+
mkdir_p Warbler::Config::CONFIG_DIR
159160
end
161+
162+
cp "#{Warbler::WARBLER_HOME}/warble.rb", Warbler::Config::FILE
160163
end
161164
end
162165

spec/warbler/application_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@
5757
expect(capture { Warbler::Application.new.run }).to match /already exists/
5858
end
5959

60-
it "should complain if the config directory is missing" do
60+
it "should create the config dir if it is missing" do
6161
begin
6262
mv "config", "config-tmp"
6363
ARGV.unshift "config"
64-
expect(capture { Warbler::Application.new.run }).to match /missing/
64+
expect(capture { Warbler::Application.new.run }).to match /missing, creating/
6565
ensure
66+
rm_r "config"
6667
mv "config-tmp", "config"
6768
end
6869
end

0 commit comments

Comments
 (0)