I'm watching a file in Node.js and would like to obtain the size of the file each time it changes. How can this be done with fs.watchFile
?
This is what I'm currently doing:
fs.watchFile(file, function(curr, prev) {
// determine file size
});
var fs = require('fs');
fs.watchFile('some.file', function () {
fs.stat('some.file', function (err, stats) {
console.log(stats.size);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With