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

cli-qa

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-qa - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

23

lib/question.js

@@ -38,3 +38,4 @@ var struct = require("new-struct");

default: options.default,
expect: options.expect
expect: options.expect,
validateFn: options.validate
});

@@ -58,8 +59,7 @@ }

var err;
if ((err = question.validate(answer))) {
return callback(err);
}
question.validate(answer, function (error) {
if (error) return callback(error);
callback(undefined, answer);
callback(undefined, answer);
});
});

@@ -92,4 +92,11 @@ }

function validate (question, answer) {
return question.expect && validateValue(answer, question.expect);
function validate (question, answer, callback) {
var err;
if (err = question.expect && validateValue(answer, question.expect)) {
return callback(err);
}
if (question.validateFn) {
question.validateFn(callback);
}
}

@@ -96,0 +103,0 @@

{
"name": "cli-qa",
"version": "2.1.2",
"version": "2.2.0",
"description": "Command-line Questions & Answers",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,8 +45,24 @@ ## cli-qa

* key: *The key that will be used in the answers object. If not specified, [it'll be auto-generated](http://github.com/azer/variable-name).*
* title: *Title of the question. [styling](http://github.com/azer/style-format) accepted.*
* list: *If a numeric value is passed, user will be prompted to enter a list with expected number of lines. If true passed, the list input won't be limited.*
* commaList: *Specify "true" if a comma-separated list is expected as an answer.*
* yesno: *Yes/no question? true/false*
* default: *Default value if answer is empty.*
* expect: *Specify [requirements](https://github.com/azer/validate-value#reference) for [validating](https://github.com/azer/validate-value) the user input.*
##### key
The key that will be used in the answers object. If not specified, [it'll be auto-generated](http://github.com/azer/variable-name)
##### title
Title of the question. [styling](http://github.com/azer/style-format) accepted.
##### list
If a numeric value is passed, user will be prompted to enter a list with expected number of lines. If true passed, the list input won't be limited.
##### commaList
Specify "true" if a comma-separated list is expected as an answer
##### yesno
Yes/no question? true/false
##### default
Default value if answer is empty.
##### expect
Specify [requirements](https://github.com/azer/validate-value#reference) for [validating](https://github.com/azer/validate-value) the user input.
##### validate
Async validation function. See tests for example.
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