Class: ShopifyCLI::Theme::Extension::DevServer::Hooks::FileChangeHook
- Inherits:
-
Object
- Object
- ShopifyCLI::Theme::Extension::DevServer::Hooks::FileChangeHook
- Defined in:
- lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb
Instance Attribute Summary collapse
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#streams ⇒ Object
readonly
Returns the value of attribute streams.
-
#syncer ⇒ Object
readonly
Returns the value of attribute syncer.
Instance Method Summary collapse
- #call(modified, added, removed, streams: nil) ⇒ Object
-
#initialize(ctx, extension:, syncer:) ⇒ FileChangeHook
constructor
A new instance of FileChangeHook.
Constructor Details
#initialize(ctx, extension:, syncer:) ⇒ FileChangeHook
Returns a new instance of FileChangeHook.
11 12 13 14 15 |
# File 'lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb', line 11 def initialize(ctx, extension:, syncer:) @ctx = ctx @extension = extension @syncer = syncer end |
Instance Attribute Details
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
9 10 11 |
# File 'lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb', line 9 def ctx @ctx end |
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
9 10 11 |
# File 'lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb', line 9 def extension @extension end |
#streams ⇒ Object (readonly)
Returns the value of attribute streams.
9 10 11 |
# File 'lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb', line 9 def streams @streams end |
#syncer ⇒ Object (readonly)
Returns the value of attribute syncer.
9 10 11 |
# File 'lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb', line 9 def syncer @syncer end |
Instance Method Details
#call(modified, added, removed, streams: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/shopify_cli/theme/extension/dev_server/hooks/file_change_hook.rb', line 17 def call(modified, added, removed, streams: nil) @streams = streams modified = paths(modified).select { |file| @extension.extension_file?(file) } added = paths(added).select { |file| @extension.extension_file?(file) } removed = paths(removed) hot_reload(modified) unless modified.empty? reload_page(added, removed) unless (added + removed).empty? end |