Skip to content

Commit

Permalink
Merge a756477 into 8d50cd8
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Feb 19, 2020
2 parents 8d50cd8 + a756477 commit ecd307b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,9 @@ class Generator extends EventEmitter {
})()
.then(function() {
delete self.runningState;
const eventName = `done$${namespace || 'unknownnamespace'}#${methodName}`;
debug(`Emiting event ${eventName}`);
self.env.emit(eventName, namespace, self);
completed();
})
.catch(err => {
Expand Down
16 changes: 15 additions & 1 deletion test/generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,20 @@ const os = require('os');

const Base = require('..');

const NAMESPACE = 'somenamespace';

describe('Generators module', () => {
beforeEach(function() {
this.env = Environment.createEnv();
});

describe('Base', () => {
beforeEach(function() {
this.generator = new Base({
const Generator = class extends Base {};
Generator.prototype.exec = function() {};
this.generator = new Generator({
env: this.env,
namespace: NAMESPACE,
resolved: 'test'
});
});
Expand All @@ -27,6 +32,15 @@ describe('Generators module', () => {
this.generator.on('yay-o-man', done);
this.generator.emit('yay-o-man');
});

it('emits done event', function(done) {
this.env.on(`done$${NAMESPACE}#exec`, (id, generator) => {
assert(generator === this.generator);
assert(`done$${NAMESPACE}#exec`.includes(id));
done();
});
this.generator.run();
});
});

it('without localConfigOnly option', function() {
Expand Down

0 comments on commit ecd307b

Please sign in to comment.