Skip to content

Commit

Permalink
Only use Spring if already loaded
Browse files Browse the repository at this point in the history
This makes it possible for the user to selectively use Spring on a command to command basis

Fixes #510
  • Loading branch information
runephilosof-abtion committed Sep 17, 2024
1 parent b86d9e4 commit 54aa1f6
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/dotenv/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
Dotenv.instrumenter = ActiveSupport::Notifications

# Watch all loaded env files with Spring
begin
require "spring/commands"
if defined?(Spring)
ActiveSupport::Notifications.subscribe("load.dotenv") do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
Spring.watch event.payload[:env].filename if Rails.application
end
rescue LoadError, ArgumentError
# Spring is not available
end

module Dotenv
Expand Down

0 comments on commit 54aa1f6

Please sign in to comment.