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.8.0 to 0.8.2

8

lib/prompts/base.js

@@ -6,11 +6,11 @@ /**

var rx = require("rx");
var _ = require("lodash");
var clc = require("cli-color");
var chalk = require("chalk");
var ansiRegex = require("ansi-regex");
var readline = require("readline");
var cliWidth = require("cli-width");
var utils = require("../utils/utils");
var Choices = require("../objects/choices");
var tty = require("../utils/tty");
var rx = require("rx");

@@ -100,3 +100,3 @@ /**

Prompt.prototype.error = function( error ) {
readline.moveCursor( this.rl.output, -clc.width, 0 );
readline.moveCursor( this.rl.output, -cliWidth(), 0 );
readline.clearLine( this.rl.output, 0 );

@@ -119,3 +119,3 @@

Prompt.prototype.hint = function( hint ) {
readline.moveCursor( this.rl.output, -clc.width, 0 );
readline.moveCursor( this.rl.output, -cliWidth(), 0 );
readline.clearLine( this.rl.output, 0 );

@@ -122,0 +122,0 @@

@@ -106,9 +106,4 @@ /**

var msgLines = message.split(/\n/);
this.height = msgLines.length;
utils.writeMessage( this, message );
// Write message to screen and setPrompt to control backspace
this.rl.setPrompt( _.last(msgLines) );
this.write( message );
return this;

@@ -115,0 +110,0 @@ };

@@ -9,2 +9,3 @@ /**

var Base = require("./base");
var utils = require("../utils/utils");
var observe = require("../utils/events");

@@ -60,4 +61,7 @@

// Once user confirm (enter key)
observe(this.rl).line.take(1).forEach( this.onEnd.bind(this) );
var events = observe(this.rl);
events.keypress.takeUntil( events.line ).forEach( this.onKeypress.bind(this) );
events.line.take(1).forEach( this.onEnd.bind(this) );
// Init

@@ -77,9 +81,4 @@ this.render();

var message = this.getQuestion();
utils.writeMessage( this, message );
this.write( message );
var msgLines = message.split(/\n/);
this.height = msgLines.length;
this.rl.setPrompt( _.last(msgLines) );
return this;

@@ -102,1 +101,9 @@ };

};
/**
* When user press a key
*/
Prompt.prototype.onKeypress = function() {
this.clean().render().write( this.rl.line );
};

@@ -9,2 +9,3 @@ /**

var Base = require("./base");
var utils = require("../utils/utils");
var Separator = require("../objects/separator");

@@ -89,8 +90,4 @@ var observe = require("../utils/events");

var msgLines = message.split(/\n/);
this.height = msgLines.length;
utils.writeMessage( this, message );
this.rl.setPrompt( _.last(msgLines) );
this.write( message );
return this;

@@ -97,0 +94,0 @@ };

@@ -9,2 +9,3 @@ /**

var Base = require("./base");
var utils = require("../utils/utils");
var observe = require("../utils/events");

@@ -40,3 +41,4 @@

// Once user confirm (enter key)
var submit = observe(this.rl).line.map( this.filterInput.bind(this) );
var events = observe(this.rl);
var submit = events.line.map( this.filterInput.bind(this) );

@@ -47,2 +49,4 @@ var validation = this.handleSubmitEvents( submit );

events.keypress.takeUntil( validation.success ).forEach( this.onKeypress.bind(this) );
// Init

@@ -62,9 +66,4 @@ this.render();

var message = this.getQuestion();
utils.writeMessage( this, message );
this.write( message );
var msgLines = message.split(/\n/);
this.height = msgLines.length;
this.rl.setPrompt( _.last(msgLines) );
return this;

@@ -102,1 +101,9 @@ };

};
/**
* When user press a key
*/
Prompt.prototype.onKeypress = function() {
this.clean().render().write( this.rl.line );
};

@@ -106,9 +106,4 @@ /**

var msgLines = message.split(/\n/);
this.height = msgLines.length;
utils.writeMessage( this, message );
// Write message to screen and setPrompt to control backspace
this.rl.setPrompt( _.last(msgLines) );
this.write( message );
return this;

@@ -115,0 +110,0 @@ };

@@ -9,2 +9,3 @@ /**

var Base = require("./base");
var utils = require("../utils/utils");
var observe = require("../utils/events");

@@ -64,10 +65,4 @@

var message = this.getQuestion();
utils.writeMessage( this, message );
var msgLines = message.split(/\n/);
this.height = msgLines.length;
// Write message to screen and setPrompt to control backspace
this.rl.setPrompt( _.last(msgLines) );
this.write( message );
return this;

@@ -74,0 +69,0 @@ };

@@ -7,5 +7,5 @@ /**

var util = require("util");
var clc = require("cli-color");
var chalk = require("chalk");
var Base = require("./base");
var utils = require("../utils/utils");
var Separator = require("../objects/separator");

@@ -102,8 +102,4 @@ var observe = require("../utils/events");

var msgLines = message.split(/\n/);
this.height = msgLines.length;
utils.writeMessage( this, message );
this.rl.setPrompt( _.last(msgLines) );
this.write( message );
return this;

@@ -140,3 +136,2 @@ };

.error("Please enter a valid index")
.write( clc.bol(0, true) )
.clean()

@@ -143,0 +138,0 @@ .render();

@@ -8,2 +8,3 @@ /**

var Base = require("./baseUI");
var utils = require("../utils/utils");

@@ -39,7 +40,4 @@

Prompt.prototype.render = function() {
this.write( this.bottomBar );
utils.writeMessage ( this, this.bottomBar );
var msgLines = this.bottomBar.split(/\n/);
this.height = msgLines.length;
return this;

@@ -46,0 +44,0 @@ };

@@ -7,3 +7,3 @@ /**

var readline = require("readline");
var clc = require("cli-color");
var cliWidth = require("cli-width");

@@ -25,3 +25,3 @@ var tty = module.exports;

while ( len-- ) {
readline.moveCursor(this.rl.output, -clc.width, 0);
readline.moveCursor(this.rl.output, -cliWidth(), 0);
readline.clearLine(this.rl.output, 0);

@@ -65,3 +65,15 @@ if ( len ) readline.moveCursor(this.rl.output, 0, -1);

/**
* Move cursor left by `x`
* @param {Number} x How far to go left (default to 1)
* @return {Prompt} self
*/
tty.left = function( x ) {
_.isNumber(x) || (x = 1);
readline.moveCursor (this.rl.output, -x, 0);
return this;
};
/**

@@ -68,0 +80,0 @@ * Write a string to the stdout

@@ -104,1 +104,21 @@ /**

};
/**
* Helper for writing message in Prompt
* @param {Prompt} prompt - The Prompt object that extends tty
* @param {String} message - The message to be output
*/
utils.writeMessage = function ( prompt, message ) {
var msgLines = message.split(/\n/);
prompt.height = msgLines.length;
// Write message to screen and setPrompt to control backspace
prompt.rl.setPrompt( _.last(msgLines) );
if ( process.stdout.rows === 0 && process.stdout.columns === 0 ) {
/* When it's a tty through serial port there's no terminal info and the render will malfunction,
so we need enforce the cursor to locate to the leftmost position for rendering. */
prompt.left( message.length + prompt.rl.line.length );
}
prompt.write( message );
};
{
"name": "inquirer",
"version": "0.8.0",
"version": "0.8.2",
"description": "A collection of common interactive command line user interfaces.",

@@ -9,6 +9,3 @@ "main": "lib/inquirer.js",

},
"repository": {
"type": "git",
"url": "git://github.com/SBoudrias/Inquirer.js.git"
},
"repository": "SBoudrias/Inquirer.js",
"keywords": [

@@ -18,29 +15,32 @@ "command",

"stdin",
"cli"
"cli",
"tty",
"menu"
],
"author": "Simon Boudrias <admin@simonboudrias.com>",
"license": "MIT",
"files": [
"lib"
],
"dependencies": {
"ansi-regex": "^1.1.0",
"chalk": "^0.5.0",
"cli-color": "~0.3.2",
"figures": "^1.3.2",
"lodash": "~2.4.1",
"mute-stream": "0.0.4",
"readline2": "~0.1.0",
"rx": "^2.2.27",
"through": "~2.3.4"
"ansi-regex": "^1.1.1",
"chalk": "^1.0.0",
"cli-width": "^1.0.1",
"figures": "^1.3.5",
"lodash": "^3.3.1",
"readline2": "^0.1.1",
"rx": "^2.4.3",
"through": "^2.3.6"
},
"devDependencies": {
"chai": "~1.9.0",
"cmdify": "0.0.4",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.8",
"grunt-contrib-jshint": "~0.10.0",
"grunt-mocha-test": "~0.10.2",
"grunt-release": "~0.7.0",
"mocha": "~1.18.2",
"mockery": "~1.4.0",
"sinon": "~1.9.1"
"chai": "^2.1.2",
"cmdify": "^0.0.4",
"grunt": "^0.4.1",
"grunt-cli": "^0.1.8",
"grunt-contrib-jshint": "^0.11.1",
"grunt-mocha-test": "^0.10.2",
"mocha": "^2.2.1",
"mockery": "^1.4.0",
"sinon": "^1.12.1"
}
}

@@ -15,3 +15,3 @@ Inquirer.js

_**Inquirer**_ provide the user interface, and the inquiry session flow. If you're searching for a full blown command line program utility, then check out [Commander.js](https://github.com/visionmedia/commander.js) (inspired by) or [cli-color](https://github.com/medikoo/cli-color) (used internally).
_**Inquirer**_ provide the user interface, and the inquiry session flow. If you're searching for a full blown command line program utility, then check out [Commander.js](https://github.com/visionmedia/commander.js) (inspired by).

@@ -61,3 +61,3 @@

- **type**: (String) Type of the prompt. Defaults: `input` - Possible values: `input`, `confirm`,
`list`, `rawlist`
`list`, `rawlist`, `password`
- **name**: (String) The name to use when storing the answer in the anwers hash.

@@ -72,3 +72,3 @@ - **message**: (String|Function) The question to print. If defined as a function, the first parameter will be the current inquirer session answers.

`default`(if defined as a function), `validate`, `filter` and `when` functions can be asynchronously using `this.async()`. You just have to pass the value you'd normally return to the callback option.
`default`(if defined as a function), `validate`, `filter` and `when` functions can be called asynchronously using `this.async()`. You just have to pass the value you'd normally return to the callback option.

@@ -153,3 +153,3 @@ ``` javascript

Note that the `choice` object will take an extra parameter called `key` for the `expand` prompt. This parameter must be a single (lowercased) character. The `h` option is added by the prompt and shouldn't be defined by the user.
Note that the `choices` object will take an extra parameter called `key` for the `expand` prompt. This parameter must be a single (lowercased) character. The `h` option is added by the prompt and shouldn't be defined by the user.

@@ -169,3 +169,3 @@ See `examples/expand.js` for a running example.

Choices who're property `disabled` is truthy will be unselectable. If `disabled` is a string, then the string will be outputed next to the disabled choice, otherwise it'll default to `"Disabled"`. The `disabled` property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.
Choices whose property `disabled` is truthy will be unselectable. If `disabled` is a string, then the string will be outputed next to the disabled choice, otherwise it'll default to `"Disabled"`. The `disabled` property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.

@@ -172,0 +172,0 @@ ![Checkbox prompt](https://dl.dropboxusercontent.com/u/59696254/inquirer/checkbox-prompt.png)

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