I'm getting an array of files, and then I want to add the date and size properties to each of those file objects, but using the code below, they don't get added. I know that's my fs.statSync(p + file).mtime.getTime() and fs.statSync(p + file).size have values in them.
var files = fs.readdirSync(p);
files.sort(function(a, b) {
return fs.statSync(p + a).mtime.getTime() -
fs.statSync(p + b).mtime.getTime();
});
files.forEach(function(file) {
file.date = fs.statSync(p + file).mtime.getTime();
file.size = fs.statSync(p + file).size;
});
console.log('files::'+files); // doesn' have the new file.date and file.size property.