File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @secjs/utils" ,
3- "version" : " 1.9.3 " ,
3+ "version" : " 1.9.4 " ,
44 "description" : " Utils functions and classes for Node.js" ,
55 "license" : " MIT" ,
66 "author" : " João Lenon <lenon@athenna.io>" ,
Original file line number Diff line number Diff line change @@ -99,6 +99,9 @@ export class Config {
9999 }
100100
101101 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+ )
103106 }
104107}
Original file line number Diff line number Diff line change 99
1010export default {
1111 name : 'SecJS' ,
12+ env : process . env . NODE_ENV ,
1213}
Original file line number Diff line number Diff line change 88 */
99
1010import { test } from '@japa/runner'
11- import { Path , Config , Folder } from '#src/index'
11+ import { Config , Folder , Path } from '#src/index'
1212import { RecursiveConfigException } from '#src/Exceptions/RecursiveConfigException'
1313import { ConfigNotNormalizedException } from '#src/Exceptions/ConfigNotNormalizedException'
1414
1515test . group ( 'ConfigTest' , group => {
1616 group . each . setup ( async ( ) => {
17+ process . env . NODE_ENV = 'test'
18+
1719 Config . configs . clear ( )
1820
1921 const config = new Config ( )
@@ -59,4 +61,19 @@ test.group('ConfigTest', group => {
5961
6062 assert . equal ( Config . get ( 'app.name' ) , 'SecJS' )
6163 } )
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+ } )
6279} )
You can’t perform that action at this time.
0 commit comments