Skip to content

Commit 61888cb

Browse files
authored
Merge pull request #253 from typed-ember/blueprint-setup
[bugfix] Ensure TS blueprints are always used
2 parents 47bd74b + 10c8d6a commit 61888cb

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

index.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ const stew = require('broccoli-stew');
99
module.exports = {
1010
name: 'ember-cli-typescript',
1111

12-
init() {
13-
this._super.init.apply(this, arguments);
14-
15-
// If we're a direct dependency of the app, we cheat and add our instance of the blueprints
16-
// addon to the project, as only top-level addons contribute blueprints.
17-
// This won't be necessary in 2.x if we shift to adding the blueprints addon as a host
18-
// dependency on install.
19-
if (this.project.addons.includes(this)) {
20-
this.project.addons.push(this.addons.find(addon => addon.name === 'ember-cli-typescript-blueprints'));
21-
}
22-
},
23-
2412
included(includer) {
2513
this._super.included.apply(this, arguments);
2614

@@ -31,6 +19,16 @@ module.exports = {
3119
},
3220

3321
includedCommands() {
22+
// If we're a direct dependency of the app, we cheat and add our instance of the blueprints
23+
// addon to the project, as only top-level addons contribute blueprints. We need to be careful
24+
// with the timing of when we do this, as it has to happen after addon initialization is
25+
// complete, but before blueprint paths are resolved.
26+
// This won't be necessary in 2.x if we shift to adding the blueprints addon as a host
27+
// dependency on install.
28+
if (this.project.addons.includes(this)) {
29+
this.project.addons.push(this.addons.find(addon => addon.name === 'ember-cli-typescript-blueprints'));
30+
}
31+
3432
if (this.project.isEmberCLIAddon()) {
3533
return {
3634
'ts:precompile': require('./lib/commands/precompile'),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
3+
const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers');
4+
const setupTestHooks = blueprintHelpers.setupTestHooks;
5+
const emberNew = blueprintHelpers.emberNew;
6+
const emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy;
7+
8+
const expect = require('ember-cli-blueprint-test-helpers/chai').expect;
9+
10+
describe('Acceptance: TypeScript blueprints', function() {
11+
setupTestHooks(this);
12+
13+
it('uses blueprints from ember-cli-typescript-blueprints', function() {
14+
let args = ['helper', 'foo'];
15+
16+
return emberNew()
17+
.then(() => emberGenerateDestroy(args, (file) => {
18+
const generated = file('app/helpers/foo.ts');
19+
expect(generated).to.contain('export function foo');
20+
expect(generated).to.contain('export default helper(foo)');
21+
}));
22+
});
23+
});

0 commit comments

Comments
 (0)