Skip to content

Commit 6fafac7

Browse files
author
Matthew Saginario
committed
got report message working
1 parent 6942872 commit 6fafac7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

ruby/rails-hyperstack/lib/generators/hyperstack/install_generator.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def report
185185
private
186186

187187
def skip_adding_component?
188-
@skip_adding_component ||= options['hotloader-only'] || options['webpack-only'] || options['hyper-model-only'] || existing_rails_app?
188+
options['hotloader-only'] || options['webpack-only'] || options['hyper-model-only'] || !new_rails_app?
189189
end
190190

191191
def skip_hotloader?
@@ -200,21 +200,19 @@ def skip_hyper_model?
200200
options['hotloader-only'] || options['webpack-only'] || options['skip-hyper-model']
201201
end
202202

203-
def existing_rails_app?
204-
#check to see if there are any routes set up
205-
route_file = File.join('config', 'routes.rb')
206-
puts "***********************************exisiting_rails_app"
207-
count = File.foreach(route_file).inject(0) do | c, line |
208-
line = line.strip
209-
210-
if line.empty? || line.start_with?('#') || line.start_with?('mount')
211-
c
212-
else
203+
def new_rails_app?
204+
# check to see if there are any routes set up and remember it, cause we might add a route in the process
205+
@new_rails_app ||= begin
206+
route_file = File.join('config', 'routes.rb')
207+
count = File.foreach(route_file).inject(0) do | c, line |
208+
line = line.strip
209+
next c if line.empty?
210+
next c if line.start_with?('#')
211+
next c if line.start_with?('mount')
213212
c + 1
214213
end
214+
count <= 2
215215
end
216-
217-
count >= 3
218216
end
219217

220218
def inject_into_initializer(s)

0 commit comments

Comments
 (0)