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

base-questions

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-questions - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

21

index.js

@@ -28,2 +28,3 @@ /*!

updateOpts();
var Questions = utils.questions;

@@ -33,8 +34,2 @@ var questions = new Questions(options);

// app.on('option', function(key, val) {
// if (/questions\./.test(key)) {
// utils.set(opts, key, val);
// }
// });
// force all questions to be asked when requested by the user

@@ -70,3 +65,3 @@ if (opts.init === true || opts.force === true) {

var answer = utils.get(app.cache.data, key);
var answer = utils.get(app.cache, ['expanded', key]);
if (answer) {

@@ -77,2 +72,8 @@ question.answer.set(answer);

answer = utils.get(app.cache.data, key);
if (answer) {
question.answer.set(answer);
return;
}
if (!question.isAnswered(options.locale) && store.has(key)) {

@@ -88,3 +89,3 @@ question.answer.setDefault(store.get(key));

questions.on('answer', function(key, val, question) {
if (question.options.isDefault && !store.has(key)) {
if (question.options.isDefault) {
store.set(key, val);

@@ -194,2 +195,6 @@ }

/**
* Utility for matching question names
*/
function isMatch(key, pattern) {

@@ -196,0 +201,0 @@ if (key === pattern) return true;

{
"name": "base-questions",
"description": "Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/jonschlinkert/base-questions",

@@ -73,4 +73,14 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

]
}
},
"layout": "default",
"plugins": [
"gulp-format-md"
],
"reflinks": [
"common-questions",
"question-cache",
"question-store",
"answer-store"
]
}
}

@@ -6,2 +6,3 @@ # base-questions [![NPM version](https://img.shields.io/npm/v/base-questions.svg)](https://www.npmjs.com/package/base-questions) [![Build Status](https://img.shields.io/travis/jonschlinkert/base-questions.svg)](https://travis-ci.org/jonschlinkert/base-questions)

## Install
Install with [npm](https://www.npmjs.com/)

@@ -13,3 +14,3 @@

## Usage
## Usage [![Build Status](https://img.shields.io/travis/jonschlinkert/base-questions.svg)](https://www.npmjs.com/)

@@ -70,10 +71,87 @@ Try running the [actual examples](./example.js) if it helps to see the following example in action.

### [.choices](index.js#L126)
Create a "choices" question from an array.
**Params**
* `queue` **{String|Array}**: Name or array of question names.
* `options` **{Object|Function}**: Question options or callback function
* `callback` **{Function}**: callback function
**Example**
```js
app.choices('foo', ['a', 'b', 'c']);
// or
app.choices('foo', {
message: 'Favorite letter?',
choices: ['a', 'b', 'c']
});
// then
app.ask('foo', function(err, answer) {
console.log(answer);
});
```
### [.question](index.js#L163)
Add a question to be asked at a later point.
**Params**
* `value` **{Object|String}**: Question object, message (string), or options object.
* `locale` **{String}**: Optionally pass the locale to use, otherwise the default locale is used.
* `returns` **{Object}**: Returns the `app.questions` object, for chaining
**Example**
```js
app.question('beverage', 'What is your favorite beverage?');
// or
app.question('beverage', {
type: 'input',
message: 'What is your favorite beverage?'
});
// or
app.question({
name: 'beverage'
type: 'input',
message: 'What is your favorite beverage?'
});
```
### [.ask](index.js#L186)
Ask one or more questions, with the given `options` and callback.
**Params**
* `queue` **{String|Array}**: Name or array of question names.
* `options` **{Object|Function}**: Question options or callback function
* `callback` **{Function}**: callback function
**Example**
```js
// ask all questions
app.ask(function(err, answers) {
console.log(answers);
});
// ask the specified questions
app.ask(['name', 'description'], function(err, answers) {
console.log(answers);
});
```
## Related projects
* [answer-store](https://www.npmjs.com/package/answer-store): Store answers to user prompts, based on locale and/or current working directory. | [homepage](https://github.com/jonschlinkert/answer-store)
* [common-questions](https://www.npmjs.com/package/common-questions): An object of questions commonly used by project generators or when initializing projects. Questions can… [more](https://www.npmjs.com/package/common-questions) | [homepage](https://github.com/generate/common-questions)
* [question-store](https://www.npmjs.com/package/question-store): Ask questions, persist the answers. Basic support for i18n and storing answers based on current… [more](https://www.npmjs.com/package/question-store) | [homepage](https://github.com/jonschlinkert/question-store)
* [to-choices](https://www.npmjs.com/package/to-choices): Generate an inquirer choices question from an array. | [homepage](https://github.com/generate/to-choices)
* [to-choices](https://www.npmjs.com/package/to-choices): Generate an inquirer choices question from an array. | [homepage](https://github.com/generate/to-choices)
## Running tests
Install dev dependencies:

@@ -86,11 +164,14 @@

## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/base-questions/issues/new).
## Author
**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)

@@ -101,2 +182,2 @@ Released under the MIT license.

_This file was generated by [verb](https://github.com/verbose/verb) on December 07, 2015._
_This file was generated by [verb](https://github.com/verbose/verb) on December 13, 2015._
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