This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters