lib/lookbook/engine.rb in lookbook-1.0.5 vs lib/lookbook/engine.rb in lookbook-1.0.6
- old
+ new
@@ -125,28 +125,26 @@
def init_listeners
config = Lookbook.config
return unless config.listen == true
Listen.logger = Lookbook.logger
- if config.listen_paths.any?
- preview_listener = Listen.to(
- *config.listen_paths,
+ listen_paths = config.listen_paths.uniq
+ if listen_paths.any?
+ preview_listener = Listen.to(*listen_paths,
only: /\.(#{config.listen_extensions.join("|")})$/,
- force_polling: config.listen_use_polling
- ) do |modified, added, removed|
+ force_polling: config.listen_use_polling) do |modified, added, removed|
parser.parse do
run_hooks(:after_change, {modified: modified, added: added, removed: removed})
end
end
register_listener(preview_listener)
end
- if config.page_paths.any?
- page_listener = Listen.to(
- *config.page_paths,
+ page_paths = config.page_paths.uniq
+ if page_paths.any?
+ page_listener = Listen.to(*page_paths,
only: /\.(html.*|md.*)$/,
- force_polling: config.listen_use_polling
- ) do |modified, added, removed|
+ force_polling: config.listen_use_polling) do |modified, added, removed|
changes = {modified: modified, added: added, removed: removed}
reload_ui
run_hooks(:after_change, changes)
end
register_listener(page_listener)