From 98e19127192e3e7efde05bf1fac79b99cd5f13ba Mon Sep 17 00:00:00 2001 From: Jakub Szwacz Date: Fri, 3 Jun 2016 07:20:35 +0200 Subject: [PATCH] Test env amendments for windows --- app/env.js | 30 ++++++++++++++++-------------- package.json | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/env.js b/app/env.js index 03f137911..e2b2ad235 100644 --- a/app/env.js +++ b/app/env.js @@ -1,22 +1,24 @@ -// Simple module exposes environment variables to rest of the code. +// Simple module exposing environment variables to rest of the code. import jetpack from 'fs-jetpack'; -let env; +// Normal way of obtaining env variables: They are written to package.json file. +var env; +var app; +if (process.type === 'renderer') { + app = require('electron').remote.app; +} else { + app = require('electron').app; +} +var appDir = jetpack.cwd(app.getAppPath()); +var manifest = appDir.read('package.json', 'json'); -if (process.env.NODE_ENV === 'test') { - // For test environment 'normal way' won't work, so grab the variables directly. - env = jetpack.cwd(__dirname).read('../config/env_test.json', 'json'); +if (manifest && manifest.env) { + env = manifest.env; } else { - // Normal way of obtaining env variables: They are written to package.json file. - let app; - if (process.type === 'renderer') { - app = require('electron').remote.app; - } else { - app = require('electron').app; - } - let appDir = jetpack.cwd(app.getAppPath()); - env = appDir.read('package.json', 'json').env; + // If 'normal way' failed, assume we're in test environment (where normal + // way won't work) and grab the variables in a ditry way. + env = jetpack.cwd(__dirname).read('../config/env_test.json', 'json'); } export default env; diff --git a/package.json b/package.json index 86d61dd5a..67617f980 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "release": "gulp release --env=production", "start": "gulp start", "pretest": "gulp build --env=test", - "test": "NODE_ENV=test electron-mocha build --renderer", + "test": "electron-mocha build --renderer", "install-native": "node ./tasks/install_native_module" } }