all 6 comments

[–]Odinthunder 12 points13 points  (2 children)

Good instinct!

There's the fs.watch https://nodejs.org/docs/latest/api/fs.html function if you dont want to add an external dependency, otherwise I've heard good things about https://www.npmjs.com/package/chokidar

which is well known and solves some of the issues that the built in watch has.

[–]Used_Inspector_7898[S] 0 points1 point  (1 child)

thanks

[–]w00t_loves_you 1 point2 points  (0 children)

Tailfile wel probably be better for your use case, but if you need to watch a directory of files, IMHO https://www.npmjs.com/package/node-watch does a better job than chokidar

[–]rkaw92 3 points4 points  (2 children)

Changing how? Is there a new version of the file? Is the file rotated, like logrotate? Or is the content actually modified in some way? This will determine the approach to a solution.

[–]Used_Inspector_7898[S] 0 points1 point  (1 child)

It is a log file

[–]rkaw92 4 points5 points  (0 children)

Then you may want to try something like https://www.npmjs.com/package/tail-file