index.js
function ask(file, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts;
    opts = {};
  }
  opts = opts || {};
  var prompt = lazy.inquirer.createPromptModule();
  var fp = path.relative(process.cwd(), file.path);

  var questions = {
    name: 'action',
    type: 'expand',
    message: 'Overwrite `' + fp + '`?',
    value: 'nothing',
    choices: [{
      key: 'n',
      name: 'do not overwrite',
      value: 'skip'
    }, {
      key: 'y',
      name: 'overwrite',
      value: 'write'
    }, {
      key: 'a',
      name: 'overwrite this and all others',
      value: 'force'
    }, {
      key: 'x',
      name: 'abort',
      value: 'abort'
    }, {
      key: 'd',
      name: 'diff comparison between the current and new:',
      value: 'diff'
    }]
  };

  prompt([questions], function (answers) {
    var msg = answers.action;

    switch(answers.action) {
      case 'skip':
        cb(answers.action);
        process.exit(0);

      case 'abort':
        msg = utils.red(utils.error) + ' Aborted. No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);

      case 'diff':
        var existing = opts.existing || fs.readFileSync(fp, 'utf8');
        if (lazy.isBinary(existing) && typeof opts.binaryDiff === 'function') {
          opts.binaryDiff(existing, file.contents);
        } else {
          stringDiff(existing, file.contents.toString());
        }
        return ask(file, opts, cb);

      case 'force':
        opts.force = true;
        break;

      case 'write':
        msg = utils.green(utils.success) + ' file written to';
        opts.force = true;
        break;

      default: {
        msg = utils.red(utils.error) + utils.red(' Aborted.') + ' No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);
      }
    }

    var rel = path.relative(process.cwd(), fp);
    var filepath = utils[answers.action](rel);
    if (!opts.silent) {
      console.log(msg, filepath);
    }
    return cb(answers.action);
  });
}
function ask(file, opts, cb) {
  if (typeof opts === 'function') {
    cb = opts;
    opts = {};
  }
  opts = opts || {};
  var prompt = lazy.inquirer.createPromptModule();
  var fp = path.relative(process.cwd(), file.path);

  var questions = {
    name: 'action',
    type: 'expand',
    message: 'Overwrite `' + fp + '`?',
    value: 'nothing',
    choices: [{
      key: 'n',
      name: 'do not overwrite',
      value: 'skip'
    }, {
      key: 'y',
      name: 'overwrite',
      value: 'write'
    }, {
      key: 'a',
      name: 'overwrite this and all others',
      value: 'force'
    }, {
      key: 'x',
      name: 'abort',
      value: 'abort'
    }, {
      key: 'd',
      name: 'diff comparison between the current and new:',
      value: 'diff'
    }]
  };

  prompt([questions], function (answers) {
    var msg = answers.action;

    switch(answers.action) {
      case 'skip':
        cb(answers.action);
        process.exit(0);

      case 'abort':
        msg = utils.red(utils.error) + ' Aborted. No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);

      case 'diff':
        var existing = opts.existing || fs.readFileSync(fp, 'utf8');
        if (lazy.isBinary(existing) && typeof opts.binaryDiff === 'function') {
          opts.binaryDiff(existing, file.contents);
        } else {
          stringDiff(existing, file.contents.toString());
        }
        return ask(file, opts, cb);

      case 'force':
        opts.force = true;
        break;

      case 'write':
        msg = utils.green(utils.success) + ' file written to';
        opts.force = true;
        break;

      default: {
        msg = utils.red(utils.error) + utils.red(' Aborted.') + ' No action was taken.';
        if (!opts.silent) console.log(msg);
        cb(answers.action);
        process.exit(0);
      }
    }

    var rel = path.relative(process.cwd(), fp);
    var filepath = utils[answers.action](rel);
    if (!opts.silent) {
      console.log(msg, filepath);
    }
    return cb(answers.action);
  });
}
function ask ( file , opts , cb ) { if ( typeof opts === 'function' ) { cb = opts ; opts = { } ; } opts = opts || { } ; var prompt = lazy . inquirer . createPromptModule ( ) ; var fp = path . relative ( process . cwd ( ) , file . path ) ; var questions = { name : 'action' , type : 'expand' , message : 'Overwrite `' + fp + '`?' , value : 'nothing' , choices : [ { key : 'n' , name : 'do not overwrite' , value : 'skip' } , { key : 'y' , name : 'overwrite' , value : 'write' } , { key : 'a' , name : 'overwrite this and all others' , value : 'force' } , { key : 'x' , name : 'abort' , value : 'abort' } , { key : 'd' , name : 'diff comparison between the current and new:' , value : 'diff' } ] } ; prompt ( [ questions ] , function ( answers ) { var msg = answers . action ; switch ( answers . action ) { case 'skip' : cb ( answers . action ) ; process . exit ( 0 ) ; case 'abort' : msg = utils . red ( utils . error ) + ' Aborted. No action was taken.' ; if ( ! opts . silent ) console . log ( msg ) ; cb ( answers . action ) ; process . exit ( 0 ) ; case 'diff' : var existing = opts . existing || fs . readFileSync ( fp , 'utf8' ) ; if ( lazy . isBinary ( existing ) && typeof opts . binaryDiff === 'function' ) { opts . binaryDiff ( existing , file . contents ) ; } else { stringDiff ( existing , file . contents . toString ( ) ) ; } return ask ( file , opts , cb ) ; case 'force' : opts . force = true ; break ; case 'write' : msg = utils . green ( utils . success ) + ' file written to' ; opts . force = true ; break ; default : { msg = utils . red ( utils . error ) + utils . red ( ' Aborted.' ) + ' No action was taken.' ; if ( ! opts . silent ) console . log ( msg ) ; cb ( answers . action ) ; process . exit ( 0 ) ; } } var rel = path . relative ( process . cwd ( ) , fp ) ; var filepath = utils [ answers . action ] ( rel ) ; if ( ! opts . silent ) { console . log ( msg , filepath ) ; } return cb ( answers . action ) ; } ) ; }
Prompt the user for feedback.

@param {Object} `file`
@param {Function} `cb`
Prompt the user for feedback .