@@ -28,9 +28,9 @@ import { InsertChange } from '../utility/change';
28
28
import { Schema as ApplicationOptions } from './schema' ;
29
29
30
30
31
- function addBootstrapToNgModule ( directory : string ) : Rule {
31
+ function addBootstrapToNgModule ( directory : string , sourceDir : string ) : Rule {
32
32
return ( host : Tree ) => {
33
- const modulePath = `${ directory } /src /app/app.module.ts` ;
33
+ const modulePath = `${ directory } /${ sourceDir } /app/app.module.ts` ;
34
34
const content = host . read ( modulePath ) ;
35
35
if ( ! content ) {
36
36
throw new SchematicsError ( `File ${ modulePath } does not exist.` ) ;
@@ -88,6 +88,7 @@ export default function (options: ApplicationOptions): Rule {
88
88
spec : false ,
89
89
styleext : options . style ,
90
90
} ;
91
+ const sourceDir = options . sourceDir || 'src' ;
91
92
92
93
return chain ( [
93
94
mergeWith (
@@ -106,17 +107,17 @@ export default function (options: ApplicationOptions): Rule {
106
107
flat : true ,
107
108
routing : options . routing ,
108
109
routingScope : 'Root' ,
109
- sourceDir : options . directory + '/' + options . sourceDir ,
110
+ sourceDir : options . directory + '/' + sourceDir ,
110
111
spec : false ,
111
112
} ) ,
112
113
schematic ( 'component' , {
113
114
name : 'app' ,
114
115
selector : appRootSelector ,
115
- sourceDir : options . directory + '/' + options . sourceDir ,
116
+ sourceDir : options . directory + '/' + sourceDir ,
116
117
flat : true ,
117
118
...componentOptions ,
118
119
} ) ,
119
- addBootstrapToNgModule ( options . directory ) ,
120
+ addBootstrapToNgModule ( options . directory , sourceDir ) ,
120
121
mergeWith (
121
122
apply ( url ( './other-files' ) , [
122
123
componentOptions . inlineTemplate ? filter ( path => ! path . endsWith ( '.html' ) ) : noop ( ) ,
@@ -127,7 +128,7 @@ export default function (options: ApplicationOptions): Rule {
127
128
selector : appRootSelector ,
128
129
...componentOptions ,
129
130
} ) ,
130
- move ( options . directory + '/' + options . sourceDir + '/app' ) ,
131
+ move ( options . directory + '/' + sourceDir + '/app' ) ,
131
132
] ) , MergeStrategy . Overwrite ) ,
132
133
] ) ( host , context ) ;
133
134
} ;
0 commit comments