Socket
Socket
Sign inDemoInstall

inquirer

Package Overview
Dependencies
Maintainers
1
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquirer - npm Package Compare versions

Comparing version 0.11.1 to 0.11.2

7

lib/prompts/checkbox.js

@@ -87,4 +87,4 @@ /**

// Render question
var cursor = 0;
var message = this.getQuestion();
var bottomContent = '';

@@ -105,4 +105,3 @@ if ( this.firstRender ) {

if (error) {
message += '\n' + chalk.red('>> ') + error;
cursor++;
bottomContent = chalk.red('>> ') + error;
}

@@ -112,3 +111,3 @@

this.screen.render(message, { cursor: cursor });
this.screen.render(message, bottomContent);
};

@@ -115,0 +114,0 @@

@@ -76,4 +76,4 @@ /**

Prompt.prototype.render = function (error, hint) {
var cursor = 0;
var message = this.getQuestion();
var bottomContent = '';

@@ -91,12 +91,10 @@ if ( this.status === "answered" ) {

if (error) {
message += '\n' + chalk.red('>> ') + error;
cursor++;
bottomContent = chalk.red('>> ') + error;
}
if (hint) {
message += '\n' + chalk.cyan('>> ') + hint;
cursor++;
bottomContent = chalk.cyan('>> ') + hint;
}
this.screen.render(message, { cursor: cursor });
this.screen.render(message, bottomContent);
};

@@ -103,0 +101,0 @@

@@ -60,3 +60,3 @@ /**

Prompt.prototype.render = function (error) {
var cursor = 0;
var bottomContent = '';
var message = this.getQuestion();

@@ -71,7 +71,6 @@

if (error) {
message += '\n' + chalk.red('>> ') + error;
cursor++;
bottomContent = chalk.red('>> ') + error;
}
this.screen.render(message, { cursor: cursor });
this.screen.render(message, bottomContent);
};

@@ -78,0 +77,0 @@

@@ -69,4 +69,4 @@ /**

Prompt.prototype.render = function (error) {
var cursor = 0;
var message = this.getQuestion();
var bottomContent = '';

@@ -80,7 +80,6 @@ if (this.status === 'answered') {

if (error) {
message += '\n' + chalk.red('>> ') + error;
cursor++;
bottomContent = '\n' + chalk.red('>> ') + error;
}
this.screen.render(message, { cursor: cursor });
this.screen.render(message, bottomContent);
};

@@ -87,0 +86,0 @@

@@ -89,4 +89,4 @@ /**

// Render question
var cursor = 0;
var message = this.getQuestion();
var bottomContent = '';

@@ -104,7 +104,6 @@ if ( this.status === "answered" ) {

if (error) {
message += '\n' + chalk.red('>> ') + error;
cursor++;
bottomContent = '\n' + chalk.red('>> ') + error;
}
this.screen.render(message, { cursor: cursor });
this.screen.render(message, bottomContent);
};

@@ -111,0 +110,0 @@

@@ -10,2 +10,21 @@ 'use strict';

function height(content) {
return content.split('\n').length;
}
function width(content) {
return stripAnsi(content).length;
}
function lastLine(content) {
return _.last(content.split('\n'));
}
function normalizedCliWidth() {
if (process.platform === 'win32') {
return cliWidth() - 1;
}
return cliWidth();
}
var ScreenManager = module.exports = function (rl) {

@@ -19,4 +38,3 @@ // These variables are keeping information to allow correct prompt re-rendering

ScreenManager.prototype.render = function (content, opt) {
opt = _.extend({ cursor: 0 }, opt || {});
ScreenManager.prototype.render = function (content, bottomContent) {
var cursorPos = this.rl._getCursorPos();

@@ -31,4 +49,3 @@

var lines = content.split(/\n/);
var promptLine = lines[lines.length - 1 - opt.cursor];
var promptLine = lastLine(content);
var rawPromptLine = stripAnsi(promptLine);

@@ -44,14 +61,15 @@

this.rl.setPrompt(prompt);
var rawPrompt = stripAnsi(prompt);
content = forceLineReturn(content);
if (bottomContent) {
bottomContent = forceLineReturn(bottomContent);
}
// Manually insert an extra line if we're at the end of the line.
// This prevent the cursor from appearing at the beginning of the
// current line.
var breakedLines = breakLines(lines);
var actualLines = _.flatten(breakedLines);
if (rawPromptLine.length % cliWidth() === 0) {
actualLines.push('');
if (rawPromptLine.length % normalizedCliWidth() === 0) {
content = content + '\n';
}
this.rl.output.write(actualLines.join('\n'));
var fullContent = content + (bottomContent ? '\n' + bottomContent : '');
this.rl.output.write(fullContent);

@@ -62,9 +80,12 @@ /**

var promptLineUpDiff = Math.floor(rawPromptLine.length / cliWidth()) - cursorPos.rows;
if (opt.cursor + promptLineUpDiff > 0) {
util.up(this.rl, opt.cursor + promptLineUpDiff);
// We need to consider parts of the prompt under the cursor as part of the bottom
// content in order to correctly cleanup and re-render.
var promptLineUpDiff = Math.floor(rawPromptLine.length / normalizedCliWidth()) - cursorPos.rows;
var bottomContentHeight = promptLineUpDiff + (bottomContent ? height(bottomContent) : 0);
if (bottomContentHeight > 0) {
util.up(this.rl, bottomContentHeight);
}
// Reset cursor at the beginning of the line
util.left(this.rl, stripAnsi(_.last(actualLines)).length);
util.left(this.rl, width(lastLine(fullContent)));

@@ -74,3 +95,3 @@ // Adjust cursor on the right

if (cursorPos.rows === 0) {
rightPos = Math.max(rightPos, rawPrompt.length);
rightPos = Math.max(rightPos, width(lastLine(content)));
}

@@ -82,7 +103,5 @@ util.right(this.rl, rightPos);

*/
this.extraLinesUnderPrompt = bottomContentHeight;
this.height = height(fullContent);
var bottomSection = breakedLines.slice(breakedLines.length - opt.cursor - promptLineUpDiff);
this.extraLinesUnderPrompt = _.flatten(bottomSection).length;
this.height = actualLines.length;
this.rl.output.mute();

@@ -107,3 +126,3 @@ };

// returns behavior accross terminals.
var width = cliWidth();
var width = normalizedCliWidth();
var regex = new RegExp(

@@ -120,1 +139,5 @@ '(?:(?:\\033\[[0-9;]*m)*.?){1,' + width + '}',

}
function forceLineReturn(content) {
return _.flatten(breakLines(content.split('\n'))).join('\n');
}
{
"name": "inquirer",
"version": "0.11.1",
"version": "0.11.2",
"description": "A collection of common interactive command line user interfaces.",

@@ -5,0 +5,0 @@ "main": "lib/inquirer.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc