Skip to content

⌚ A filewatcher that will create a Websocket server to allow you to know when your file is updated

License

Notifications You must be signed in to change notification settings

JulesGuesnon/Ws-Filewatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ws-Filewatcher

Ws-Filewatcher is a cli that will watch for file change and open a websocket server where it will send a message everytime the file is updated

⚡ Requirements

  • Npm or Yarn, the package managers for NodeJs

🔧 Installation

Here are the instruction to install the cli globally, but you can do it locally on your projects.

npm i -g ws-filewatcher
OR
yarn global add ws-filewatcher

🔥 Usage

Here is the minimum you need to write to launch the service:

ws-filewatcher -f path/to/my/file

⚠️ 'path/to/my/file' isn't necessarily an existing file. You may want to listen for a file creation. So if you make a typo in the path, it won't be considered as an error

Options

Verbose
parameter --verbose
shortcut -v
default value (bool)false
description Allow loggings
Port
parameter --port
shortcut -p
default value (number)9999
description Set the port of the WebSocket server
Command
parameter --command
shortcut -c
default value (string)""
description The command will be run on every file update

Full example

ws-filewatcher -f path/to/my/file -p 8080 -v -c 'cp folder/file other/folder/file'

Client example

The example assume you are running the code inside a browser

const ws = new WebSocket('ws://localhost:9999')

ws.onmessage = () => {
    console.log('My file was updated!')
}

About

⌚ A filewatcher that will create a Websocket server to allow you to know when your file is updated

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published