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 <[email protected]>
wrote:
Subject: How to pass/get fileName in callBack of watchFile
To: "nodejs" <[email protected]>
Cc: "Anirban Bhattacharya" <[email protected]>
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
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/1148390039.8428448.1448389453065.JavaMail.yahoo%40mail.yahoo.com.
For more options, visit https://groups.google.com/d/optout.