I got this code:
var log = (function () {
 'use strict';
 var fs = require('fs'), baseName='', path = require('path');
 fs.readFile('./config.json', {encoding : 'utf-8'}, function (err, data) {
            if (!err) {
                var parsedConfig = JSON.parse(data);
                logPath = parsedConfig.logFile;
                baseName = path.basename(logPath, '.log');
                if (logPath.length==0 )
                    logPath = './alteredFile.log';
            } else {
                throw err;
            }
        });
}());
var module;
module.exports = log;
I'm trying to set variable baseName but out side of fs.readFile callback it's not set and still empty! how can Iresolve this?
 
    