I am monitoring the file for content change using Node.js watch File. Its succesfully calling the event when content of the file is modified
fs.watchFile(filePath, ()=> {
console.log('File Changed ...');
file = fs.readFileSync(filePath);
console.log('File content at : ' + new Date() + ' is \n' + file);
});
from Hello to Hello World
I want only the World not all the contents of the file, can any one suggest the most efficient way to achieve this or any node package to achieve this. I looked at node package Chokidar but that also monitors the change.
I found a JAVA Solution for that, but not sure of any Node.js alternative for that.
How to watch file for new content and retrieve that content
I did my research tried to follow these posts
https://nodejs.org/api/fs.html#fs_fs_watchfile_filename_options_listener
http://www.codingdefined.com/2015/09/how-to-monitor-file-for-modifications.html
Observe file changes with node.js
Thanks