Comparing version 0.1.3 to 0.1.4
26
index.js
@@ -11,2 +11,3 @@ 'use strict'; | ||
* ```js | ||
* var Enquirer = require('enquirer'); | ||
* var enquirer = new Enquirer(); | ||
@@ -20,3 +21,3 @@ * ``` | ||
debug('initializing from <%s>', __filename); | ||
this.active = false; | ||
this.session = false; | ||
this.options = options || {}; | ||
@@ -41,3 +42,3 @@ this.questions = {}; | ||
this.ui.once('finish', function() { | ||
this.active = false; | ||
this.session = false; | ||
this.close = null; | ||
@@ -170,2 +171,5 @@ this.queue = []; | ||
* ```js | ||
* var Enquirer = require('enquirer'); | ||
* var enquirer = new Enquirer(); | ||
* | ||
* enquirer.question('first', 'First name?'); | ||
@@ -198,2 +202,3 @@ * enquirer.question('last', 'Last name?'); | ||
var finish = this.finish.bind(this); | ||
this.session = true; | ||
@@ -216,2 +221,5 @@ // disable `finish` to prevent successive calls | ||
* ```js | ||
* var Enquirer = require('enquirer'); | ||
* var enquirer = new Enquirer(); | ||
* | ||
* enquirer.question('first', 'First name?'); | ||
@@ -237,7 +245,6 @@ * enquirer.prompt('first') | ||
var answers = this.answers; | ||
var self = this; | ||
try { | ||
var question = self.question(name).clone(); | ||
var PromptType = self.prompts[question.type]; | ||
var question = this.question(name).clone(); | ||
var PromptType = this.prompts[question.type]; | ||
@@ -248,4 +255,5 @@ if (typeof PromptType !== 'function') { | ||
var prompt = new PromptType(question, answers, self.ui); | ||
self.emit('prompt', question.default, question, answers, prompt); | ||
var prompt = new PromptType(question, answers, this.ui); | ||
if (this.session) prompt.session = true; | ||
this.emit('prompt', question.default, question, answers, prompt); | ||
@@ -255,3 +263,3 @@ return prompt.run(answers) | ||
question.answer = val[name]; | ||
self.emit('answer', val[name], name, question, answers); | ||
this.emit('answer', val[name], name, question, answers); | ||
return val; | ||
@@ -261,3 +269,3 @@ }) | ||
} catch (err) { | ||
self.close(); | ||
this.close(); | ||
throw err; | ||
@@ -264,0 +272,0 @@ } |
{ | ||
"name": "enquirer", | ||
"description": "Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all the same prompt types and more, but without the bloat.", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/enquirer/enquirer", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
# enquirer [![NPM version](https://img.shields.io/npm/v/enquirer.svg?style=flat)](https://www.npmjs.com/package/enquirer) [![NPM downloads](https://img.shields.io/npm/dm/enquirer.svg?style=flat)](https://npmjs.org/package/enquirer) [![Build Status](https://img.shields.io/travis/enquirer/enquirer.svg?style=flat)](https://travis-ci.org/enquirer/enquirer) | ||
Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all the same prompt types and more, but without the bloat. | ||
> Intuitive, plugin-based prompt system for node.js. Much faster and lighter alternative to Inquirer, with all the same prompt types and more, but without the bloat. | ||
@@ -9,3 +9,2 @@ ## Table of Contents | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [Prompt types](#prompt-types) | ||
@@ -37,10 +36,4 @@ * [Publishing prompt types](#publishing-prompt-types) | ||
```js | ||
var enquirer = require('enquirer'); | ||
``` | ||
### [Enquirer](index.js#L18) | ||
## API | ||
### [Enquirer](index.js#L17) | ||
Create an instance of `Enquirer` with the given `options`. | ||
@@ -55,6 +48,7 @@ | ||
```js | ||
var Enquirer = require('enquirer'); | ||
var enquirer = new Enquirer(); | ||
``` | ||
### [.register](index.js#L73) | ||
### [.register](index.js#L74) | ||
@@ -75,3 +69,3 @@ Register a new prompt `type` with the given `fn`. | ||
### [.use](index.js#L92) | ||
### [.use](index.js#L93) | ||
@@ -91,3 +85,3 @@ Invoke a plugin `fn` | ||
### [.question](index.js#L130) | ||
### [.question](index.js#L131) | ||
@@ -131,3 +125,3 @@ Create question `name` with the given `message` and `options`. Uses [enquirer-question](https://github.com/enquirer/enquirer-question), visit that library for additional details. | ||
### [.ask](index.js#L189) | ||
### [.ask](index.js#L193) | ||
@@ -145,2 +139,5 @@ Initialize a prompt session for one or more questions. | ||
```js | ||
var Enquirer = require('enquirer'); | ||
var enquirer = new Enquirer(); | ||
enquirer.question('first', 'First name?'); | ||
@@ -164,3 +161,3 @@ enquirer.question('last', 'Last name?'); | ||
### [.prompt](index.js#L223) | ||
### [.prompt](index.js#L231) | ||
@@ -181,2 +178,5 @@ Initialize a prompt session for a single question. Used by the [ask](#ask) method. | ||
```js | ||
var Enquirer = require('enquirer'); | ||
var enquirer = new Enquirer(); | ||
enquirer.question('first', 'First name?'); | ||
@@ -189,7 +189,7 @@ enquirer.prompt('first') | ||
### [.separator](index.js#L262) | ||
### [.separator](index.js#L270) | ||
Create a new `Separator` to use in a choices array. | ||
### [.Separator](index.js#L285) | ||
### [.Separator](index.js#L293) | ||
@@ -206,4 +206,4 @@ Create a new `Separator` to use in a choices array. | ||
* [ ] `checkbox` ([enquirer-prompt-checkbox][]) | ||
* [ ] `confirm` ([enquirer-prompt-confirm][]) | ||
* [x] `checkbox` ([enquirer-prompt-checkbox](https://github.com/enquirer/enquirer-prompt-checkbox)) | ||
* [x] `confirm` ([enquirer-prompt-confirm](https://github.com/enquirer/enquirer-prompt-confirm)) | ||
* [ ] `editor` ([enquirer-prompt-editor][]) | ||
@@ -214,3 +214,3 @@ * [ ] `expand` ([enquirer-prompt-expand][]) | ||
* [ ] `password` ([enquirer-prompt-password][]) | ||
* [ ] `radio` ([enquirer-prompt-radio][]) | ||
* [x] `radio` ([enquirer-prompt-radio](https://github.com/enquirer/enquirer-prompt-radio)) | ||
* [ ] `rawlist` ([enquirer-prompt-rawlist][]) | ||
@@ -320,2 +320,2 @@ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 29, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 30, 2016._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22348
291