/**
 * @fileoverview
 * @author Harry <czy88840616@gmail.com>
 *
 */
var fs = require('fs'),
    path = require('path'),
    mkdirp = require('mkdirp');

function easyconf(jsonPath) {
    this.p = path.resolve(jsonPath);

    if(fs.existsSync(this.p)) {
        try {
            this.json = require(this.p);
        } catch(ex) {
            this.json = {};
        }
    } else {
        this.json = {};
        mkdirp.sync(path.dirname(this.p));
        this.save(function(err) {
            throw err;
        });
    }
}

easyconf.prototype.set = function(name, value) {
    this.json[name] = value;
};

easyconf.prototype.get = function(name) {
    return this.json[name];
};

easyconf.prototype.save = function(callback) {
    fs.writeFile(this.p, JSON.stringify(this.json, null, 4), function(err){
        if (err) {
            callback(err);
        } else {
            callback();
        }
    });
};

module.exports = easyconf;
@@ -259,14 +259,187 @@
     
-try %7B%0A
+var fileStat = fs.statSync( this.p );%0A        %0A        if( !fileStat.isDirectory() )%7B%0A            %0A            if( path.extname( this.p ) === '.json' )%7B%0A                try %7B%0A    
     
@@ -483,16 +483,24 @@
         
+  
+      
 %7D catch(
@@ -509,32 +509,40 @@
 ) %7B%0A            
+  
+      
 this.json = %7B%7D;%0A
@@ -533,32 +533,350 @@
 this.json = %7B%7D;%0A
+                %7D    %0A            %7D%0A            else %7B%0A                var fileContent = fs.readFileSync( this.p ).toString( 'utf-8' );%0A                try %7B%0A                    this.json = JSON.parse( fileContent )%0A                %7D catch(ex) %7B%0A                    this.json = %7B%7D;%0A                %7D    %0A            %7D%0A
         %7D%0A    %7D 

Update lib/easyconf.js