<commit_before>'use strict'

var ini = require('iniparser')
var _ = require('lodash')
var environment = process.env.NODE_ENV || 'development'

module.exports = function (settingsDir) {
  var properties_default = {}
  var properties_custom = {}
  try {
    properties_default = ini.parseSync(settingsDir + 'properties_' + environment + '.conf')
  } catch (e) {
    throw new Error('Can\'t find default properties')
  }

  properties_default.ENV.type = environment

  properties_default.server.https_port = process.env.SSL_PORT || properties_default.server.https_port
  properties_default.server.http_port = process.env.PORT || properties_default.server.http_port
  properties_default.server.name = process.env.SERVERNAME || properties_default.server.name
  properties_default.ssl.key = process.env.KEY_FILE || properties_default.ssl.key
  properties_default.ssl.crt = process.env.CRT_FILE || properties_default.ssl.crt

  properties_default.JWT.jwtTokenSecret = process.env.JWTTOKENSECRET || properties_default.JWT.jwtTokenSecret

  properties_default.db.name = process.env.DBCOLLECTION || properties_default.db.name
  properties_default.db.host = process.env.DBHOST || properties_default.db.host
  properties_default.db.port = process.env.DBPORT || properties_default.db.port
  properties_default.db.user = process.env.DBUSER || properties_default.db.user
  properties_default.db.pass = process.env.DBPASS || properties_default.db.pass

  properties_default.logentries.api_key = process.env.LOG_API_KEY || properties_default.logentries.api_key

  if (environment !== 'production') {
    try {
      properties_custom = ini.parseSync(settingsDir + 'properties.conf')
      properties_default = _.merge(properties_default, properties_custom)
    } catch (e) {
      console.warn('Can\'t find properties.conf so using default configuration')
    }
  }
  return properties_default
}<commit_msg>Fixed crashing when missing properties<commit_after>'use strict'

var ini = require('iniparser')
var _ = require('lodash')
var environment = process.env.NODE_ENV || 'development'

module.exports = function (settingsDir) {
  var properties_default = {}
  var properties_custom = {}
  try {
    properties_default = ini.parseSync(settingsDir + 'properties_' + environment + '.conf')
  } catch (e) {
    throw new Error('Can\'t find default properties')
  }

  properties_default.ENV.type = environment
  properties_default.server.https_port = process.env.SSL_PORT || properties_default.server && properties_default.server.https_port
  properties_default.server.http_port = process.env.PORT || properties_default.server && properties_default.server.http_port
  properties_default.server.name = process.env.SERVERNAME || properties_default.server && properties_default.server.name
  properties_default.ssl.key = process.env.KEY_FILE || properties_default.ssl && properties_default.ssl.key
  properties_default.ssl.crt = process.env.CRT_FILE || properties_default.ssl && properties_default.ssl.crt
  properties_default.JWT.jwtTokenSecret = process.env.JWTTOKENSECRET || properties_default.JWT && properties_default.JWT.jwtTokenSecret
  properties_default.db.name = process.env.DBCOLLECTION || properties_default.db && properties_default.db.name
  properties_default.db.host = process.env.DBHOST || properties_default.db && properties_default.db.host
  properties_default.db.port = process.env.DBPORT || properties_default.db && properties_default.db.port
  properties_default.db.user = process.env.DBUSER || properties_default.db && properties_default.db.user
  properties_default.db.pass = process.env.DBPASS || properties_default.db && properties_default.db.pass
  properties_default.logentries.api_key = process.env.LOG_API_KEY || properties_default.logentries && properties_default.logentries.api_key

  if (environment !== 'production') {
    try {
      properties_custom = ini.parseSync(settingsDir + 'properties.conf')
      properties_default = _.merge(properties_default, properties_custom)
    } catch (e) {
      console.warn('Can\'t find properties.conf so using default configuration')
    }
  }
  return properties_default
}
{'fraction_non_alphanumeric': 0.1081474296799224, 'fraction_numerical': 0.0, 'mean_word_length': 5.111111111111111, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2082188', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1185, 'n_words': 198}