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 488
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
3 changed files
with
30 additions
and
37 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,24 +1,8 @@ | ||
// Simple module exposing environment variables to rest of the code. | ||
// Simple wrapper exposing environment variables to rest of the code. | ||
|
||
import jetpack from 'fs-jetpack'; | ||
|
||
// 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 (manifest && manifest.env) { | ||
env = manifest.env; | ||
} else { | ||
// 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'); | ||
} | ||
// The variables have been written to `env.json` by the build process. | ||
var env = jetpack.cwd(__dirname).read('env.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Tests here are for easier maintenance of this boilerplate. | ||
// Feel free to delete this file in your own project. | ||
|
||
import { expect } from 'chai'; | ||
import env from '../env'; | ||
|
||
describe("boilerplate tests", function () { | ||
|
||
it("environment variables should be on their place", function () { | ||
expect(env.name).to.equal('test'); | ||
expect(env.description).to.equal('Add here any environment specific stuff you like.'); | ||
}); | ||
|
||
}); |
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