<commit_before>'use strict'
var fs = require("fs"),
  path = require("path"),
  userData = require("electron").app.getPath("userData"),
  settings;
try {
  settings = JSON.parse(fs.readFileSync(path.join(userData, "config.json")));
}catch(err){
  if(err.code === "ENOENT"){
    settings = {
        "port": {
            "name": "Remote Control Port",
            "type": "number",
            "value": 3000
        },
        "library": {
            "name": "Download Location",
            "type": "directory",
            "value": path.join(userData, "movies")
        },
        "notify": {
            "name": "Notifications",
            "type": "boolean",
            "value": true
        }
    };
  }
}

//store and retreive settings

module.exports = {
  //store setting to config.json
  store: function(setting, prop, value){
    settings[setting] = (typeof settings[setting] === 'undefined') ? {} : settings[setting];
    settings[setting][prop] = value;
    fs.writeFileSync(path.join(userData, "config.json"), JSON.stringify(settings));
  },
  //get specific setting
  get: function(setting){
    return settings[setting];<commit_msg>Fixed bug when adding additional settings<commit_after>'use strict'
var fs = require("fs"),
  path = require("path"),
  userData = require("electron").app.getPath("userData"),
  settings,
  template = {
    "port": {
        "name": "Remote Control Port",
        "type": "number",
        "value": 3000
    },
    "library": {
        "name": "Download Location",
        "type": "directory",
        "value": path.join(userData, "movies")
    },
    "notify": {
        "name": "Notifications",
        "type": "boolean",
        "value": true
    },
    "updates": {
        "name": "Auto Updates",
        "type": "boolean",
        "value": true
    }
};

try {
  settings = JSON.parse(fs.readFileSync(path.join(userData, "config.json")));
}catch(err){
  if(err.code === "ENOENT"){
    settings = template;
  }
}

Object.keys(template).filter(function(key){
  return (Object.keys(settings).indexOf(key) === -1);
}).forEach(function(key){
  settings[key] = template[key];
})


//store and retreive settings

module.exports = {
  //store setting to config.json
  store: function(setting, prop, value){
    settings[setting] = (typeof settings[setting] === 'undefined') ? {} : settings[setting];
    settings[setting][prop] = value;
    fs.writeFileSync(path.join(userData, "config.json"), JSON.stringify(settings));
  },
  //get specific setting
  get: function(setting){
    return settings[setting];
{'fraction_non_alphanumeric': 0.1782216999608304, 'fraction_numerical': 0.0035252643948296123, 'mean_word_length': 2.893292682926829, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7411259', 'n_tokens_mistral': 786, 'n_tokens_neox': 774, 'n_words': 167}