Skip to content

Commit 8908626

Browse files
authored
Merge pull request #234 from Shopify/dont-always-generate-app-uri
Only generate app_uri.txt and append Rack app when the server feature is enabled
2 parents 3347ca7 + 0e1b659 commit 8908626

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/ruby_lsp_rails/railtie.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ class Railtie < ::Rails::Railtie
1212

1313
initializer "ruby_lsp_rails.setup" do |_app|
1414
config.after_initialize do |app|
15-
unless config.ruby_lsp_rails.server == false
15+
# If we start the app with `bin/rails console` then `Rails::Server` is not defined.
16+
if defined?(::Rails::Server) && config.ruby_lsp_rails.server
1617
app.routes.prepend do
1718
T.bind(self, ActionDispatch::Routing::Mapper)
1819
mount(RackApp.new => RackApp::BASE_PATH)
1920
end
20-
end
2121

22-
# If we start the app with `bin/rails console` then `Rails::Server` is not defined.
23-
if defined?(::Rails::Server)
2422
ssl_enable, host, port = ::Rails::Server::Options.new.parse!(ARGV).values_at(:SSLEnable, :Host, :Port)
2523
app_uri = "#{ssl_enable ? "https" : "http"}://#{host}:#{port}"
2624
app_uri_path = ::Rails.root.join("tmp", "app_uri.txt")

0 commit comments

Comments
 (0)