File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,9 @@ console.log(Config.get('database.database')) // 'secjs'
328
328
// You can call load again and you will never lose the previous states
329
329
config .load (' example.ts' )
330
330
331
+ // You can also use safeLoad to not reload files that were already loaded
332
+ config .safeLoad (' app.ts' ) // Will just return without errors, but app.ts will not be reloaded.
333
+
331
334
console .log (Config .get (' app.name' )) // 'secjs'
332
335
```
333
336
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @secjs/utils" ,
3
- "version" : " 1.7.4 " ,
3
+ "version" : " 1.7.5 " ,
4
4
"description" : " " ,
5
5
"license" : " MIT" ,
6
6
"author" : " João Lenon" ,
Original file line number Diff line number Diff line change @@ -30,7 +30,20 @@ export class Config {
30
30
return config
31
31
}
32
32
33
- // Load the configuration file on demand
33
+ clear ( ) {
34
+ Config . configs . clear ( )
35
+ }
36
+
37
+ safeLoad ( path : string ) {
38
+ const { name } = parse ( path )
39
+
40
+ if ( Config . configs . has ( name ) ) {
41
+ return
42
+ }
43
+
44
+ return this . load ( path )
45
+ }
46
+
34
47
load ( path : string , callNumber = 0 ) {
35
48
const { dir, name, base } = parse ( path )
36
49
@@ -76,8 +89,4 @@ export class Config {
76
89
Config . debug . log ( `Loading ${ name } configuration file` )
77
90
Config . configs . set ( name , require ( `${ dir } /${ name } ` ) . default )
78
91
}
79
-
80
- clear ( ) {
81
- Config . configs . clear ( )
82
- }
83
92
}
You can’t perform that action at this time.
0 commit comments