'use strict';

var utils = require('lazy-cache')(require);
var fn = require;
require = utils; // eslint-disable-line

/**
 * Utils
 */

require('data-store', 'Store');
require('extend-shallow', 'extend');
require('get-value', 'get');
require('fs-exists-sync', 'exists');
require('is-answer');
require('mixin-deep', 'merge');
require('resolve-dir');
require = fn; // eslint-disable-line

/**
 * Async helper that prompts the user and populates a template
 * with the answer.
 *
 * ```html
 * <%%= ask('author.name') %>
 * ```
 * @param {Object} `app`
 * @return {Function} Returns the helper function
 * @api public
 */

utils.ask = function(app) {
  return function ask(name, options, cb) {
    if (typeof options === 'function') {
      return ask.call(this, name, {}, options);
    }

    options = utils.merge({}, this.options, options);
    var ctx = this.context;
    var val = ctx.get(name);

    var isAnswered = utils.isAnswer(val);
    options.force = !isAnswered;
    options.save = false;

    // conditionally prompt the user
    switch (options.askWhen) {
      case 'never':
        cb(null, val);
        return;

      case 'not-answered':
        if (isAnswered) {
          cb(null, val);
          return;
        }
        break;

      case 'always':
      default: {
        break;
      }
    }

    this.app.ask(name, options, function(err, answers) {
      if (err) return cb(err);
      app.data(answers);
      cb(null, utils.get(answers, name));
    });
  };
};

/**
 * Expose utils
 */

module.exports = utils;

@@ -660,32 +660,41 @@
 nction ask(name,
+ message,
  options, cb) %7B%0A
@@ -689,24 +689,126 @@
 ions, cb) %7B%0A
+    if (typeof message === 'function') %7B%0A      return ask.call(this, name, null, %7B%7D, message);%0A    %7D%0A%0A
     if (type
@@ -869,16 +869,25 @@
 s, name,
+ message,
  %7B%7D, opt
@@ -896,24 +896,108 @@
 ns);%0A    %7D%0A%0A
+    if (typeof options === 'string') %7B%0A      options = %7B message: options %7D;%0A    %7D%0A%0A
     options 
@@ -1011,16 +1011,32 @@
 .merge(%7B
+message: message
 %7D, this.

allow `message` to be passed as a string to ask helper