File tree 4 files changed +24
-3
lines changed
4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @secjs/utils" ,
3
- "version" : " 1.9.3 " ,
3
+ "version" : " 1.9.4 " ,
4
4
"description" : " Utils functions and classes for Node.js" ,
5
5
"license" : " MIT" ,
6
6
"author" : " João Lenon <lenon@athenna.io>" ,
Original file line number Diff line number Diff line change @@ -99,6 +99,9 @@ export class Config {
99
99
}
100
100
101
101
Debug . log ( `Loading ${ path } configuration file` , 'api:configurations' )
102
- Config . configs . set ( name , ( await import ( file . href ) ) . default )
102
+ Config . configs . set (
103
+ name ,
104
+ ( await import ( `${ file . href } ?version=${ Math . random ( ) } ${ ext } ` ) ) . default ,
105
+ )
103
106
}
104
107
}
Original file line number Diff line number Diff line change 9
9
10
10
export default {
11
11
name : 'SecJS' ,
12
+ env : process . env . NODE_ENV ,
12
13
}
Original file line number Diff line number Diff line change 8
8
*/
9
9
10
10
import { test } from '@japa/runner'
11
- import { Path , Config , Folder } from '#src/index'
11
+ import { Config , Folder , Path } from '#src/index'
12
12
import { RecursiveConfigException } from '#src/Exceptions/RecursiveConfigException'
13
13
import { ConfigNotNormalizedException } from '#src/Exceptions/ConfigNotNormalizedException'
14
14
15
15
test . group ( 'ConfigTest' , group => {
16
16
group . each . setup ( async ( ) => {
17
+ process . env . NODE_ENV = 'test'
18
+
17
19
Config . configs . clear ( )
18
20
19
21
const config = new Config ( )
@@ -59,4 +61,19 @@ test.group('ConfigTest', group => {
59
61
60
62
assert . equal ( Config . get ( 'app.name' ) , 'SecJS' )
61
63
} )
64
+
65
+ test ( 'should be able to reload configuration values' , async ( { assert } ) => {
66
+ assert . equal ( Config . get ( 'app.env' ) , 'test' )
67
+
68
+ process . env . NODE_ENV = 'example'
69
+
70
+ Config . configs . clear ( )
71
+
72
+ const config = new Config ( )
73
+
74
+ await config . safeLoad ( Path . config ( 'app.js' ) )
75
+ await config . safeLoad ( Path . config ( 'database.js' ) )
76
+
77
+ assert . equal ( Config . get ( 'app.env' ) , 'example' )
78
+ } )
62
79
} )
You can’t perform that action at this time.
0 commit comments