This will take filePath
as a function parameter and reads the file via fs
module and get the file and converts it's size into more humanly readable format.
function getFileSize(filePath) {
var stats = fs.statSync(filePath);
// console.log('stats', stats);
var size = stats["size"];
// convert it to humanly readable format.