Skip to content

Commit

Permalink
Fix logic to start the watcher
Browse files Browse the repository at this point in the history
We should start if the variable isn't set or it it is set and nil.
  • Loading branch information
rafaelfranca committed Sep 21, 2022
1 parent a7c3d99 commit 1fd7707
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/spring/watcher/listen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ class Listen < Abstract
attr_reader :listener

def start
return unless defined?(@listener)
return if defined?(@listener) && @listener

unless @listener
@listener = ::Listen.to(*base_directories, latency: latency, &method(:changed))
@listener.start
end
@listener = ::Listen.to(*base_directories, latency: latency, &method(:changed))
@listener.start
end

def stop
Expand Down

0 comments on commit 1fd7707

Please sign in to comment.