@@ -121,16 +121,7 @@ module.exports = {
121
121
122
122
beforeInstall ( ) {
123
123
if ( this . project . isEmberCLIAddon ( ) ) {
124
- let pkg = readPackage ( this . project ) ;
125
-
126
- this . _installPrecompilationHooks ( pkg ) ;
127
-
128
- if ( pkg . devDependencies [ 'ember-cli-typescript' ] ) {
129
- pkg . dependencies [ 'ember-cli-typescript' ] = pkg . devDependencies [ 'ember-cli-typescript' ] ;
130
- delete pkg . devDependencies [ 'ember-cli-typescript' ] ;
131
- }
132
-
133
- writePackage ( this . project , pkg ) ;
124
+ this . _transformAddonPackage ( ) ;
134
125
}
135
126
136
127
let packages = [
@@ -184,11 +175,23 @@ module.exports = {
184
175
return this . project . isModuleUnification && this . project . isModuleUnification ( ) ;
185
176
} ,
186
177
187
- _installPrecompilationHooks ( pkg ) {
188
- // Really `prepack` and `postpack` would be ideal, but yarn doesn't execute those when publishing
189
- this . _addScript ( pkg . scripts , 'prepublishOnly' , 'ember ts:precompile' ) ;
190
- this . _addScript ( pkg . scripts , 'postpublish' , 'ember ts:clean' ) ;
178
+ _transformAddonPackage ( ) {
179
+ const pkgPath = `${ this . project . root } /package.json` ;
180
+
181
+ let pkg = JSON . parse ( fs . readFileSync ( pkgPath , 'utf-8' ) ) ;
182
+
183
+ // Really `prepack` and `postpack` would be ideal, but yarn doesn't execute those when publishing
184
+ this . _addScript ( pkg . scripts , 'prepublishOnly' , 'ember ts:precompile' ) ;
185
+ this . _addScript ( pkg . scripts , 'postpublish' , 'ember ts:clean' ) ;
186
+
187
+ // avoid being placed in devDependencies
188
+ const name = 'ember-cli-typescript' ;
189
+ if ( pkg . devDependencies [ name ] ) {
190
+ pkg . dependencies [ name ] = pkg . devDependencies [ name ] ;
191
+ delete pkg . devDependencies [ name ] ;
192
+ }
191
193
194
+ fs . writeFileSync ( pkgPath , JSON . stringify ( pkg , null , 2 ) + '\n' ) ;
192
195
} ,
193
196
194
197
_addScript ( scripts , type , script ) {
@@ -209,15 +212,3 @@ module.exports = {
209
212
}
210
213
} ,
211
214
} ;
212
-
213
- const packagePath = ( project ) => `${ project . root } /package.json` ;
214
-
215
- function readPackage ( project ) {
216
- const path = packagePath ( project )
217
-
218
- return JSON . parse ( fs . readFileSync ( path , 'utf-8' ) ) ;
219
- }
220
-
221
- function writePackage ( project , pkg ) {
222
- fs . writeFileSync ( packagePath ( project ) , JSON . stringify ( pkg , null , 2 ) + '\n' ) ;
223
- }
0 commit comments