File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 7
7
* file that was distributed with this source code.
8
8
*/
9
9
10
- import { join } from 'path'
11
- import { readFile } from 'fs-extra'
12
- import { EnvParser as Parser } from '@adonisjs/env'
10
+ import { EnvParser as Parser , envLoader } from '@adonisjs/env'
13
11
14
12
/**
15
13
* Parses the env file inside the project root.
16
14
*/
17
15
export class EnvParser {
18
16
private envContents : any = { }
19
17
20
- private parser = new Parser ( false )
21
-
22
- constructor ( private envFileName : string = '.env' ) { }
18
+ constructor ( ) { }
23
19
24
20
/**
25
21
* Parse .env file contents
26
22
*/
27
23
public async parse ( rootDir : string ) {
28
- try {
29
- this . envContents = this . parser . parse ( await readFile ( join ( rootDir , this . envFileName ) , 'utf-8' ) )
30
- } catch { }
24
+ const { envContents, testEnvContent } = envLoader ( rootDir )
25
+ const envVars = new Parser ( true ) . parse ( envContents )
26
+ const testEnvVars = new Parser ( true ) . parse ( testEnvContent )
27
+ this . envContents = { ...envVars , ...testEnvVars }
31
28
}
32
29
33
30
/**
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ export class TestsServer {
129
129
* for the HTTP server
130
130
*/
131
131
private async getEnvironmentVariables ( ) {
132
- const envParser = new EnvParser ( '.env.test' )
132
+ const envParser = new EnvParser ( )
133
133
await envParser . parse ( this . appRoot )
134
134
135
135
const envOptions = envParser . asEnvObject ( [ 'PORT' , 'TZ' , 'HOST' ] )
You can’t perform that action at this time.
0 commit comments