@@ -281,6 +281,48 @@ function updateRegisterCalls(j, root) {
281281 } ) ;
282282}
283283
284+ function updateInjectCalls ( j , root ) {
285+ root
286+ . find ( j . CallExpression , {
287+ callee : {
288+ type : 'MemberExpression' ,
289+ object : {
290+ object : {
291+ type : 'ThisExpression' ,
292+ } ,
293+ property : {
294+ name : 'inject' ,
295+ } ,
296+ } ,
297+ } ,
298+ } )
299+ . forEach ( p => {
300+ let injectType = p . node . callee . property . name ;
301+ let injectedName = p . node . arguments [ 0 ] . value ;
302+ let localName = injectedName ;
303+ if ( p . node . arguments [ 1 ] ) {
304+ let options = p . node . arguments [ 1 ] ;
305+ let as = options . properties . find ( property => property . key . name === 'as' ) ;
306+ if ( as ) {
307+ localName = as . value . value ;
308+ }
309+ }
310+ let assignment = j . assignmentExpression (
311+ '=' ,
312+ j . memberExpression ( j . thisExpression ( ) , j . identifier ( localName ) ) ,
313+ j . callExpression (
314+ j . memberExpression (
315+ j . memberExpression ( j . thisExpression ( ) , j . identifier ( 'owner' ) ) ,
316+ j . identifier ( 'lookup' )
317+ ) ,
318+ [ j . literal ( `${ injectType } :${ injectedName } ` ) ]
319+ )
320+ ) ;
321+
322+ p . replace ( assignment ) ;
323+ } ) ;
324+ }
325+
284326module . exports = function ( file , api , options ) {
285327 const j = api . jscodeshift ;
286328
@@ -298,6 +340,7 @@ module.exports = function(file, api, options) {
298340 updateModuleForToNestedModule ( j , root ) ;
299341 updateLookupCalls ( j , root ) ;
300342 updateRegisterCalls ( j , root ) ;
343+ updateInjectCalls ( j , root ) ;
301344
302345 return root . toSource ( printOptions ) ;
303346} ;
0 commit comments