const fs = require("fs");
const path = require("path");

function getValue(obj, pathArr, def) {
    let nextPath = pathArr.shift();
    if (nextPath) {
        return (pathArr.length > 0) ?
            (obj.hasOwnProperty(nextPath) ? getValue(obj[nextPath], pathArr, def) : def) :
            obj[nextPath] || def;
    }
    return obj || def;
}

class Configuration {

    constructor(data = {}) {
        this.config = data;
    }

    get(path, def) {
        return getValue(this.config, path.split("."), def);
    }

}

Configuration.loadFromFile = function(filename, allowEmpty = false) {
    let fileContents;
    try {
        fileContents = JSON.parse(fs.readFileSync(filename));
    } catch (err) {
        if (allowEmpty) {
            console.log("No configuration found locally, loading defaults...");
            // @todo load defaults
            return new Configuration();
        } else {
            throw err;
        }
    }
    return new Configuration(fileContents);
};

Configuration.loadLocalConfig = function() {
    return Configuration.loadFromFile(path.resolve(__dirname, "../config.json"), true);
};

module.exports = Configuration;

@@ -50,16 +50,60 @@
 ath%22);%0A%0A
+const fileExists = require(%22file-exists%22);%0A%0A
 function
@@ -384,16 +384,316 @@
 def;%0A%7D%0A%0A
+function placeConfig(configPath) %7B%0A    if (fileExists(configPath) !== true) %7B%0A        const baseConfigPath = path.resolve(__dirname, %22../resources/config.base.json%22);%0A        let baseConfig = fs.readFileSync(baseConfigPath, %22utf8%22);%0A        fs.writeFileSync(configPath, baseConfig, %22utf8%22);%0A    %7D%0A%7D%0A%0A
 class Co
@@ -1384,42 +1384,25 @@
     
-return Configuration.loadFromFile(
+let configPath = 
 path
@@ -1438,16 +1438,95 @@
 g.json%22)
+;%0A    placeConfig(configPath);%0A    return Configuration.loadFromFile(configPath
 , true);

Create config.json if not exists