ファイルのディレクトリの変更を監視し、変更されたファイルを出力する node.js スクリプトを作成しようとしています。このスクリプトを変更して、(個々のファイルではなく) ディレクトリを監視し、変更されたディレクトリ内のファイルの名前を出力するようにするにはどうすればよいですか?
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?
});