File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,8 +65,19 @@ export default Mixin.create({
6565 run . scheduleOnce ( 'afterRender' , this , this . updateOpenFiles ) ;
6666 } ,
6767
68- addFile ( type ) {
69- let fileProperties = type ? this . emberCli . buildProperties ( type ) : { filePath :'file.js' } ;
68+ async addFile ( type ) {
69+ let replacements = { } ;
70+ let isGlimmer = await this . emberCli . twiddleJson . hasAddon ( this . model , '@glimmer/component' ) ;
71+
72+ if ( type === 'component-js' ) {
73+ replacements . importComponent = isGlimmer ?
74+ `import Component from '@glimmer/component';` :
75+ `import Component from '@ember/component';` ;
76+ replacements . importTemplate = '' ;
77+ replacements . defaultExport = "class extends Component {\n}" ;
78+ }
79+
80+ let fileProperties = type ? this . emberCli . buildProperties ( type , replacements ) : { filePath :'file.js' } ;
7081 let filePath = fileProperties . filePath ;
7182
7283 if ( [ 'twiddle.json' , 'router' , 'css' ] . indexOf ( type ) === - 1 ) {
Original file line number Diff line number Diff line change @@ -131,8 +131,8 @@ export default Service.extend({
131131 } ,
132132
133133 async hasAddon ( gist , addonName ) {
134- let json = await this . _getTwiddleJson ( gist ) ;
135- return addonName in json . addons ;
134+ let { addons = { } } = await this . _getTwiddleJson ( gist ) ;
135+ return addonName in addons ;
136136 } ,
137137
138138 _dedupEmberData ( json ) {
You can’t perform that action at this time.
0 commit comments