@@ -55,23 +55,19 @@ function addImportToNgModule(options: RootStoreOptions): Rule {
55
55
true
56
56
) ;
57
57
58
- const statePath = `${ options . path } /${ options . statePath } ` ;
58
+ const statePath = `/ ${ options . path } /${ options . statePath } ` ;
59
59
const relativePath = buildRelativePath ( modulePath , statePath ) ;
60
- const srcPath = dirname ( options . path as Path ) ;
61
- const environmentsPath = buildRelativePath (
62
- statePath ,
63
- `/${ srcPath } /environments/environment`
60
+ const [ storeNgModuleImport ] = addImportToModule (
61
+ source ,
62
+ modulePath ,
63
+ 'StoreModule.forRoot(reducers, { metaReducers })' ,
64
+ relativePath
64
65
) ;
65
66
66
67
const changes = [
67
68
insertImport ( source , modulePath , 'StoreModule' , '@ngrx/store' ) ,
68
69
insertImport ( source , modulePath , 'reducers, metaReducers' , relativePath ) ,
69
- addImportToModule (
70
- source ,
71
- modulePath ,
72
- 'StoreModule.forRoot(reducers, { metaReducers })' ,
73
- relativePath
74
- ) ,
70
+ storeNgModuleImport ,
75
71
] ;
76
72
const recorder = host . beginUpdate ( modulePath ) ;
77
73
@@ -103,8 +99,7 @@ export default function(options: RootStoreOptions): Rule {
103
99
return ( host : Tree , context : SchematicContext ) => {
104
100
options . path = getProjectPath ( host , options ) ;
105
101
106
- const parsedPath = parseName ( options . path , options . name ) ;
107
- options . name = parsedPath . name ;
102
+ const parsedPath = parseName ( options . path , '' ) ;
108
103
options . path = parsedPath . path ;
109
104
110
105
const statePath = `/${ options . path } /${ options . statePath } /index.ts` ;
@@ -115,7 +110,11 @@ export default function(options: RootStoreOptions): Rule {
115
110
) ;
116
111
117
112
if ( options . module ) {
118
- options . module = findModuleFromOptions ( host , options ) ;
113
+ options . module = findModuleFromOptions ( host , {
114
+ name : '' ,
115
+ module : options . module ,
116
+ path : options . path ,
117
+ } ) ;
119
118
}
120
119
121
120
if ( options . stateInterface && options . stateInterface !== 'State' ) {
@@ -132,7 +131,6 @@ export default function(options: RootStoreOptions): Rule {
132
131
] ) ;
133
132
134
133
return chain ( [
135
- options && options . skipPackageJson ? noop ( ) : addNgRxStoreToPackageJson ( ) ,
136
134
branchAndMerge (
137
135
chain ( [
138
136
filter (
@@ -144,6 +142,7 @@ export default function(options: RootStoreOptions): Rule {
144
142
mergeWith ( templateSource ) ,
145
143
] )
146
144
) ,
145
+ options && options . skipPackageJson ? noop ( ) : addNgRxStoreToPackageJson ( ) ,
147
146
] ) ( host , context ) ;
148
147
} ;
149
148
}
0 commit comments