Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/faustinoaq/kemal-watcher
Kemal plugin to watch files and live-reload the browser
https://github.com/faustinoaq/kemal-watcher
crystal kemal
Last synced: 15 days ago
JSON representation
Kemal plugin to watch files and live-reload the browser
- Host: GitHub
- URL: https://github.com/faustinoaq/kemal-watcher
- Owner: faustinoaq
- License: mit
- Created: 2017-03-29T20:14:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-17T21:14:51.000Z (over 6 years ago)
- Last Synced: 2024-08-01T17:34:04.923Z (3 months ago)
- Topics: crystal, kemal
- Language: Crystal
- Homepage:
- Size: 27.3 KB
- Stars: 20
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - kemal-watcher - Kemal plugin to watch files and live-reload the browser (Development Tools)
- awesome-crystal - kemal-watcher - Kemal plugin to watch files and live-reload the browser (Development Tools)
README
# kemal-watcher
[![Build Status](https://travis-ci.org/faustinoaq/kemal-watcher.svg?branch=master)](https://travis-ci.org/faustinoaq/kemal-watcher)
[Kemal](https://github.com/kemalcr/kemal) plugin to watch files like client stuff.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
kemal-watcher:
github: faustinoaq/kemal-watcher
```## Usage
Add `Kemal.watch` to your Kemal app to watch files.
```crystal
require "kemal"
require "kemal-watcher"get "/" do
File.read "src/views/index.html"
endfiles = [
"public/*.js",
"public/*.html"
]Kemal.watch(files)
Kemal.run
```# How does it works?
`Kemal.watch` uses [watcher](https://github.com/faustinoaq/watcher) to watch files and add a new handler to Kemal that inject a script in the response. When a change is detected an event handler is executed and then send a reload signal to the clients.
## Contributing
1. Fork it ( https://github.com/faustinoaq/kemal-watcher/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request## Disclaimer
`Kemal.watch` is intended for use in a development environment.
## Contributors
- [faustinoaq](https://github.com/faustinoaq) Faustino Aguilar - creator, maintainer