File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -588,23 +588,24 @@ export class Inquirerer {
588588 private handleOverridesWithOptions (
589589 argv : any ,
590590 obj : any ,
591- question : AutocompleteQuestion | ListQuestion | CheckboxQuestion
591+ question : AutocompleteQuestion | ListQuestion
592592 ) : void {
593- if (
594- typeof argv [ question . name ] === 'string'
595- ) {
596- const options = this . sanitizeOptions ( question ) ;
597- const input = argv [ question . name ] ;
598-
599- const found = options . find (
600- opt => opt . name === input || String ( opt . value ) === input
601- ) ;
602-
603- if ( typeof found !== 'undefined' ) {
604- obj [ question . name ] = found . value ;
605- }
593+ const input = argv [ question . name ] ;
594+ if ( typeof input !== 'string' ) return ;
595+
596+ const options = this . sanitizeOptions ( question ) ;
597+
598+ const found = options . find (
599+ opt => opt . name === input || String ( opt . value ) === input
600+ ) ;
601+
602+ if ( found ) {
603+ obj [ question . name ] = found . value ;
604+ } else if ( question . allowCustomOptions ) {
605+ obj [ question . name ] = input ; // Store as-is
606606 }
607607 }
608+
608609
609610 private async handleQuestionType ( question : Question , ctx : PromptContext ) : Promise < any > {
610611 this . keypress ?. clearHandlers ( ) ;
Original file line number Diff line number Diff line change @@ -36,12 +36,14 @@ export interface BaseQuestion {
3636 type : 'autocomplete' ;
3737 options : ( string | OptionValue ) [ ] ;
3838 maxDisplayLines ?: number ;
39+ allowCustomOptions ?: boolean ;
3940 }
4041
4142 export interface ListQuestion extends BaseQuestion {
4243 type : 'list' ;
4344 options : ( string | OptionValue ) [ ] ;
4445 maxDisplayLines ?: number ;
46+ allowCustomOptions ?: boolean ;
4547 }
4648
4749 export interface CheckboxQuestion extends BaseQuestion {
You can’t perform that action at this time.
0 commit comments