From 5c9369d57a8b2ba34ec843c394afe86a6cbbc5a9 Mon Sep 17 00:00:00 2001 From: billchurch Date: Mon, 12 Feb 2018 10:48:26 -0500 Subject: [PATCH] Updated config path statement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit config path now uses “require.main.filename” which should switch between being used a module or as an application. --- app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 58e7b80..aeefb4e 100644 --- a/app.js +++ b/app.js @@ -1,7 +1,10 @@ // app.js var path = require('path') -var config = require('read-config')(path.join(__dirname, 'config.json')) +// configPath = path.join(__dirname, 'config.json') +configPath = path.join(path.dirname(require.main.filename), 'config.json') +console.log('Reading config from: ' + configPath) +var config = require('read-config')(configPath) var express = require('express') var logger = require('morgan') var session = require('express-session')({