Juul / tail-stream

Like `tail -f` but a stream. Like fs.createReadStream but keeps reading as the file grows.
Other
33 stars 13 forks source link

Allow waiting for file to be created #14

Closed jampekka closed 7 years ago

jampekka commented 7 years ago

Currently createReadStream throws an ENOENT if trying to follow a file that does not (yet) exist. This PR adds a waitForCreate option (default off) that makes tail-stream to wait for the file to be created using the same mechanism that currently is used for moved files.

Changes are quite minimal otherwise, but I had to put the initialization code to a separate method that's called at the end of the constructor. Otherwise the necessary methods aren't declared when needed.