Comparing version 2.1.0 to 2.1.1
@@ -5,3 +5,3 @@ var NewQA = require('./'); | ||
QA.ask("{white}Name:{reset}"); | ||
QA.ask({ title: "Username:", default: process.env.USER }); | ||
QA.ask({ title: "Username:", default: process.env.USER, expect: { len: [2] } }); | ||
QA.ask({ title: "E-Mail:", expect: { email: true } }); | ||
@@ -8,0 +8,0 @@ QA.ask({ title: "{red}Favorite foods:{reset}", list: 3 }); |
@@ -53,2 +53,6 @@ var struct = require("new-struct"); | ||
if (isEmpty(answer) && question.default) { | ||
answer = question.render(question.default); | ||
} | ||
var err; | ||
@@ -59,4 +63,2 @@ if ((err = question.validate(answer))) { | ||
answer = isEmpty(answer) && question.render(question.default) || answer; | ||
callback(undefined, answer); | ||
@@ -124,3 +126,3 @@ }); | ||
function isEmpty (str) { | ||
return !str && (!str.trim || !str.trim()); | ||
return !str || (str.trim && !str.trim()); | ||
} |
{ | ||
"name": "cli-qa", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "Command-line Questions & Answers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -41,13 +41,2 @@ ## cli-qa | ||
### Styling | ||
Title and description fields can be styled with [style-format](http://github.com/azer/style-format) interface. Here is an example; | ||
```js | ||
QA([{ title: "{green}Yes{reset}/{red}No{reset}?", bool: true }], function (answers) { | ||
answers[yesNo] | ||
// => true or false | ||
}) | ||
``` | ||
### Reference | ||
@@ -54,0 +43,0 @@ |
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
180
7736
52