Próbuję napisać skrypt node.js, który obserwuje zmiany w katalogu plików, a następnie drukuje pliki, które zostały zmienione. Jak mogę zmodyfikować ten skrypt, aby obserwował katalog (zamiast pojedynczego pliku) i wyświetlał nazwy plików w katalogu w miarę ich zmiany?
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?
});