From b9ecb4db413dba17648df581bbe38b0a138046e2 Mon Sep 17 00:00:00 2001 From: Radek Stepan Date: Tue, 1 Oct 2013 11:12:48 +0100 Subject: [PATCH] better handling of missing config; closes #22 --- build/build.js | 4 +++- src/modules/config.coffee | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/build.js b/build/build.js index ee11580..cafef8f 100644 --- a/build/build.js +++ b/build/build.js @@ -28116,7 +28116,9 @@ module.exports = function(cb) { wait = true; return request.config(function(err, result) { var field, k, v, validator; - config = (err ? {} : result); + if (err || !_.isObject(result)) { + config = {}; + } for (k in defaults) { v = defaults[k]; if (config[k] == null) { diff --git a/src/modules/config.coffee b/src/modules/config.coffee index 9fcb349..014e8b3 100644 --- a/src/modules/config.coffee +++ b/src/modules/config.coffee @@ -44,7 +44,7 @@ module.exports = (cb) -> # Make the request. request.config (err, result) -> # We do not strictly require config files. - config = ( if err then { } else result ) + config = {} if err or not _.isObject result # Tack on defaults? ( config[k] ?= v for k, v of defaults )