From 2a6ec3e95508c2cf974b5d1d01e53498123715b8 Mon Sep 17 00:00:00 2001 From: Guillermo Rauch Date: Thu, 7 Jul 2016 07:50:18 -0700 Subject: [PATCH] config: add more error handling --- config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/config.js b/config.js index 0f6d19d2..8b1f4a5a 100644 --- a/config.js +++ b/config.js @@ -17,9 +17,12 @@ function watch () { function exec (str) { const script = new vm.Script(str); - const mod = {}; - script.runInNewContext(mod); - const cfg = mod.exports.config; + const module = {}; + script.runInNewContext({ module }); + const cfg = module.exports.config; + if (!module.exports) { + throw new Error('Error reading configuration: `module.exports` not set'); + } if (!cfg) { throw new Error('Error reading configuration: `config` key is missing'); }