I also Tried the below option
for(i=0;i<fileNames.length;i++)
{
console.log(fileNames[i]);
fs.watchFile(fileNames[i],function(prev,cur){
console.log(fileNames[i]);
doAll(fileNames[i]);
});
}
function doAll(fileName)
{
console.log(fileName);
}
But the console.log() in callback printing undefined.
--------------------------------------------
On Tue, 24/11/15, Anirban Bhattacharya <
anirbanbhat...@gmail.com> wrote:
Subject: How to pass/get fileName in callBack of watchFile
To: "nodejs" <
nod...@googlegroups.com>
Cc: "Anirban Bhattacharya" <
anirbanbhat...@yahoo.co.in>
Date: Tuesday, 24 November, 2015, 10:22 AM
HI,
I have to watch multiple files, and I don't want to
create seperate callback function for each.
fs.watchFile(testFile,callBack);
function callBack(cur,prev) {
console.log("in Test..");
var data='';
}
How can I get the fileName from the callBack function?
Thanks,
Anirban