Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Add datacenter support for common.json #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions get-config-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ function getConfigState(dirname, opts) {
null,
// load ./config/NODE_ENV.json
NODE_ENV ? join(configFolder, NODE_ENV + '.json') : null,
// load ./config/common.DATACENTER.json
dc ?
join(configFolder, 'common.' + dc.datacenter + '.json') :
null,
// load ./config/common.json
join(configFolder, 'common.json'),
// load defaults
Expand Down
16 changes: 13 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,16 @@ test('config loads from datacenter file', withFixtures(__dirname, {
a: 'a',
b: {
c: 'c',
d: 'd'
}
d: 'd',
e: 'e'
},
f: 'f'
}),
'common.peak1.json': JSON.stringify({
b: {
e: 'e2'
},
f: 'f2'
}),
'production.json': JSON.stringify({
b: {
Expand All @@ -283,7 +291,9 @@ test('config loads from datacenter file', withFixtures(__dirname, {
assert.equal(config.get('a'), 'a3');
assert.equal(config.get('b.c'), 'c2');
assert.equal(config.get('b.d'), 'd');
assert.deepEqual(config.get('b'), { c: 'c2', d: 'd' });
assert.equal(config.get('b.e'), 'e2');
assert.deepEqual(config.get('b'), { c: 'c2', d: 'd', e: 'e2' });
assert.equal(config.get('f'), 'f2');

assert.end();
}));
Expand Down