diff --git a/readme.md b/readme.md index 0d396eb..30088ea 100644 --- a/readme.md +++ b/readme.md @@ -21,15 +21,16 @@ Alternatively, just run it: All of these are optional. -| Define | Description | -| --------------------------- | ------------------------------------------------------------------------------------------- | -| `-D watch.run=(string)` | command to execute on successful builds | -| `-D watch.port=(integer)` | use this port for the completion server | -| `-D watch.connect` | connect to a running completion server (use with `watch.port`) | -| `-D watch.excludeRoot` | exclude watching the root directory (see [#3](https://github.com/benmerckx/watch/issues/3)) | -| `-D watch.exclude=(string)` | exclude this path from the watcher (can be repeated for multiple paths) | -| `-D watch.include=(string)` | include this path in the watcher (can be repeated for multiple paths) | -| `-D watch.verbose` | extra log before and after every build | +| Define | Description | +| --------------------------- | ------------------------------------------------------------------------------------------------- | +| `-D watch.run=(string)` | command to execute on successful builds | +| `-D watch.port=(integer)` | use this port for the completion server | +| `-D watch.connect` | connect to a running completion server (use with `watch.port`) | +| `-D watch.excludeRoot` | exclude watching the root directory (see [#3](https://github.com/benmerckx/watch/issues/3)) | +| `-D watch.exclude=(string)` | exclude this path from the watcher (can be repeated for multiple paths) | +| `-D watch.include=(string)` | include this path in the watcher (can be repeated for multiple paths) | +| `-D watch.verbose` | extra log before and after every build | +| `-D watch.extensions=(string)`| extensions to watch, seperated by comma but without dot prefix (will watch '.hx files per default)| ### Example diff --git a/src/watch/Watch.hx b/src/watch/Watch.hx index 6018877..a2de872 100644 --- a/src/watch/Watch.hx +++ b/src/watch/Watch.hx @@ -439,11 +439,16 @@ function register() { for (path in paths) { switch FsEvent.init(loop) { case Ok(watcher): - watcher.start(path, [], - res -> + + watcher.start(path, [], res -> switch res { case Ok({file: (_.toString()) => file}): - if (StringTools.endsWith(file, '.hx')) { + final extensions = switch Context.definedValue('watch.extensions') { + case null: ['.hx']; + case v: v.split(',').map(s -> '.$s'); + } + final resExtension = file.substring(file.lastIndexOf('.')); + if (extensions.contains(resExtension)) { for (exclude in excludes) { if (isSubOf(FileSystem.absolutePath(file), exclude)) return; @@ -471,4 +476,4 @@ function register() { }); }); loop.loop(); -} +} \ No newline at end of file