File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
ruby/rails-hyperstack/lib/generators/hyperstack Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ def report
185185 private
186186
187187 def skip_adding_component?
188- options [ 'hotloader-only' ] || options [ 'webpack-only' ] || options [ 'hyper-model-only' ]
188+ options [ 'hotloader-only' ] || options [ 'webpack-only' ] || options [ 'hyper-model-only' ] || existing_rails_app?
189189 end
190190
191191 def skip_hotloader?
@@ -200,6 +200,23 @@ 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+
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
213+ c + 1
214+ end
215+ end
216+
217+ count >= 3
218+ end
219+
203220 def inject_into_initializer ( s )
204221 file_name = File . join ( 'config' , 'initializers' , 'hyperstack.rb' )
205222 if File . exists? ( file_name )
You can’t perform that action at this time.
0 commit comments