Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
Test env amendments for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
szwacz committed Jun 3, 2016
1 parent 40c02df commit 98e1912
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions app/env.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 98e1912

Please sign in to comment.