Class: ShopifyCLI::FileSystemListener

Inherits:
Object
  • Object
show all
Includes:
Observable
Defined in:
lib/shopify_cli/file_system_listener.rb

Instance Method Summary collapse

Constructor Details

#initialize(root:, force_poll:, ignore_regex:) ⇒ FileSystemListener

Returns a new instance of FileSystemListener.



9
10
11
12
13
14
15
16
17
18
# File 'lib/shopify_cli/file_system_listener.rb', line 9

def initialize(root:, force_poll:, ignore_regex:)
  @root = root
  @force_poll = force_poll
  @ignore_regex = ignore_regex

  @listener = Listen.to(@root, force_polling: @force_poll, ignore: @ignore_regex) do |updated, added, removed|
    changed
    notify_observers(updated, added, removed)
  end
end

Instance Method Details

#startObject



20
21
22
23
24
# File 'lib/shopify_cli/file_system_listener.rb', line 20

def start
  @listener.start
rescue ArgumentError
  # Ignore errors during the transition of 'listen' events
end

#stopObject



26
27
28
# File 'lib/shopify_cli/file_system_listener.rb', line 26

def stop
  @listener.stop
end