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 0.3.0 to 1.0.0

2

example.js

@@ -11,3 +11,3 @@ var QA = require('./');

{ title: "{yellow}Favorite {green}Fruits{reset}:", commaList: true },
{ key: 'thatsAll', title: "{yellow}{bold}That's all {grey}(yes/no) {yellow}?{reset}", bool: true },
{ key: 'thatsAll', title: "{yellow}{bold}That's all, {name}? {grey}(yes/no){reset}", bool: true },
];

@@ -14,0 +14,0 @@

var read = require("read-cli-input");
var loop = require("serial-loop");
var format = require("style-format");
var style = require("style-format");
var variable = require("variable-name");
var leftpad = require("left-pad");
var validate = require("validate-value");
var format = require("format-text");

@@ -22,2 +23,3 @@ module.exports = QA;

var answers = {};
options.answers = answers;

@@ -37,3 +39,3 @@ loop(questions.length, each, function () {

function ask (question, options, callback) {
options.stdout.write(formatQuestion(question));
options.stdout.write(format(styleQuestion(question), options.answers));

@@ -61,3 +63,3 @@ var readOptions = {

if (question.validate && (err = validate(answer, question.validate))) {
options.stdout.write(formatError(err));
options.stdout.write(styleError(err));
return ask(question, options, callback);

@@ -78,3 +80,3 @@ }

return function (line) {
options.stdout.write(formatPrefix(line, options));
options.stdout.write(stylePrefix(line, options));
};

@@ -113,3 +115,3 @@ }

if (!question.key) {
question.key = variable(clearFormat(question.title));
question.key = variable(clearFormatting(question.title));
}

@@ -120,9 +122,9 @@

function formatQuestion (question) {
function styleQuestion (question) {
return ' '
+ format(question.title)
+ style(question.title)
+ (question.list ? '\n' : ' ');
}
function formatPrefix (line, options) {
function stylePrefix (line, options) {
if (options.prefix) return options.prefix(line);

@@ -132,3 +134,3 @@ return ' ' + (line + 1) + '. ';

function clearFormat (text) {
function clearFormatting (text) {
return text.replace(/\{\w+\}/g, '');

@@ -141,4 +143,4 @@ }

function formatError (err) {
return format('\n {red}{bold}Error: ' + err.message + '{reset}\n');
function styleError (err) {
return style('\n {red}{bold}Error: ' + err.message + '{reset}\n');
}
{
"name": "cli-qa",
"version": "0.3.0",
"version": "1.0.0",
"description": "Command-line Questions & Answers",

@@ -26,2 +26,3 @@ "main": "index.js",

"dependencies": {
"format-text": "0.0.3",
"left-pad": "0.0.4",

@@ -28,0 +29,0 @@ "read-cli-input": "1.0.1",

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