Socket
Socket
Sign inDemoInstall

inquander

Package Overview
Dependencies
37
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

4

example/pizza.js

@@ -83,3 +83,5 @@ #!/usr/bin/env node

message: 'What size would you like?',
choices: ['small', 'medium', 'large', 'x-large']
// Note that one can use promises here:
choices: Promise.resolve(['small', 'medium', 'large', 'x-large'])
},

@@ -86,0 +88,0 @@ '--meats': {

var inquirer = require('inquirer'),
_ = require('lodash'),
_s = require('underscore.string'),
Promise = require('bluebird'),
CommandMapper = require('./lib/commandMapper'),

@@ -63,22 +64,23 @@ InquireMapper = require('./lib/inquireMapper'),

me = this;
questions = _.compact(questions);
questions = this.overrideQuestions(questions);
inquirer.prompt(questions)
.then(function(answers) {
answers = _(answers).map(function(value, key) {
if (_s.startsWith(key, '--')) {
if (_.isBoolean(value)) {
if (value) {
return key;
}
} else {
return [key, value];
this.overrideQuestions(questions)
.then(function(questions_res){
return inquirer.prompt(questions_res);
})
.then(function(answers) {
answers = _(answers).map(function(value, key) {
if (_s.startsWith(key, '--')) {
if (_.isBoolean(value)) {
if (value) {
return key;
}
} else {
if (_.isArray(value)) {
value = value.join(',');
}
return value;
return [key, value];
}
}).flatten().compact().value();
} else {
if (_.isArray(value)) {
value = value.join(',');
}
return value;
}
}).flatten().compact().value();
me.argv = _.union(me.argv, answers);

@@ -91,11 +93,27 @@ me.program.parse(me.argv);

var me = this;
return _.compact(_.map(questions, function(question) {
return Promise.map(questions, function(question) {
var override = me.overrides[question.name];
if (_.includes(me.hidden, question.name)) {
// Check if Undefined
if(typeof override === "undefined"){
return null;
}
return _.merge(question, override);
}));
// Check if Hidden
else if (_.includes(me.hidden, question.name)) {
return null;
}
// Resolve Promises
return Promise.props(override)
.then(function(override_res){
return _.merge(question, override_res);
});
})
.then(function(res){
return _.compact(res);
});
};
module.exports = new Inquander();
{
"name": "inquander",
"version": "1.1.0",
"version": "1.1.1",
"description": "Inquirer for commander. If no arguments and options are passed to your commander app, it runs inquirer.",

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

"dependencies": {
"bluebird": "^3.5.0",
"commander": "^2.9.0",

@@ -37,0 +38,0 @@ "inquirer": "^3.1.0",

@@ -86,3 +86,3 @@ inquander

`Inquander.runCommand(command, forceInteractive)` allows you to manually trigger a generated
command.
command.

@@ -93,1 +93,19 @@ #### Detecting Interactive Mode

whether inquander is using inquirer or commander.
#### Promises in Overrides
One can also pass Promises in for any value inside of the overrides object,
for instance:
``Javascript
inquander.parse(program, process.argv, {
overrides: {
'creditcard': {
type: 'password'
},
'pickup': {
type: 'checkbox',
choices: Promise.resolve(['one','two'])
}
}
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc