@@ -79,7 +79,7 @@ export function addReducerToState(options: any): Rule {
7979export function addReducerToStateInterface (
8080 source : ts . SourceFile ,
8181 reducersPath : string ,
82- options : { name : string }
82+ options : { name : string ; plural : boolean }
8383) : Change {
8484 const stateInterface = source . statements . find (
8585 stm => stm . kind === ts . SyntaxKind . InterfaceDeclaration
@@ -90,11 +90,12 @@ export function addReducerToStateInterface(
9090 return new NoopChange ( ) ;
9191 }
9292
93+ const state = options . plural
94+ ? stringUtils . pluralize ( options . name )
95+ : stringUtils . camelize ( options . name ) ;
96+
9397 const keyInsert =
94- stringUtils . camelize ( options . name ) +
95- ': from' +
96- stringUtils . classify ( options . name ) +
97- '.State;' ;
98+ state + ': from' + stringUtils . classify ( options . name ) + '.State;' ;
9899 const expr = node as any ;
99100 let position ;
100101 let toInsert ;
@@ -125,7 +126,7 @@ export function addReducerToStateInterface(
125126export function addReducerToActionReducerMap (
126127 source : ts . SourceFile ,
127128 reducersPath : string ,
128- options : { name : string }
129+ options : { name : string ; plural : boolean }
129130) : Change {
130131 let initializer : any ;
131132 const actionReducerMap : any = source . statements
@@ -152,11 +153,12 @@ export function addReducerToActionReducerMap(
152153
153154 let node = actionReducerMap . initializer ;
154155
156+ const state = options . plural
157+ ? stringUtils . pluralize ( options . name )
158+ : stringUtils . camelize ( options . name ) ;
159+
155160 const keyInsert =
156- stringUtils . camelize ( options . name ) +
157- ': from' +
158- stringUtils . classify ( options . name ) +
159- '.reducer,' ;
161+ state + ': from' + stringUtils . classify ( options . name ) + '.reducer,' ;
160162 const expr = node as any ;
161163 let position ;
162164 let toInsert ;
0 commit comments