File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @secjs/config" ,
3
- "version" : " 1.0.7 " ,
3
+ "version" : " 1.0.8 " ,
4
4
"description" : " " ,
5
5
"license" : " MIT" ,
6
6
"author" : " João Lenon" ,
Original file line number Diff line number Diff line change @@ -99,14 +99,14 @@ export class Config {
99
99
const fileContent = file . getContentSync ( ) . toString ( )
100
100
101
101
if ( fileContent . includes ( 'Config.get' ) ) {
102
- const matches = fileContent . match ( / \( ( [ ^ ) ] + ) \) / g)
102
+ const matches = fileContent . match ( / C o n f i g . g e t \( ( [ ^ ) ] + ) \) / g)
103
103
104
- for ( const match of matches ) {
104
+ for ( let match of matches ) {
105
+ match = match . replace ( 'Config.get' , '' ) . replace ( / [ ( ^ ) ' ] / g, '' )
105
106
if ( this . configs . get ( `env-${ match } ` ) ) continue
106
107
107
- const filePath = `${ dir } /${
108
- match . replace ( / [ ( ^ ) ' ] / g, '' ) . split ( '.' ) [ 0 ]
109
- } .ts`
108
+ const extension = process . env . NODE_TS === 'true' ? 'ts' : 'js'
109
+ const filePath = `${ dir } /${ match . split ( '.' ) [ 0 ] } .${ extension } `
110
110
111
111
this . loadOnDemand ( filePath , files , callNumber + 1 )
112
112
}
Original file line number Diff line number Diff line change @@ -2,7 +2,10 @@ import { Config } from '../src/Config'
2
2
import { rm , writeFile } from 'fs/promises'
3
3
4
4
describe ( '\n Config' , ( ) => {
5
- beforeAll ( ( ) => ( process . env . DB_NAME = 'testing' ) )
5
+ beforeAll ( ( ) => {
6
+ process . env . NODE_TS = 'true'
7
+ process . env . DB_NAME = 'testing'
8
+ } )
6
9
7
10
it ( 'should be able to get environment variables' , async ( ) => {
8
11
await new Config ( ) . load ( )
You can’t perform that action at this time.
0 commit comments