From 4d49e0fb635c40b20f9f30fbccb373e7911682fc Mon Sep 17 00:00:00 2001 From: tigerbot Date: Mon, 12 Jun 2017 11:38:18 -0600 Subject: [PATCH] allowed for specifying not-yet-existent config file --- bin/goldilocks.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/goldilocks.js b/bin/goldilocks.js index 6b72433..68dabe6 100755 --- a/bin/goldilocks.js +++ b/bin/goldilocks.js @@ -87,7 +87,17 @@ function checkConfigLocation(cwd, configFile) { var prom; if (configFile) { filename = path.resolve(cwd, configFile); - prom = fs.readFileAsync(filename); + prom = fs.readFileAsync(filename) + .catch(function (err) { + if (err.code !== 'ENOENT') { + return PromiseA.reject(err); + } + if (path.extname(filename) === '.json') { + return '{}'; + } + return ''; + }) + ; } else { prom = PromiseA.reject('blah') .catch(function () {