Module: Middleman::CoreExtensions::FileWatcher

Defined in:
lib/middleman-core/core_extensions/file_watcher.rb

Defined Under Namespace

Modules: InstanceMethods Classes: API

Constant Summary collapse

IGNORE_LIST =
[
  /^bin(\/|$)/,
  /^\.bundle(\/|$)/,
  /^vendor(\/|$)/,
  /^node_modules(\/|$)/,
  /^\.sass-cache(\/|$)/,
  /^\.cache(\/|$)/,
  /^\.git(\/|$)/,
  /^\.gitignore$/,
  /\.DS_Store/,
  /^\.rbenv-.*$/,
  /^Gemfile$/,
  /^Gemfile\.lock$/,
  /~$/,
  /(^|\/)\.?#/,
  /^tmp\//
]

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object Also known as: included

Once registered


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/middleman-core/core_extensions/file_watcher.rb', line 29

def registered(app)
  app.send :include, InstanceMethods

  app.config.define_setting :file_watcher_ignore, IGNORE_LIST, 'Regexes for paths that should be ignored when they change.'

  # Before parsing config, load the data/ directory
  app.before_configuration do
    files.reload_path(config[:data_dir])
  end

  app.after_configuration do
    config[:file_watcher_ignore] << %r{^#{config[:build_dir]}(\/|$)}
  end

  # After config, load everything else
  app.ready do
    files.reload_path('.')
  end
end