Skip to content

Commit a868fa7

Browse files
authored
Merge pull request #233 from Mezuro-labxp2016/fix_setup
Fix setup
2 parents df19ef9 + 92fe45b commit a868fa7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

bin/setup

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
#!/usr/bin/env ruby
22
require 'pathname'
3+
require 'fileutils'
4+
include FileUtils
35

46
# path to your application root.
5-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
7+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
68

7-
Dir.chdir APP_ROOT do
9+
def system!(*args)
10+
system(*args) || abort("\n== Command #{args} failed ==")
11+
end
12+
13+
chdir APP_ROOT do
814
# This script is a starting point to setup your application.
9-
# Add necessary setup steps to this file:
15+
# Add necessary setup steps to this file.
1016

11-
puts "== Installing dependencies =="
12-
system "gem install bundler --conservative"
13-
system "bundle check || bundle install"
17+
puts '== Installing dependencies =='
18+
system! 'gem install bundler --conservative'
19+
system('bundle check') || system!('bundle install')
1420

1521
puts "\n== Copying sample files =="
16-
unless File.exist?("config/database.yml")
17-
system "cp config/database.yml.postgresql_sample config/database.yml"
22+
unless File.exist?('config/database.yml')
23+
cp 'config/database.yml.sample', 'config/database.yml'
1824
end
1925
unless File.exist?("config/repositories.yml")
2026
system "cp config/repositories.yml.sample config/repositories.yml"
@@ -24,11 +30,13 @@ Dir.chdir APP_ROOT do
2430
end
2531

2632
puts "\n== Preparing database =="
27-
system "bin/rake db:setup"
33+
system! 'rake db:setup'
2834

2935
puts "\n== Removing old logs and tempfiles =="
30-
system "rm -f log/*"
31-
system "rm -rf tmp/cache"
36+
system! 'bin/rake log:clear tmp:clear'
37+
38+
puts "\n== Creating tempfiles =="
39+
system! 'rake tmp:create'
3240

3341
puts "\n== Restarting application server =="
3442
system "touch tmp/restart.txt"

0 commit comments

Comments
 (0)