I'm having an issue returning a value after determining something from fs.stat()
, here is the example below:
function checkFile(fileName, type) {
var status = false;
// Get the stats assocatied to this file
fs.stat(fileName, function (error, stats) {
// get the time when the file was last modified
var fileTime = moment(stats.mtime);
if(type === "behind") {
var query = moment(main.repoTime).isAfter(fileTime);
} else if(type === "updated") {
var query = moment(fileTime).isAfter(main.repoTime);
}
status = query;
});
return status;
}
What am I exactly doing wrong here? If I took fs.stat
it works fine?