Skip to content

Commit

Permalink
Ensure that the namespace and resolved properties are passed (#108)
Browse files Browse the repository at this point in the history
In the case of a module generator, the namespace and resolved properties
were being lost as the instantiate function expects them to be attached
as properties of the constructor function. This commit ensures they
are being passed where the instantiate function expects to find them.

For issue #107
  • Loading branch information
esheffield authored and SBoudrias committed Nov 4, 2018
1 parent 096b5ce commit f0b05a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ class Environment extends EventEmitter {
const Generator = this.get(namespace);

if (typeof Generator !== 'undefined' && typeof Generator.default === 'function') {
Generator.default.resolved = Generator.resolved;
Generator.default.namespace = Generator.namespace;
return this.instantiate(Generator.default, options);
}

Expand Down
12 changes: 12 additions & 0 deletions test/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ describe('Environment', () => {
it('adds the namespace as called on the options', function () {
assert.equal(this.env.create('stub:foo:bar').options.namespace, 'stub:foo:bar');
});

it('adds the namespace from a module generator on the options', function () {
this.env
.register(path.join(__dirname, './fixtures/generator-module/generators/app'), 'fixtures:generator-module');
assert.equal(this.env.create('fixtures:generator-module').options.namespace, 'fixtures:generator-module');
});

it('adds the Generator resolved path from a module generator on the options', function () {
this.env
.register(path.join(__dirname, './fixtures/generator-module/generators/app'), 'fixtures:generator-module');
assert.equal(this.env.create('fixtures:generator-module').options.resolved, this.env.get('fixtures:generator-module').resolved);
});
});

describe('#run()', () => {
Expand Down

0 comments on commit f0b05a0

Please sign in to comment.