@@ -17,11 +17,17 @@ function write_file(file_path, content) {
17
17
function sync_args_from_cmd ( args ) {
18
18
return new Promise ( function ( resolve , reject ) {
19
19
let rawdata = fs . readFileSync ( args [ "lambdatest-config-file" ] ) ;
20
- let lt_config = JSON . parse ( rawdata ) ;
20
+ let lt_config ;
21
+ try {
22
+ lt_config = JSON . parse ( rawdata ) ;
23
+ } catch ( err ) {
24
+ reject ( "error in parsing lambdatest-config-file" , err ) ;
25
+ }
21
26
let usernameFromEnvFile = undefined ;
22
27
let accessKeyFromEnvFile = undefined ;
23
28
let envFile , parsedEnv ;
24
29
let dot_env_vars = undefined ;
30
+ let dot_env_keys_list = undefined ;
25
31
let envFilePath = path . join ( "." , `.env` ) ;
26
32
if ( "sys-env-keys" in args ) {
27
33
dot_env_vars = args [ "sys-env-keys" ] ;
@@ -30,18 +36,18 @@ function sync_args_from_cmd(args) {
30
36
}
31
37
if ( dot_env_vars ) {
32
38
dot_env_vars = dot_env_vars . trim ( ) ;
33
- dot_env_vars = dot_env_vars . split ( "," ) ;
39
+ dot_env_keys_list = dot_env_vars . split ( "," ) ;
34
40
if ( "envfl" in args ) {
35
41
envFilePath = args [ "envfl" ] ;
36
- } else if ( lt_config [ "run_settings" ] [ "env_file" ] ) {
42
+ } else if ( lt_config [ "run_settings" ] && lt_config [ "run_settings" ] [ "env_file" ] ) {
37
43
envFilePath = lt_config [ "run_settings" ] [ "env_file" ] ;
38
44
}
39
45
40
46
try {
41
47
envFile = fs . readFileSync ( envFilePath , { encoding : 'utf8' } )
42
48
parsedEnv = dotenv . parse ( envFile )
43
- for ( index in dot_env_vars ) {
44
- let envKey = dot_env_vars [ index ]
49
+ for ( index in dot_env_keys_list ) {
50
+ let envKey = dot_env_keys_list [ index ]
45
51
if ( envKey == constants . LT_USERNAME_ENV ) {
46
52
let envValue = parsedEnv [ envKey ]
47
53
if ( envValue ) {
@@ -451,10 +457,10 @@ function sync_args_from_cmd(args) {
451
457
}
452
458
}
453
459
454
- if ( dot_env_vars ) {
460
+ if ( dot_env_keys_list ) {
455
461
try {
456
- for ( index in dot_env_vars ) {
457
- let envKey = dot_env_vars [ index ]
462
+ for ( index in dot_env_keys_list ) {
463
+ let envKey = dot_env_keys_list [ index ]
458
464
let envValue = parsedEnv [ envKey ]
459
465
envs [ envKey ] = envValue
460
466
}
0 commit comments