Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prompt-base

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompt-base - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

71

index.js

@@ -76,3 +76,2 @@ 'use strict';

util.inherits(Prompt, Emitter);
Prompt.extend = extend(Prompt);

@@ -304,11 +303,12 @@ /**

var render = {
var context = {
state: state,
status: this.status,
line: this.rl.line,
message: message,
status: this.status,
append: append
};
this.emit('render', render);
this.ui.render(render.message, render.append);
this.emit('render', context);
this.ui.render(context.message, context.append);
};

@@ -465,4 +465,4 @@

if (key.name === 'line') {
this.status = 'submitted';
input = this.getAnswer(input, key);
this.status = 'submitted';
}

@@ -737,2 +737,53 @@

/**
* Static convenience method for running the prompt asynchronously.
* Takes the same arguments as the contructror.
*
* ```js
* var prompt = require('prompt-base');
* var question = { name: 'color', message: 'What is your favorite color?' };
* prompt.ask(question, function(answer) {
* console.log(answer);
* //=> 'blue'
* });
* ```
* @param {Object} `question` Plain object or instance of [prompt-question][].
* @param {Object} `answers` Optionally pass an answers object from a prompt manager (like [enquirer][]).
* @param {Object} `ui` Optionally pass an instance of [readline-ui][]. If not passed, an instance is created for you.
* @param {Function} `callback`
* @return {undefined}
* @api public
*/
Prompt.ask = function(question, answers, ui) {
var args = [].slice.call(arguments);
var cb = args.pop();
var prompt = new this(...args);
prompt.ask(cb);
};
/**
* Static convenience method for running the prompt.
* Takes the same arguments as the contructror.
*
* ```js
* var prompt = require('prompt-base');
* prompt.run({ name: 'color', message: 'What is your favorite color?'})
* .then(function(answer) {
* console.log(answer);
* //=> 'blue'
* });
* ```
* @param {Object} `question` Plain object or instance of [prompt-question][].
* @param {Object} `answers` Optionally pass an answers object from a prompt manager (like [enquirer][]).
* @param {Object} `ui` Optionally pass an instance of [readline-ui][]. If not passed, an instance is created for you.
* @return {Promise}
* @api public
*/
Prompt.run = function() {
var prompt = new this(...arguments);
return prompt.run();
};
/**
* Create a new `Question`. See [prompt-question][] for more details.

@@ -778,2 +829,10 @@ *

/**
* Static method for inheriting `Prompt`. This ensures that all getters/setters,
* prototype methods, and static methods are inherited and invoked in the
* correct context.
*/
Prompt.extend = extend(Prompt);
/**
* Expose `Prompt`

@@ -780,0 +839,0 @@ */

2

package.json
{
"name": "prompt-base",
"description": "Base prompt module used for creating custom prompts.",
"version": "2.1.2",
"version": "2.2.0",
"homepage": "https://github.com/enquirer/prompt-base",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

@@ -101,3 +101,3 @@ # prompt-base [![NPM version](https://img.shields.io/npm/v/prompt-base.svg?style=flat)](https://www.npmjs.com/package/prompt-base) [![NPM monthly downloads](https://img.shields.io/npm/dm/prompt-base.svg?style=flat)](https://npmjs.org/package/prompt-base) [![NPM total downloads](https://img.shields.io/npm/dt/prompt-base.svg?style=flat)](https://npmjs.org/package/prompt-base) [![Linux Build Status](https://img.shields.io/travis/enquirer/prompt-base.svg?style=flat&label=Travis)](https://travis-ci.org/enquirer/prompt-base) [![Windows Build Status](https://img.shields.io/appveyor/ci/enquirer/prompt-base.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/enquirer/prompt-base)

### [.transform](index.js#L97)
### [.transform](index.js#L96)

@@ -122,3 +122,3 @@ Modify the answer value before it's returned. Must return a string or promise.

### [.validate](index.js#L135)
### [.validate](index.js#L134)

@@ -148,3 +148,3 @@ Validate user input on `keypress` events and the answer value when it's submitted by the `line` event (when the user hits <kbd>enter</kbd>. This may be overridden in custom prompts. If the function returns `false`, either `question.errorMessage` or the default validation error message (`invalid input`) is used. Must return a boolean, string or promise.

### [.when](index.js#L166)
### [.when](index.js#L165)

@@ -171,3 +171,3 @@ A custom `.when` function may be defined to determine

### [.ask](index.js#L192)
### [.ask](index.js#L191)

@@ -195,3 +195,3 @@ Run the prompt with the given `callback` function.

### [.run](index.js#L233)
### [.run](index.js#L232)

@@ -222,3 +222,3 @@ Run the prompt and resolve answers. If [when](#when) is defined and returns false, the prompt will be skipped.

### [.render](index.js#L277)
### [.render](index.js#L276)

@@ -329,3 +329,3 @@ (Re-)render the prompt message, along with any help or error messages, user input, choices, list items, and so on. This is called to render the initial prompt, then it's called again each time the prompt changes, such as on keypress events (when the user enters input, or a multiple-choice option is selected). This method may be overridden in custom prompts, but it's recommended that you override the more specific render "status" methods instead.

### [.onError](index.js#L511)
### [.onError](index.js#L512)

@@ -340,11 +340,11 @@ Default error event handler. If an `error` listener exist, an `error`

### [.getDefault](index.js#L526)
### [.getDefault](index.js#L527)
Get the answer to use. This can be overridden in custom prompts.
### [.getAnswer](index.js#L540)
### [.getAnswer](index.js#L541)
Get the answer to use. This can be overridden in custom prompts.
### [.submitAnswer](index.js#L551)
### [.submitAnswer](index.js#L552)

@@ -354,3 +354,3 @@ Re-render and pass the final answer to the callback.

### [.only](index.js#L574)
### [.only](index.js#L575)

@@ -367,3 +367,3 @@ Ensures that events for event `name` are only **registered** once and are disabled correctly when specified. This is different from `.once`, which only **emits** once.

### [.mute](index.js#L603)
### [.mute](index.js#L604)

@@ -384,3 +384,3 @@ Mutes the output stream that was used to create the readline interface, and returns a function for unmuting the stream. This is useful in unit tests.

### [.end](index.js#L623)
### [.end](index.js#L624)

@@ -391,3 +391,3 @@ Pause the readline and unmute the output stream that was

### [.resume](index.js#L638)
### [.resume](index.js#L639)

@@ -398,3 +398,3 @@ [Resume](https://nodejs.org/api/readline.html#readline_rl_resume) the readline input stream if it has been paused.

### [.choices](index.js#L684)
### [.choices](index.js#L685)

@@ -405,3 +405,3 @@ Getter for getting the choices array from the question.

### [.message](index.js#L701)
### [.message](index.js#L702)

@@ -412,3 +412,3 @@ Getter that returns `question.message` after passing it to [format](#format).

### [.prefix](index.js#L723)
### [.prefix](index.js#L724)

@@ -426,4 +426,49 @@ Getter/setter that returns the prefix to use before `question.message`. The default value is a green `?`.

### [.Question](index.js#L743)
### [.ask](index.js#L753)
Static convenience method for running the prompt asynchronously. Takes the same arguments as the contructror.
**Params**
* `question` **{Object}**: Plain object or instance of [prompt-question](https://github.com/enquirer/prompt-question).
* `answers` **{Object}**: Optionally pass an answers object from a prompt manager (like [enquirer](https://github.com/enquirer/enquirer)).
* `ui` **{Object}**: Optionally pass an instance of [readline-ui](https://github.com/enquirer/readline-ui). If not passed, an instance is created for you.
* `callback` **{Function}**
* `returns` **{undefined}**
**Example**
```js
var prompt = require('prompt-base');
var question = { name: 'color', message: 'What is your favorite color?' };
prompt.ask(question, function(answer) {
console.log(answer);
//=> 'blue'
});
```
### [.run](index.js#L779)
Static convenience method for running the prompt. Takes the same arguments as the contructror.
**Params**
* `question` **{Object}**: Plain object or instance of [prompt-question](https://github.com/enquirer/prompt-question).
* `answers` **{Object}**: Optionally pass an answers object from a prompt manager (like [enquirer](https://github.com/enquirer/enquirer)).
* `ui` **{Object}**: Optionally pass an instance of [readline-ui](https://github.com/enquirer/readline-ui). If not passed, an instance is created for you.
* `returns` **{Promise}**
**Example**
```js
var prompt = require('prompt-base');
prompt.run({ name: 'color', message: 'What is your favorite color?'})
.then(function(answer) {
console.log(answer);
//=> 'blue'
});
```
### [.Question](index.js#L795)
Create a new `Question`. See [prompt-question](https://github.com/enquirer/prompt-question) for more details.

@@ -442,3 +487,3 @@

### [.Choices](index.js#L757)
### [.Choices](index.js#L809)

@@ -458,3 +503,3 @@ Create a new `Choices` object. See [prompt-choices](https://github.com/enquirer/prompt-choices) for more details.

### [.Separator](index.js#L770)
### [.Separator](index.js#L822)

@@ -558,3 +603,3 @@ Create a new `Separator` object. See [choices-separator](https://github.com/enquirer/choices-separator) for more details.

| --- | --- |
| 114 | [jonschlinkert](https://github.com/jonschlinkert) |
| 119 | [jonschlinkert](https://github.com/jonschlinkert) |
| 6 | [doowb](https://github.com/doowb) |

@@ -594,2 +639,2 @@

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 26, 2017._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 27, 2017._
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