lighter-config.js
function load (dir, name) {
  // Read config JSON.
  var path = dir + '/' + name + '.json'
  var json
  try {
    json = '' + fs.readFileSync(path)
  } catch (error) {
    if (this.isDebug) {
      console.error('No configuration found in "' + path + '".', error)
    }
    return
  }

  // Replace tokens like $HOST and ${PORT-8080} with environment variables.
  json = json.replace(/\$(\w+)/g, function (match, key) {
    return pe[key] || ''
  }).replace(/\$\{(\w+)(-[^\}]*)?\}/g, function (match, key, value) {
    return pe[key] || value.substr(1)
  })

  // Parse and decorate.
  try {
    var config = JSON.parse(json)
    decorate(this, config)
  } catch (error) {
    return console.error('Invalid JSON in "' + path + '".', json, error)
  }
}
function load (dir, name) {
  // Read config JSON.
  var path = dir + '/' + name + '.json'
  var json
  try {
    json = '' + fs.readFileSync(path)
  } catch (error) {
    if (this.isDebug) {
      console.error('No configuration found in "' + path + '".', error)
    }
    return
  }

  // Replace tokens like $HOST and ${PORT-8080} with environment variables.
  json = json.replace(/\$(\w+)/g, function (match, key) {
    return pe[key] || ''
  }).replace(/\$\{(\w+)(-[^\}]*)?\}/g, function (match, key, value) {
    return pe[key] || value.substr(1)
  })

  // Parse and decorate.
  try {
    var config = JSON.parse(json)
    decorate(this, config)
  } catch (error) {
    return console.error('Invalid JSON in "' + path + '".', json, error)
  }
}
Load a configuration file from the /config directory, and decorate the
module exports with its values.

@param  {String} name  File name, excluding ".json"