You can use fs.readlink :
fs.readlink(file, function(err, realFile) { if(!err) { fs.watch(realFile, ... ); } });
Of course, you could fall in love and write a small wrapper that can watch a file or link, so you don't need to think about it.
UPDATE: Here is a shell for the future:
/** Helper for watchFile, also handling symlinks */ function watchFile(path, callback) { // Check if it a link fs.lstat(path, function(err, stats) { if(err) { // Handle errors return callback(err); } else if(stats.isSymbolicLink()) { // Read symlink fs.readlink(path, function(err, realPath) { // Handle errors if(err) return callback(err); // Watch the real file fs.watch(realPath, callback); }); } else { // It not a symlink, just watch it fs.watch(path, callback); } }); }
source share