@@ -79,7 +79,7 @@ export function addReducerToState(options: any): Rule {
79
79
export function addReducerToStateInterface (
80
80
source : ts . SourceFile ,
81
81
reducersPath : string ,
82
- options : { name : string }
82
+ options : { name : string ; plural : boolean }
83
83
) : Change {
84
84
const stateInterface = source . statements . find (
85
85
stm => stm . kind === ts . SyntaxKind . InterfaceDeclaration
@@ -90,11 +90,12 @@ export function addReducerToStateInterface(
90
90
return new NoopChange ( ) ;
91
91
}
92
92
93
+ const state = options . plural
94
+ ? stringUtils . pluralize ( options . name )
95
+ : stringUtils . camelize ( options . name ) ;
96
+
93
97
const keyInsert =
94
- stringUtils . camelize ( options . name ) +
95
- ': from' +
96
- stringUtils . classify ( options . name ) +
97
- '.State;' ;
98
+ state + ': from' + stringUtils . classify ( options . name ) + '.State;' ;
98
99
const expr = node as any ;
99
100
let position ;
100
101
let toInsert ;
@@ -125,7 +126,7 @@ export function addReducerToStateInterface(
125
126
export function addReducerToActionReducerMap (
126
127
source : ts . SourceFile ,
127
128
reducersPath : string ,
128
- options : { name : string }
129
+ options : { name : string ; plural : boolean }
129
130
) : Change {
130
131
let initializer : any ;
131
132
const actionReducerMap : any = source . statements
@@ -152,11 +153,12 @@ export function addReducerToActionReducerMap(
152
153
153
154
let node = actionReducerMap . initializer ;
154
155
156
+ const state = options . plural
157
+ ? stringUtils . pluralize ( options . name )
158
+ : stringUtils . camelize ( options . name ) ;
159
+
155
160
const keyInsert =
156
- stringUtils . camelize ( options . name ) +
157
- ': from' +
158
- stringUtils . classify ( options . name ) +
159
- '.reducer,' ;
161
+ state + ': from' + stringUtils . classify ( options . name ) + '.reducer,' ;
160
162
const expr = node as any ;
161
163
let position ;
162
164
let toInsert ;
0 commit comments