From 43f9b2511d22e840e2416938e388a7d5578bdaef Mon Sep 17 00:00:00 2001 From: Johann du Toit Date: Sun, 19 Jul 2015 05:29:44 +0200 Subject: [PATCH] Fixed the path issue when packaged to NPM --- src/drivers/npm/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/drivers/npm/index.js b/src/drivers/npm/index.js index 153273a70..dd1ed8229 100644 --- a/src/drivers/npm/index.js +++ b/src/drivers/npm/index.js @@ -81,7 +81,20 @@ function getHTMLFromUrl(url, cb) { } function getAppsJson(cb) { - fs.readFile(path.resolve(__dirname, '../../apps.json'), 'utf8', function(err, data) { + + // depending on evironment select a direction to the path + var appsFileStr = path.resolve(__dirname, './apps.json'); + + // handle the environment variable if it's there + if(process.env.NODE_ENV == 'testing') { + + // set the apps.json to testing stage + appsFileStr = path.resolve(__dirname, '../../apps.json'); + + } + + // read in the file + fs.readFile(appsFileStr, 'utf8', function(err, data) { if (err) throw err; return cb(null, JSON.parse(data)); });