Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/capaj/chokidar-socket-emitter
a simple chokidar watcher which emits events to all connected socket.io clients
https://github.com/capaj/chokidar-socket-emitter
event-emitter filesystem socket-io watcher
Last synced: 4 months ago
JSON representation
a simple chokidar watcher which emits events to all connected socket.io clients
- Host: GitHub
- URL: https://github.com/capaj/chokidar-socket-emitter
- Owner: capaj
- License: mit
- Created: 2015-10-07T16:29:14.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-07T14:05:33.000Z (almost 8 years ago)
- Last Synced: 2024-09-29T01:02:09.129Z (4 months ago)
- Topics: event-emitter, filesystem, socket-io, watcher
- Language: JavaScript
- Size: 36.1 KB
- Stars: 28
- Watchers: 3
- Forks: 22
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# chokidar-socket-emitter
a simple chokidar watcher and socket.io server which emits file system events to all connected socket.io clients. Primarily it should serve as an event source for **[systemjs-hot-reloader](https://github.com/capaj/systemjs-hot-reloader)** but you can use it any other way.## Install
```
npm i -D chokidar-socket-emitter
```## CLI usage
```
npm i -g chokidar-socket-emitter
chokidar-socket-emitter -l 1234
```available CLI options:
```
-l, --port
-p, --path
-d, --dir
-P, --poll # use when you have a disk mounted over network for example
-q, --quiet # don't print out any logs
```By default listens on port 5776.
## NPM script usage
Combined with [browser-sync](https://browsersync.io/):``` json
"scripts": {
"start": "npm run serve & npm run watch",
"serve": "browser-sync start --server",
"watch": "chokidar-socket-emitter"
},
```
Start by running:
```
npm start
```## Programatic usage
```javascript
var chokidarEvEmitter = require('chokidar-socket-emitter')
chokidarEvEmitter({port: 8090}) //path is taken from jspm/directories/baseURL or if that is not set up, '.' is used
//or specify the path
chokidarEvEmitter({port: 8090, path: '.'})//you can also supply an http server instance, that way it will run within your server, no need for extra port
require('chokidar-socket-emitter')({app: server})
```## FAQ
#### Does chokidar have problems with watching drives mounted from VMs hosts/network?
Yes and if you want it to work, use additional opts property to switch to polling mode
```
chokidarEvEmitter({port: 8090, path: '.', chokidar: {usePolling: true}})
```