@@ -6,8 +6,8 @@ import { Command } from 'commander';
66
77@Injectable ( )
88export class ConfigService {
9-
10- public readonly cwd = process . env . PWD || process . env . INIT_CWD || process . cwd ( ) ;
9+ public readonly cwd =
10+ process . env . PWD || process . env . INIT_CWD || process . cwd ( ) ;
1111 public readonly configFile = this . configFileOrDefault ( ) ;
1212
1313 private configFileOrDefault ( ) {
@@ -59,8 +59,14 @@ export class ConfigService {
5959 return getPath ( obj [ head ] , tail ) ;
6060 } ;
6161
62- const result = getPath ( this . read ( ) , path . split ( '.' ) ) as T ;
63- return result !== undefined ? result : defaultValue ;
62+ const raw = getPath ( this . read ( ) , path . split ( '.' ) ) as Record <
63+ string ,
64+ unknown
65+ > ;
66+
67+ const resolved = this . replacePlaceholders ( raw ) as T ;
68+
69+ return resolved !== undefined ? resolved : defaultValue ;
6470 }
6571
6672 has ( path : string ) {
@@ -137,12 +143,11 @@ export class ConfigService {
137143
138144 fs . ensureFileSync ( this . configFile ) ;
139145
140- const config = deepMerge (
141- this . defaultConfig ,
142- fs . readJSONSync ( this . configFile , { throws : false , encoding : 'utf8' } ) ,
143- ) ;
146+ const fileConfig =
147+ fs . readJSONSync ( this . configFile , { throws : false , encoding : 'utf8' } ) ??
148+ { } ;
144149
145- return this . replacePlaceholders ( config ) ;
150+ return deepMerge ( this . defaultConfig , fileConfig ) ;
146151 }
147152
148153 private replacePlaceholders ( config : Record < string , unknown > ) : Record < string , unknown > {
0 commit comments