File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed
Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,31 @@ describe('BaseClass', () => {
406406 expect ( printAllVariablesMock ) . toHaveBeenCalled ( ) ;
407407 expect ( baseClass . envVariables ) . toEqual ( expectedEnv ) ;
408408 } ) ;
409+
410+ it ( 'should pass deduplicated choices to ux.inquire when variablePreparationTypeOptions contains duplicates' , async ( ) => {
411+ const opts = config . variablePreparationTypeOptions ;
412+ const withDuplicates = [ ...opts , opts [ 0 ] , opts [ 1 ] ] ;
413+ baseClass = new BaseClass ( {
414+ log : logMock ,
415+ exit : exitMock ,
416+ config : {
417+ variablePreparationTypeOptions : withDuplicates ,
418+ } ,
419+ } as any ) ;
420+
421+ jest . spyOn ( baseClass , 'importEnvFromStack' ) . mockResolvedValueOnce ( ) ;
422+ ( ux . inquire as jest . Mock ) . mockResolvedValueOnce ( [ 'Import variables from a stack' ] ) ;
423+
424+ await baseClass . handleEnvImportFlow ( ) ;
425+
426+ expect ( ux . inquire ) . toHaveBeenCalledWith (
427+ expect . objectContaining ( {
428+ type : 'checkbox' ,
429+ name : 'variablePreparationType' ,
430+ choices : opts ,
431+ } ) ,
432+ ) ;
433+ } ) ;
409434 } ) ;
410435
411436 describe ( 'importVariableFromLocalConfig' , ( ) => {
Original file line number Diff line number Diff line change @@ -514,13 +514,15 @@ export default class BaseClass {
514514 * @memberof BaseClass
515515 */
516516 async handleEnvImportFlow ( ) : Promise < void > {
517+ const rawChoices = this . config . variablePreparationTypeOptions ;
518+ const choiceList = Array . isArray ( rawChoices ) ? Array . from ( new Set ( rawChoices ) ) : rawChoices ;
519+
517520 let variablePreparationType : string | string [ ] =
518521 this . config . variableType ||
519522 ( await ux . inquire ( {
520523 type : 'checkbox' ,
521524 name : 'variablePreparationType' ,
522- default : this . config . framework ,
523- choices : this . config . variablePreparationTypeOptions ,
525+ choices : choiceList ,
524526 message : 'Import variables from a stack and/or manually add custom variables to the list' ,
525527 } ) ) ;
526528
Original file line number Diff line number Diff line change @@ -62,6 +62,9 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
6262 this . args = args as Args < T > ;
6363
6464 ux . registerSearchPlugin ( ) ;
65+ if ( process . stdin . isTTY && typeof process . stdin . setMaxListeners === 'function' ) {
66+ process . stdin . setMaxListeners ( 20 ) ;
67+ }
6568 this . $event = new EventEmitter ( ) ;
6669
6770 await this . prepareConfig ( ) ;
You can’t perform that action at this time.
0 commit comments