Я пытаюсь написать node.js script, который следит за изменениями в каталоге файлов, а затем печатает файлы, которые были изменены. Как я могу изменить этот script так, чтобы он смотрел каталог (а не отдельный файл) и печатал имена файлов в каталоге по мере их изменения?
var fs = require('fs'),
sys = require('sys');
var file = '/home/anderson/Desktop/fractal.png'; //this watches a file, but I want to watch a directory instead
fs.watchFile(file, function(curr, prev) {
alert("File was modified."); //is there some way to print the names of the files in the directory as they are modified?
});