fs-broadcaster
A websocket server that broadcasts file system events. Can be run from the commandline.
Installation
# to use as cli
npm install -g fs-broadcaster
# to use as module
npm install --save fs-broadcaster
Usage
Cli
Usage: cli [options]
Starts a websocket server and broadcasts fs events in a given directory
Options:
-h, --help output usage information
-V, --version output the version number
-d, --dir <path> Specify which directory to watch, can recieve a file glob. Defaults to current directory.
-p, --port Port that will be used. Defaults to 1992
Module
;; // Create new broadcaster and pass in the files to watch and portlet broadcaster = 8080; // Start socket server and begin to broadcast fs eventsbroadcaster; // List all watched filesbroadcaster; // Destroy socket server and remove fs listenersbroadcaster; // Get chokidar instancebroadcaster;
Example
Output
The following will be broadcast to all connected clients when an fs event occurs.
event: 'change' path: 'lib/styles/main.css' ext: '.css' stamp: '2017-02-27T21:18:25.929Z'
Live reloading on client
A live reloading example using the browser's websocket api and the output from fs-broadcaster.
<!-- your app -->