Sha256: 46a615965560fb632e7d3a71afcfae3892f8ff6f882c078dcc13c98ee4b16885
Contents?: true
Size: 1.32 KB
Versions: 14
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true require "shopify_cli/file_system_listener" require "shopify_cli/theme/dev_server" require "forwardable" module ShopifyCLI module Theme module Extension class DevServer < ShopifyCLI::Theme::DevServer # Watches for file changes and publish events to the theme class Watcher extend Forwardable def_delegators :@listener, :add_observer, :changed, :notify_observers def initialize(ctx, extension:, syncer:, poll: false) @ctx = ctx @extension = extension @syncer = syncer @listener = FileSystemListener.new(root: @extension.root.to_s, force_poll: poll, ignore_regex: nil) add_observer(self, :notify_updates) end def start @listener.start end def stop @listener.stop end def notify_updates(modified, added, removed) @syncer.enqueue_updates(files(modified).select { |file| @extension.extension_file?(file) }) @syncer.enqueue_creates(files(added).select { |file| @extension.extension_file?(file) }) @syncer.enqueue_deletes(files(removed)) end def files(paths) paths.map { |file| @extension[file] } end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems