Class: Esp::Watcher
- Inherits:
-
Object
- Object
- Esp::Watcher
- Defined in:
- lib/esp/watcher.rb
Overview
File-watch-driven rebuild. Watches a mod’s source directory (and its scripts/, i18n/, etc. subtrees) and re-invokes Esp::Mw::Builder on any matching change. Blocks until SIGINT.
Constant Summary collapse
- WATCHED_EXTS =
%w[.json .rb .py .js .mjs .ts .mwscript .yaml .yml].freeze
Instance Method Summary collapse
-
#initialize(mod, locale: nil, root: Esp::ROOT, output: $stdout) ⇒ Watcher
constructor
A new instance of Watcher.
- #start ⇒ Object
Constructor Details
Instance Method Details
#start ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/esp/watcher.rb', line 17 def start source_dir = File.dirname(Esp::Mw::Loader.resolve(@mod, root: @root)) rebuild log "watching #{relative(source_dir)} (Ctrl-C to stop)" listener = Listen.to(source_dir, only: extensions_regex, latency: 0.2) { rebuild } listener.start trap('INT') do listener.stop log 'stopped.' exit 0 end sleep end |