@@ -358,6 +358,10 @@ export enum ParameterType {
358358 * Resolved according to the config directory.
359359 */
360360 Path ,
361+ /**
362+ * Resolved according to the config directory unless it starts with https?://
363+ */
364+ UrlOrPath ,
361365 Number ,
362366 Boolean ,
363367 Map ,
@@ -418,10 +422,10 @@ export interface StringDeclarationOption extends DeclarationOptionBase {
418422 * Specifies the resolution strategy. If `Path` is provided, values will be resolved according to their
419423 * location in a file. If `String` or no value is provided, values will not be resolved.
420424 */
421- type ?: ParameterType . String | ParameterType . Path ;
425+ type ?: ParameterType . String | ParameterType . Path | ParameterType . UrlOrPath ;
422426
423427 /**
424- * If not specified defaults to the empty string for both `String` and `Path` .
428+ * If not specified defaults to the empty string for all types .
425429 */
426430 defaultValue ?: string ;
427431
@@ -569,6 +573,7 @@ export type DeclarationOption =
569573export interface ParameterTypeToOptionTypeMap {
570574 [ ParameterType . String ] : string ;
571575 [ ParameterType . Path ] : string ;
576+ [ ParameterType . UrlOrPath ] : string ;
572577 [ ParameterType . Number ] : number ;
573578 [ ParameterType . Boolean ] : boolean ;
574579 [ ParameterType . Mixed ] : unknown ;
@@ -612,6 +617,19 @@ const converters: {
612617 option . validate ?.( stringValue , i18n ) ;
613618 return stringValue ;
614619 } ,
620+ [ ParameterType . UrlOrPath ] ( value , option , i18n , configPath ) {
621+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
622+ const stringValue = value == null ? "" : String ( value ) ;
623+
624+ if ( / ^ h t t p s ? : \/ \/ / i. test ( stringValue ) ) {
625+ option . validate ?.( stringValue , i18n ) ;
626+ return stringValue ;
627+ }
628+
629+ const resolved = resolve ( configPath , stringValue ) ;
630+ option . validate ?.( resolved , i18n ) ;
631+ return resolved ;
632+ } ,
615633 [ ParameterType . Number ] ( value , option , i18n ) {
616634 const numValue = parseInt ( String ( value ) , 10 ) || 0 ;
617635 if ( ! valueIsWithinBounds ( numValue , option . minValue , option . maxValue ) ) {
@@ -792,6 +810,18 @@ const defaultGetters: {
792810 ? defaultStr
793811 : join ( process . cwd ( ) , defaultStr ) ;
794812 } ,
813+ [ ParameterType . UrlOrPath ] ( option ) {
814+ const defaultStr = option . defaultValue ?? "" ;
815+ if ( defaultStr == "" ) {
816+ return "" ;
817+ }
818+ if ( / ^ h t t p s ? : \/ \/ / i. test ( defaultStr ) ) {
819+ return defaultStr ;
820+ }
821+ return isAbsolute ( defaultStr )
822+ ? defaultStr
823+ : join ( process . cwd ( ) , defaultStr ) ;
824+ } ,
795825 [ ParameterType . Number ] ( option ) {
796826 return option . defaultValue ?? 0 ;
797827 } ,
0 commit comments