Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[answer] argument of khaos.generate is always undefined. #101

Open
lili21 opened this issue Apr 12, 2016 · 0 comments
Open

[answer] argument of khaos.generate is always undefined. #101

lili21 opened this issue Apr 12, 2016 · 0 comments

Comments

@lili21
Copy link

lili21 commented Apr 12, 2016

generate(template, dest, function(err) {
  if (err) {
    logger.fatal(err);
  }
  console.log();
  logger.success('Generated "%s".', name);
});

function generate(template, dest, fn) {
  var schema = require('../schema.json');
  schema.name.default = name;
  var khaos = new Khaos(template);
  khaos.format({
    color: 'green',
    separator: ': ',
    prefix: '? '
  });
  khaos.schema(schema);
  khaos.helpers({
    'raw-helper': function(opts) {
      return opts.fn();
    }
  });
  khaos.generate(dest, fn);
}

Actually, the fn be called after generate done. But khaos using those {{}} from template as schema, not just the schema I configured. so I read this source code.

Khaos.prototype.generate = unyield(function*(destination, answers){
  assert(is.string(destination), 'You must pass a destination path to generate to.');
  var files = yield this.read();
  if (!answers) {
    var schema = yield this.parse(files);
    answers = yield this.prompt(schema);
  }

  assert(is.object(answers), 'The answers must be an object.');
  yield this.write(destination, files, answers);
});

If I pass answers argument, then I can disable those behavior, right? But It doesn't work. I added this code console.log(answers), It always output undefined. so Why ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant