node_modules/snyk/dist/cli/139.index.js
/**
   * Render the prompt to screen
   * @return {CheckboxPrompt} self
   */
Render the prompt to screen
@return {CheckboxPrompt} self
Render the prompt to screen @return { CheckboxPrompt } self
render(error) {
    var message = this.getQuestion();
    var bottomContent = '';
    if (!this.spaceKeyPressed) {
      message +=
        '(Press ' +
        chalk.cyan.bold('<space>') +
        ' to select, ' +
        chalk.cyan.bold('<a>') +
        ' to toggle all, ' +
        chalk.cyan.bold('<i>') +
        ' to invert selection)';
    }
    if (this.status === 'answered') {
      message += chalk.cyan(this.selection.join(', '));
    } else {
      var choicesStr = renderChoices(this.opt.choices, this.pointer);
      var indexPosition = this.opt.choices.indexOf(
        this.opt.choices.getChoice(this.pointer)
      );
      var realIndexPosition =
        this.opt.choices.reduce(function (acc, value, i) {
          if (i > indexPosition) {
            return acc;
          }
          if (value.type === 'separator') {
            return acc + 1;
          }
          var l = value.name;
          if (typeof l !== 'string') {
            return acc + 1;
          }
          l = l.split('\n');
          return acc + l.length;
        }, 0) - 1;
      message +=
        '\n' + this.paginator.paginate(choicesStr, realIndexPosition, this.opt.pageSize);
    }
    if (error) {
      bottomContent = chalk.red('>> ') + error;
    }
    this.screen.render(message, bottomContent);
  }
render ( error ) { var message = this . getQuestion ( ) ; var bottomContent = '' ; if ( ! this . spaceKeyPressed ) { message += '(Press ' + chalk . cyan . bold ( '<space>' ) + ' to select, ' + chalk . cyan . bold ( '<a>' ) + ' to toggle all, ' + chalk . cyan . bold ( '<i>' ) + ' to invert selection)' ; } if ( this . status === 'answered' ) { message += chalk . cyan ( this . selection . join ( ', ' ) ) ; } else { var choicesStr = renderChoices ( this . opt . choices , this . pointer ) ; var indexPosition = this . opt . choices . indexOf ( this . opt . choices . getChoice ( this . pointer ) ) ; var realIndexPosition = this . opt . choices . reduce ( function ( acc , value , i ) { if ( i > indexPosition ) { return acc ; } if ( value . type === 'separator' ) { return acc + 1 ; } var l = value . name ; if ( typeof l !== 'string' ) { return acc + 1 ; } l = l . split ( '\n' ) ; return acc + l . length ; } , 0 ) - 1 ; message += '\n' + this . paginator . paginate ( choicesStr , realIndexPosition , this . opt . pageSize ) ; } if ( error ) { bottomContent = chalk . red ( '>> ' ) + error ; } this . screen . render ( message , bottomContent ) ; }
Render the prompt to screen
 @return {CheckboxPrompt} self
Render the prompt to screen @return { CheckboxPrompt } self
// Render question // Render choices or answer depending on the state // Dont count lines past the choice we are looking at // Add line if it's a separator // Non-strings take up one line // Calculate lines taken up by string