@@ -157,6 +157,7 @@ export const FormatType = formatUtils.Type;
157157export type BaseSettingsDefinition < T extends SettingsType = SettingsType > = {
158158 description : string ;
159159 type : T ;
160+ fallback ?: string ;
160161} & ( { isArray ?: false } | { isArray : true , concatenateValues ?: boolean } ) ;
161162
162163export enum DurationUnit {
@@ -168,7 +169,7 @@ export enum DurationUnit {
168169 WEEKS = `w` ,
169170}
170171export type DurationSettingsDefinition = BaseSettingsDefinition < SettingsType . DURATION > & {
171- default : string ;
172+ default : string | undefined ;
172173 unit : DurationUnit ;
173174 isNullable ?: boolean ;
174175} ;
@@ -953,6 +954,9 @@ function getDefaultValue(configuration: Configuration, definition: SettingsDefin
953954 }
954955 }
955956 case SettingsType . DURATION : {
957+ if ( typeof definition . default === `undefined` )
958+ return undefined ;
959+
956960 return miscUtils . parseDuration ( definition . default , definition . unit ) ;
957961 }
958962 default : {
@@ -966,7 +970,10 @@ type SettingTransforms = {
966970 getNativePaths : boolean ;
967971} ;
968972
969- function transformConfiguration ( rawValue : unknown , definition : SettingsDefinitionNoDefault , transforms : SettingTransforms ) {
973+ function transformConfiguration ( configuration : Configuration , rawValue : unknown , definition : SettingsDefinitionNoDefault , transforms : SettingTransforms ) {
974+ if ( typeof rawValue === `undefined` && typeof definition . fallback !== `undefined` )
975+ return configuration . get ( definition . fallback ) ;
976+
970977 if ( definition . type === SettingsType . SECRET && typeof rawValue === `string` && transforms . hideSecrets )
971978 return SECRET ;
972979 if ( definition . type === SettingsType . ABSOLUTE_PATH && typeof rawValue === `string` && transforms . getNativePaths )
@@ -976,7 +983,7 @@ function transformConfiguration(rawValue: unknown, definition: SettingsDefinitio
976983 const newValue : Array < unknown > = [ ] ;
977984
978985 for ( const value of rawValue )
979- newValue . push ( transformConfiguration ( value , definition , transforms ) ) ;
986+ newValue . push ( transformConfiguration ( configuration , value , definition , transforms ) ) ;
980987
981988 return newValue ;
982989 }
@@ -988,7 +995,7 @@ function transformConfiguration(rawValue: unknown, definition: SettingsDefinitio
988995 const newValue : Map < string , unknown > = new Map ( ) ;
989996
990997 for ( const [ key , value ] of rawValue . entries ( ) ) {
991- const transformedValue = transformConfiguration ( value , definition . valueDefinition , transforms ) ;
998+ const transformedValue = transformConfiguration ( configuration , value , definition . valueDefinition , transforms ) ;
992999 if ( typeof transformedValue !== `undefined` ) {
9931000 newValue . set ( key , transformedValue ) ;
9941001 }
@@ -1006,7 +1013,7 @@ function transformConfiguration(rawValue: unknown, definition: SettingsDefinitio
10061013 for ( const [ key , value ] of rawValue . entries ( ) ) {
10071014 const propertyDefinition = definition . properties [ key ] ;
10081015
1009- const transformedValue = transformConfiguration ( value , propertyDefinition , transforms ) ;
1016+ const transformedValue = transformConfiguration ( configuration , value , propertyDefinition , transforms ) ;
10101017 if ( typeof transformedValue !== `undefined` ) {
10111018 newValue . set ( key , transformedValue ) ;
10121019 }
@@ -1733,7 +1740,7 @@ export class Configuration {
17331740 if ( typeof definition === `undefined` )
17341741 throw new UsageError ( `Couldn't find a configuration settings named "${ key } "` ) ;
17351742
1736- return transformConfiguration ( rawValue , definition , {
1743+ return transformConfiguration ( this , rawValue , definition , {
17371744 hideSecrets,
17381745 getNativePaths,
17391746 } ) as T ;
0 commit comments