{"_id":"ask-when","_rev":"227922","name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","dist-tags":{"latest":"0.1.7"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"time":{"modified":"2021-06-03T15:44:00.000Z","created":"2016-06-26T07:46:15.404Z","0.1.7":"2016-08-18T03:54:53.407Z","0.1.5":"2016-08-17T11:09:56.111Z","0.1.4":"2016-07-14T00:45:24.740Z","0.1.3":"2016-07-11T17:27:50.685Z","0.1.2":"2016-07-11T17:16:19.453Z","0.1.1":"2016-06-26T07:58:41.403Z","0.1.0":"2016-06-26T07:46:15.404Z"},"users":{"rbecheras":true},"author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"versions":{"0.1.7":{"name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","version":"0.1.7","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js","LICENSE","README.md"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"debug":"^2.2.0","get-value":"^2.0.6","is-answer":"^0.1.0","is-valid-app":"^0.2.0","mixin-deep":"^1.1.3"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.7.1","gulp-format-md":"^0.1.9"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":true,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["assemble","base","base-questions","generate","question-cache","question-store","update","verb","verb-generate-readme"],"lint":{"reflinks":true}},"gitHead":"33774d0bb0334ec38b8cea2da774ab877b5c6cf6","_id":"ask-when@0.1.7","_shasum":"1086b10e961933776a9d801ca2aa72645e5060be","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"1086b10e961933776a9d801ca2aa72645e5060be","size":4101,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.7.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ask-when-0.1.7.tgz_1471492491431_0.11436416232027113"},"directories":{},"publish_time":1471492493407,"_cnpm_publish_time":1471492493407,"_hasShrinkwrap":false},"0.1.5":{"name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","version":"0.1.5","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js","LICENSE","README.md"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"debug":"^2.2.0","get-value":"^2.0.6","is-answer":"^0.1.0","is-valid-app":"^0.2.0","mixin-deep":"^1.1.3"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.7.1","gulp-format-md":"^0.1.9"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":true,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["assemble","base","base-questions","generate","question-cache","question-store","update","verb","verb-generate-readme"],"lint":{"reflinks":true}},"gitHead":"cbba3c7fef5c3c84ed1623bf8b0ae2011a6aab01","_id":"ask-when@0.1.5","_shasum":"2c49368c5401ddeff1d79c0d0aafeb65fada8879","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"2c49368c5401ddeff1d79c0d0aafeb65fada8879","size":3992,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.5.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ask-when-0.1.5.tgz_1471432194137_0.3756797837559134"},"directories":{},"publish_time":1471432196111,"_cnpm_publish_time":1471432196111,"_hasShrinkwrap":false},"0.1.4":{"name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","version":"0.1.4","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js","LICENSE","README.md"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","get-value":"^2.0.6","is-answer":"^0.1.0","is-valid-app":"^0.2.0"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.7.1","gulp-format-md":"^0.1.9"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["assemble","base","base-questions","generate","question-cache","question-store","update","verb","verb-generate-readme"],"lint":{"reflinks":true}},"gitHead":"9745648feff7e73aa03dbe2a4fa03ea0b4432a4f","_id":"ask-when@0.1.4","_shasum":"fa64521a2c6b01e9db9c2c2cb81be0b68e05e114","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.3.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"fa64521a2c6b01e9db9c2c2cb81be0b68e05e114","size":3680,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.4.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/ask-when-0.1.4.tgz_1468457122845_0.10309792961925268"},"directories":{},"publish_time":1468457124740,"_cnpm_publish_time":1468457124740,"_hasShrinkwrap":false},"0.1.3":{"name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","version":"0.1.3","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js","LICENSE","README.md"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","get-value":"^2.0.6","is-answer":"^0.1.0","is-valid-app":"^0.2.0"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.6.6","gulp-format-md":"^0.1.9"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["assemble","base","base-questions","generate","question-cache","question-store","update","verb","verb-generate-readme"],"lint":{"reflinks":true}},"gitHead":"88e00fb3b8caf78ab25b6351fe8594b6ef3bfb94","_id":"ask-when@0.1.3","_shasum":"7d792aa48d27f5f3e714356ebe48b1386aa865f1","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"7d792aa48d27f5f3e714356ebe48b1386aa865f1","size":2010,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.3.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ask-when-0.1.3.tgz_1468258068349_0.10992004885338247"},"directories":{},"publish_time":1468258070685,"_cnpm_publish_time":1468258070685,"_hasShrinkwrap":false},"0.1.2":{"name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","version":"0.1.2","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js","LICENSE","README.md"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","get-value":"^2.0.6","is-answer":"^0.1.0","is-valid-app":"^0.2.0"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.6.6","gulp-format-md":"^0.1.9"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["assemble","base","base-questions","generate","question-cache","question-store","update","verb","verb-generate-readme"],"lint":{"reflinks":true}},"gitHead":"40ab1ab644c911074b6d9717e20e364a9f09d3f1","_id":"ask-when@0.1.2","_shasum":"101815c6454a6dc5eefaab8e32a31faad751026f","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"101815c6454a6dc5eefaab8e32a31faad751026f","size":2011,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.2.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ask-when-0.1.2.tgz_1468257377287_0.5960501655936241"},"directories":{},"publish_time":1468257379453,"_cnpm_publish_time":1468257379453,"_hasShrinkwrap":false},"0.1.1":{"name":"ask-when","description":"Conditionally prompt the user based on options. For use with Base applications or question-store.","version":"0.1.1","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","get-value":"^2.0.6","is-answer":"^0.1.0","is-valid-app":"^0.1.2"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.6.6","gulp-format-md":"*","mocha":"*"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["assemble","base","base-questions","generate","question-cache","question-store","update","verb","verb-readme-generator"],"lint":{"reflinks":true}},"gitHead":"38ac6743a2efdf1b4cb7d4d0b48b0e87395120ef","_id":"ask-when@0.1.1","_shasum":"09337cee0f9261c2c00bb0678ea846dc3b723ce6","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"09337cee0f9261c2c00bb0678ea846dc3b723ce6","size":1930,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ask-when-0.1.1.tgz_1466927918855_0.24492391175590456"},"directories":{},"publish_time":1466927921403,"_cnpm_publish_time":1466927921403,"_hasShrinkwrap":false},"0.1.0":{"name":"ask-when","description":"Conditionally prompt the user based on options.","version":"0.1.0","homepage":"https://github.com/jonschlinkert/ask-when","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git+https://github.com/jonschlinkert/ask-when.git"},"bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT","files":["index.js"],"main":"index.js","engines":{"node":">=0.10.0"},"scripts":{"test":"mocha"},"dependencies":{"extend-shallow":"^2.0.1","is-answer":"^0.1.0","is-valid-app":"^0.1.2"},"devDependencies":{"base":"^0.11.1","base-questions":"^0.6.6","gulp-format-md":"*","mocha":"*"},"keywords":["ask","cli","inquirer","interact","interaction","prompt","question","terminal","user","when"],"verb":{"toc":false,"layout":"default","tasks":["readme"],"plugins":["gulp-format-md"],"related":{"list":["base-questions","question-cache","question-store"]},"reflinks":["base","base-questions","generate","question-cache","question-store","verb","verb-readme-generator"],"lint":{"reflinks":true}},"gitHead":"d5394a38ee6f72aea06a9318be5e2094252a2ab9","_id":"ask-when@0.1.0","_shasum":"7925d7c7361190d23718eb4f5c18dba80caeea66","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"7925d7c7361190d23718eb4f5c18dba80caeea66","size":1847,"noattachment":false,"key":"/ask-when/-/ask-when-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/ask-when/download/ask-when-0.1.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/ask-when-0.1.0.tgz_1466927172799_0.42071960074827075"},"directories":{},"publish_time":1466927175404,"_cnpm_publish_time":1466927175404,"_hasShrinkwrap":false}},"readme":"# ask-when [![NPM version](https://img.shields.io/npm/v/ask-when.svg?style=flat)](https://www.npmjs.com/package/ask-when) [![NPM downloads](https://img.shields.io/npm/dm/ask-when.svg?style=flat)](https://npmjs.org/package/ask-when)\n\nConditionally prompt the user based on options. For use with Base applications or question-store.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [API](#api)\n  * [askWhen](#askwhen)\n  * [.when](#when)\n  * [Options](#options)\n- [Compatibility](#compatibility)\n- [About](#about)\n  * [Related projects](#related-projects)\n  * [Contributing](#contributing)\n  * [Building docs](#building-docs)\n  * [Running tests](#running-tests)\n  * [Author](#author)\n  * [License](#license)\n\n_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save ask-when\n```\n\n## Usage\n\n```js\nvar askWhen = require('ask-when');\nvar questions = require('base-questions');\nvar Base = require('base');\nvar app = new Base({isApp: true});\n\n// register plugins\napp.use(questions());\napp.use(askWhen());\n```\n\n## API\n\n### askWhen\n\nThe main export is a function that can be passed to `.use()`, if you want to register this as a plugin.\n\n```js\napp.askWhen(name, options, cb);\n```\n\n**Params**\n\n* `name` **{String}**: question name\n* `options` **{Object|Function}**: Callback, or options object. If options, an \"answer\" value may be passed on `options[name]`.\n* `cb` **{Function}**: callback\n\n**Prerequisites**\n\n* [base-questions](https://github.com/node-base/base-questions): the `base-questions` plugin must be registered before `ask-when` is registered\n* `isApp` must be defined on the instance (either define `app.isApp = true`, or pass `{isApp: true}` to the constructor. This prevents the plugin from loading on [invalid instances](https://github.com/node-base/is-valid-app)):\n\n**Register the plugin**\n\n```js\nvar askWhen = require('ask-when');\nvar questions = require('base-questions');\nvar Base = require('base');\nvar app = new Base({isApp: true});\n\n// register plugins\napp.use(questions());\napp.use(askWhen());\n```\n\n**Example usage**\n\n```js\n// define when\napp.options.askWhen = 'not-answered';\n\napp.question('dest', 'Destination directory?', {default: process.cwd()})\n  .askWhen('dest', function(err, answers) {\n    if (err) return console.log(err);\n    console.log(answers)\n  });\n```\n\n### .when\n\nAlternatively, a `.when` method is exposed if you don't want to register this as a plugin.\n\n```js\nask.when(app, name, val, cb);\n```\n\n**Params**\n\n* `app` **{Object}**: instance of [base](https://github.com/node-base/base) (one of the applications listed in the [compatibility section](#compatibility))\n* `name` **{String}**: question name\n* `options` **{Object|Function}**: Callback, or options object. If options, an \"answer\" value may be passed on `options[name]`.\n* `cb` **{Function}**: callback\n\n**Prerequisites**\n\n* [base-questions](https://github.com/node-base/base-questions): the `base-questions` plugin must be registered before `ask-when` is registered\n\n```js\nvar ask = require('ask-when');\nvar askWhen = require('ask-when');\nvar questions = require('base-questions');\nvar Base = require('base');\nvar app = new Base({isApp: true});\n\n// register the `base-questions` plugin first\napp.use(questions());\n\n// ask questions\napp.question('dest', 'Destination directory?', {default: process.cwd()})\nask.when(app, 'dest', function(err, answers) {\n  if (err) return console.log(err);\n  console.log(answers)\n});\n```\n\n### Options\n\nThis library wraps the `.ask` method from [base-questions](https://github.com/node-base/base-questions) to allow prompts to be conditionally skipped when one of the following values is defined on `options` (either on `app.options`, or options passed to `askWhen` directly)\n\n* `never`: the question will always be skipped\n* `always`: the question will always be asked\n* `not-answered`: the question will only be asked if a value is not already defined\n\n## Compatibility\n\nCan be used with any of the following libs:\n\n* [question-cache](https://github.com/jonschlinkert/question-cache)\n* [question-store](https://github.com/jonschlinkert/question-store)\n* [base](https://github.com/node-base/base), when the [base-questions](https://github.com/node-base/base-questions) plugin is used\n* [assemble](https://github.com/assemble/assemble), in your `assemblefile.js`\n* [generate](https://github.com/generate/generate), in your `generator.js`\n* [update](https://github.com/update/update), in your `updatefile.js`\n* [verb](https://github.com/verbose/verb), in your `verbfile.js`\n\n## About\n\n### Related projects\n\n* [base-questions](https://www.npmjs.com/package/base-questions): Plugin for base-methods that adds methods for prompting the user and storing the answers on… [more](https://github.com/node-base/base-questions) | [homepage](https://github.com/node-base/base-questions \"Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.\")\n* [question-cache](https://www.npmjs.com/package/question-cache): A wrapper around inquirer that makes it easy to create and selectively reuse questions. | [homepage](https://github.com/jonschlinkert/question-cache \"A wrapper around inquirer that makes it easy to create and selectively reuse questions.\")\n* [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://github.com/jonschlinkert/question-store) | [homepage](https://github.com/jonschlinkert/question-store \"Ask questions, persist the answers. Basic support for i18n and storing answers based on current working directory.\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Building docs\n\n_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_\n\nTo generate the readme and API documentation with [verb](https://github.com/verbose/verb):\n\n```sh\n$ npm install -g verb verb-generate-readme && verb\n```\n\n### Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm install -d && npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT license](https://github.com/jonschlinkert/ask-when/blob/master/LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.30, on August 17, 2016._","_attachments":{},"homepage":"https://github.com/jonschlinkert/ask-when","bugs":{"url":"https://github.com/jonschlinkert/ask-when/issues"},"license":"MIT"}