@@ -20,15 +20,10 @@ export default function maybeTransformEmberObjects(
20
20
filePath : string ,
21
21
userOptions : UserOptions
22
22
) : boolean {
23
- const options : Options = {
24
- ...userOptions ,
25
- runtimeData : getRuntimeData ( filePath ) ,
26
- } ;
27
-
28
23
const { results, decoratorImportSpecs } = _maybeTransformEmberObjects (
29
24
root ,
30
25
filePath ,
31
- options
26
+ userOptions
32
27
) ;
33
28
34
29
for ( const result of results ) {
@@ -44,15 +39,15 @@ export default function maybeTransformEmberObjects(
44
39
const decoratorsToImport = Object . keys ( decoratorImportSpecs ) . filter (
45
40
( key ) => decoratorImportSpecs [ key as keyof DecoratorImportSpecs ]
46
41
) ;
47
- createDecoratorImportDeclarations ( root , decoratorsToImport , options ) ;
42
+ createDecoratorImportDeclarations ( root , decoratorsToImport , userOptions ) ;
48
43
49
44
return results . length > 0 && results . every ( ( r ) => r . success ) ;
50
45
}
51
46
52
47
function _maybeTransformEmberObjects (
53
48
root : AST . Collection ,
54
49
filePath : string ,
55
- options : Options
50
+ userOptions : UserOptions
56
51
) : {
57
52
results : TransformResult [ ] ;
58
53
decoratorImportSpecs : DecoratorImportSpecs ;
@@ -79,27 +74,32 @@ function _maybeTransformEmberObjects(
79
74
filePath,
80
75
info : "UNMODIFIED: Did not find any 'EmberObject.extend()' expressions" ,
81
76
} ) ;
82
- }
77
+ } else {
78
+ const options : Options = {
79
+ ...userOptions ,
80
+ runtimeData : getRuntimeData ( filePath ) ,
81
+ } ;
83
82
84
- // eslint-disable-next-line unicorn/no-array-for-each
85
- eoExtendExpressionPaths . forEach ( ( eoExtendExpressionPath ) => {
86
- const extendExpression = new EOExtendExpression (
87
- eoExtendExpressionPath ,
88
- filePath ,
89
- existingDecoratorImportInfos ,
90
- options
91
- ) ;
83
+ // eslint-disable-next-line unicorn/no-array-for-each
84
+ eoExtendExpressionPaths . forEach ( ( eoExtendExpressionPath ) => {
85
+ const extendExpression = new EOExtendExpression (
86
+ eoExtendExpressionPath ,
87
+ filePath ,
88
+ existingDecoratorImportInfos ,
89
+ options
90
+ ) ;
92
91
93
- const result = extendExpression . transform ( ) ;
94
- results . push ( result ) ;
92
+ const result = extendExpression . transform ( ) ;
93
+ results . push ( result ) ;
95
94
96
- if ( result . success ) {
97
- decoratorImportSpecs = mergeDecoratorImportSpecs (
98
- extendExpression . decoratorImportSpecs ,
99
- decoratorImportSpecs
100
- ) ;
101
- }
102
- } ) ;
95
+ if ( result . success ) {
96
+ decoratorImportSpecs = mergeDecoratorImportSpecs (
97
+ extendExpression . decoratorImportSpecs ,
98
+ decoratorImportSpecs
99
+ ) ;
100
+ }
101
+ } ) ;
102
+ }
103
103
104
104
return { results, decoratorImportSpecs } ;
105
105
}
0 commit comments