Skip to content

Commit ca2537b

Browse files
authored
Merge pull request #22 from fabrix-app/v1.5
[fix] #21 #16
2 parents babf2db + 87ba7a4 commit ca2537b

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

lib/Configuration.ts

+6
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ export class Configuration extends Map<any, any> {
207207
if (value === null) {
208208
// Do Nothing
209209
}
210+
else if (typeof value === 'undefined') {
211+
// Do Nothing
212+
}
210213
else if (Array.isArray(value)) {
211214
// Do Nothing
212215
}
@@ -216,6 +219,9 @@ export class Configuration extends Map<any, any> {
216219
else if (typeof value === 'string') {
217220
// Do Nothing
218221
}
222+
else if (typeof value === 'function') {
223+
// Do Nothing
224+
}
219225
else {
220226
this.set(key, Core.defaultsDeep(this.get(key), value))
221227
}

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fabrix/fabrix",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"description": "Strongly Typed Modern Web Application Framework for Node.js",
55
"keywords": [
66
"framework",

test/lib/Configuration.test.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ describe('lib.Configuration', () => {
2121
array: [2, 3, 4],
2222
subobj: {
2323
attr: 'b'
24-
}
24+
},
25+
func: (v = 0) => { return 1 + v }
2526
}
2627
},
2728
envTest2: {
@@ -37,7 +38,8 @@ describe('lib.Configuration', () => {
3738
subobj: {
3839
attr: 'b'
3940
},
40-
int2: 2
41+
int2: 2,
42+
func: (v = 0) => { return 2 + v }
4143
}
4244
},
4345
envTest3: {
@@ -73,7 +75,8 @@ describe('lib.Configuration', () => {
7375
subobj: {
7476
attr: 'a'
7577
},
76-
nullValue: null
78+
nullValue: null,
79+
func: (v = 0) => { return 3 + v }
7780
}
7881
}
7982
})
@@ -144,6 +147,8 @@ describe('lib.Configuration', () => {
144147
assert.equal(config.customObject.array[0], 2)
145148
assert(typeof config.customObject.subobj === 'object')
146149
assert.equal(config.customObject.subobj.attr, 'b')
150+
assert(typeof config.customObject.func === 'function')
151+
assert.equal(config.customObject.func(1), 2)
147152
})
148153

149154
it('should merge partial custom env config', () => {
@@ -158,6 +163,8 @@ describe('lib.Configuration', () => {
158163
assert.equal(config.customObject.array[0], 1)
159164
assert(typeof config.customObject.subobj === 'object')
160165
assert.equal(config.customObject.subobj.attr, 'b')
166+
assert(typeof config.customObject.func === 'function')
167+
assert.equal(config.customObject.func(1), 3)
161168
})
162169

163170
it('should merge new custom attr in env config', () => {
@@ -173,6 +180,8 @@ describe('lib.Configuration', () => {
173180
assert(typeof config.customObject.subobj === 'object')
174181
assert.equal(config.customObject.subobj.attr, 'b')
175182
assert.equal(config.customObject.int2, 2)
183+
assert(typeof config.customObject.func === 'function')
184+
assert.equal(config.customObject.func(1), 3)
176185
})
177186

178187
it('should not override any configs if NODE_ENV matches no env', () => {
@@ -357,7 +366,10 @@ describe('lib.Configuration', () => {
357366
subobj: {
358367
attr: 'b'
359368
},
360-
newValue: 'a'
369+
newValue: 'a',
370+
func: (v = 4) => {
371+
return v + 1
372+
}
361373
}
362374
}, 'merge')
363375
// Old Value should be replaced?
@@ -370,6 +382,8 @@ describe('lib.Configuration', () => {
370382
assert.deepEqual(config.get('customObject.stringArray'), ['one', 'two', 'three'])
371383
assert.deepEqual(config.get('customObject.stringArray2'), ['one', 'two', 'three'])
372384

385+
assert.equal(config.get('customObject.func')(4), 7)
386+
373387
})
374388

375389
it('should completely ignore replaceable values', () => {

0 commit comments

Comments
 (0)