assemble-ask
Advanced tools
+14
-12
@@ -13,12 +13,7 @@ /*! | ||
| module.exports = function (options) { | ||
| var Ask = utils.ask; | ||
| return function (app) { | ||
| function config(inst, ctx) { | ||
| var data = inst.store && inst.store.data; | ||
| ctx = utils.merge({}, data, ctx); | ||
| return utils.ask({ | ||
| questions: inst.questions, | ||
| store: inst.store, | ||
| data: ctx | ||
| }); | ||
| if (this.store && this.options.init) { | ||
| this.store.del({force: true}); | ||
| } | ||
@@ -31,4 +26,10 @@ | ||
| options = utils.merge({}, this.options, options); | ||
| this.questions = utils.questions(options); | ||
| var ask = new Ask({ | ||
| questions: this.questions, | ||
| store: this.store, | ||
| }); | ||
| /** | ||
@@ -54,5 +55,4 @@ * Set a question to ask at a later point. | ||
| if (typeof locals === 'object') { | ||
| utils.merge(ctx, locals); | ||
| ctx = utils.merge({}, ctx, locals.hash || locals); | ||
| } | ||
| var ask = config(this, ctx); | ||
| return ask.once(name, ctx, cb); | ||
@@ -71,3 +71,5 @@ }); | ||
| } | ||
| var args = [name, locals.hash || {}, cb]; | ||
| locals = locals || {}; | ||
| var opts = utils.merge({}, locals.hash || locals); | ||
| var args = [name, opts, cb]; | ||
| return this.app.ask.apply(this.app, args); | ||
@@ -74,0 +76,0 @@ }); |
+4
-4
| { | ||
| "name": "assemble-ask", | ||
| "description": "Assemble plugin for asking questions and storing answers.", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "homepage": "https://github.com/jonschlinkert/assemble-ask", | ||
@@ -24,9 +24,9 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
| "dependencies": { | ||
| "ask-once": "^0.5.0", | ||
| "ask-once": "^0.5.1", | ||
| "lazy-cache": "^0.2.3", | ||
| "mixin-deep": "^1.1.3", | ||
| "question-cache": "^0.3.0" | ||
| "question-cache": "^0.3.1" | ||
| }, | ||
| "devDependencies": { | ||
| "assemble": "assemble/assemble#dev", | ||
| "assemble-core": "^0.1.1", | ||
| "data-store": "^0.9.0", | ||
@@ -33,0 +33,0 @@ "engine-handlebars": "^0.8.0", |
+27
-6
| 'use strict'; | ||
| /** | ||
| * Lazily required module dependencies | ||
| * Module dependencies | ||
| */ | ||
| var lazy = require('lazy-cache')(require); | ||
| var utils = require('lazy-cache')(require); | ||
| /** | ||
| * Temporarily re-assign `require` to trick browserify and | ||
| * webpack into reconizing lazy dependencies. | ||
| * | ||
| * This tiny bit of ugliness has the huge dual advantage of | ||
| * only loading modules that are actually called at some | ||
| * point in the lifecycle of the application, whilst also | ||
| * allowing browserify and webpack to find modules that | ||
| * are depended on but never actually called. | ||
| */ | ||
| var fn = require; | ||
| require = utils; | ||
| require = lazy; | ||
| /** | ||
| * Lazily required module dependencies | ||
| */ | ||
| require('ask-once', 'ask'); | ||
| require('mixin-deep', 'merge'); | ||
| require('question-cache', 'questions'); | ||
| require('ask-once', 'ask'); | ||
| /** | ||
| * Restore `require` | ||
| */ | ||
| require = fn; | ||
| /** | ||
| * Expose `lazy` | ||
| * Expose `utils` modules | ||
| */ | ||
| module.exports = lazy; | ||
| module.exports = utils; |
7531
7.65%92
22.67%Updated
Updated