title: Emitting custom event
body: <p>I am using my custom yeoman generator programmatical in one of my nodejs module. I have written an Adapter to replace default TerminalAdapter.
  The issues are,</p>
  
  <blockquote>
    <ul>
    <li>When I am triggering custom event using <code>emit</code> method, I am not able
    to listen for that event in my module. It is not getting fired.</li>
    <li>Even <code>end</code> event listener also not getting fired.</li>
    </ul>
  </blockquote>
  
  <p>Please let me know what I am missing here,</p>
  
  <p>Below is my module code,</p>
  
  <pre><code>'use strict';
  var fs = require('fs');
  var path = require('path');
  var MyOwnAdapter = require('./MyOwnAdapter');
  var adapt = new MyOwnAdapter();
  var env = require('./generator-myframewrk/node_modules/yeoman-generator')(null, {}, adapt);
  
  env.register(path.resolve(__dirname, './generator-myframewrk'), 'myframewrk');
  exports.run = function (options, answers) {
      var obj = {};
      adapt.setAnswers(answers);
      process.chdir(options.projdir);
  
      env.on("end", function(){
          this.log("Even this is not getting called !!!"); //not coming here
      }.bind(this));
  
      env.on("alldone", function(){
          this.log("Everything is done (including Bower install)");  //not coming here
          obj.cb();
      }.bind(this));
  
      env.run('myframewrk', function(){
          this.log('ran yo myframewrk, But bower install might be pending'); //coming here
      });
  
      return {
          done: function (cb) {
              obj.cb = cb;
          }
      };
  };
  </code></pre>
  
  <p>Below is my Generator code,</p>
  
  <pre><code>var MyframewrkGenerator = yeoman.generators.Base.extend({
      init: function () {
          this.pkg = require('../package.json');
  
          this.on('end', function () {
              if (!this.options['skip-install']) {
                  this._installBower();
              }
          });
      },
  
      _installBower: function () {
          this.log("Running bower install...");
          /*reads bower.json and installs*/
          bower.commands.install([], {}, {directory : "./"}).on('error', function (error) {
              this.log("BOWER error::");
              this.log(JSON.stringify(error));
          }.bind(this)).on('log', function (log) {
              this.log("BOWER LOG::"); // coming here
          }.bind(this)).on('end', function (installed) {
              this.log("BOWER END::"); // coming here
              this.emit("alldone");   // my custom event
          }.bind(this));
      },
  
      askFor: function () { ...
  </code></pre>