forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Currently we use an environment file for configuration. This is fine, but there are a couple shortcomings 1) the environment file is read directly 2) the environment file is for your own local changes, which is not the same as shared development features 3) it would not be obvious how to add production flags. This PR adds a development.json file, but it would be easy to add a production.php file and read from it when in production. 4) lastly, there aren't any nice helpers. This PR adds an isEnabled feature, but ultimately it would be nice to improve it to support path notation and maybe other functionaality as well.
- Loading branch information
Jason Laster
committed
May 2, 2016
1 parent
bd771b9
commit 2906d2c
Showing
9 changed files
with
108 additions
and
18 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,5 +1,5 @@ | ||
.DS_Store | ||
build | ||
node_modules | ||
environment.json | ||
public/js/configs/development.local.json | ||
npm-debug.log |
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
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
{ | ||
"development": true, | ||
"logging": true | ||
} |
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,3 @@ | ||
{ | ||
|
||
} |
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,34 @@ | ||
"use strict"; | ||
|
||
let config = {}; | ||
|
||
const developmentConfig = require("./development"); | ||
|
||
// Hack, to let local development files be ignored by git | ||
let localDevelopmentConfig; | ||
try { | ||
localDevelopmentConfig = require("./development.local"); | ||
} catch (e) { | ||
localDevelopmentConfig = {}; | ||
} | ||
|
||
config = Object.assign({}, developmentConfig, localDevelopmentConfig); | ||
|
||
// only used for testing purposes | ||
function stubConfig(stub) { | ||
config = stub; | ||
} | ||
|
||
function isEnabled(name) { | ||
return config[name]; | ||
} | ||
|
||
function isDevelopment() { | ||
return isEnabled("development"); | ||
} | ||
|
||
module.exports = { | ||
isEnabled, | ||
isDevelopment, | ||
stubConfig | ||
}; |
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,32 @@ | ||
{ | ||
"globals": { | ||
"after": true, | ||
"afterEach": true, | ||
"before": true, | ||
"beforeEach": true, | ||
"context": true, | ||
"describe": true, | ||
"it": true, | ||
"mocha": true, | ||
"setup": true, | ||
"specify": true, | ||
"suite": true, | ||
"suiteSetup": true, | ||
"suiteTeardown": true, | ||
"teardown": true, | ||
"test": true, | ||
"xcontext": true, | ||
"xdescribe": true, | ||
"xit": true, | ||
"xspecify": true, | ||
"assert": true, | ||
"expect": true, | ||
"equal": true, | ||
"ok": true | ||
}, | ||
"rules": { | ||
"camelcase": 0, | ||
"no-unused-vars": [2, {"vars": "all", "args": "none", "varsIgnorePattern": "run_test"}], | ||
"max-nested-callbacks": [2, 4], | ||
} | ||
} |
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,31 @@ | ||
"use strict"; | ||
|
||
const { isDevelopment, isEnabled, stubConfig } = require("../feature"); | ||
const expect = require("expect.js"); | ||
|
||
describe("feature", () => { | ||
it("isDevelopment", () => { | ||
stubConfig({ development: true }); | ||
expect(isDevelopment()).to.be.truthy; | ||
}); | ||
|
||
it("isDevelopment - not defined", () => { | ||
stubConfig({ }); | ||
expect(isDevelopment()).to.be.falsey; | ||
}); | ||
|
||
it("isEnabled - enabled", function() { | ||
stubConfig({ featureA: true }); | ||
expect(isEnabled("featureA")).to.be.truthy; | ||
}); | ||
|
||
it("isEnabled - disabled", function() { | ||
stubConfig({ featureA: false }); | ||
expect(isEnabled("featureA")).to.be.falsey; | ||
}); | ||
|
||
it("isEnabled - not present", function() { | ||
stubConfig({}); | ||
expect(isEnabled("featureA")).to.be.undefined; | ||
}); | ||
}); |
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