1
1
import {
2
- chain , Rule ,
3
- Tree , SchematicsException
2
+ chain ,
3
+ Rule ,
4
+ Tree ,
5
+ SchematicsException ,
4
6
} from '@angular-devkit/schematics' ;
5
7
import * as ts from 'typescript' ;
6
8
import { addImportToModule , insertImport } from '../utils/ast-utils' ;
7
- import { commitChanges } from '../utils/change' ;
9
+ import { commitChanges , Change } from '../utils/change' ;
8
10
import { RouterOptions } from './schema' ;
9
11
import { findModuleFromOptions } from '../utils/find-module' ;
10
12
import { getProjectPath } from '../utils/project' ;
@@ -22,7 +24,6 @@ function addImportToNgModule(options: RouterOptions): Rule {
22
24
throw new Error ( 'Specified module does not exist' ) ;
23
25
}
24
26
25
-
26
27
const text = host . read ( modulePath ) ;
27
28
if ( text === null ) {
28
29
throw new SchematicsException ( `File ${ modulePath } does not exist.` ) ;
@@ -40,28 +41,21 @@ function addImportToNgModule(options: RouterOptions): Rule {
40
41
source ,
41
42
modulePath ,
42
43
'RoutingModule.forRoot()' ,
43
- 'angular-routing' ,
44
+ 'angular-routing'
44
45
) . shift ( ) ;
45
46
46
-
47
47
let changes = [
48
48
insertImport ( source , modulePath , 'RoutingModule' , 'angular-routing' ) ,
49
- importChanges
49
+ importChanges ,
50
50
] ;
51
51
52
- commitChanges ( host , source . fileName , changes ) ;
52
+ commitChanges ( host , source . fileName , changes as Change [ ] ) ;
53
53
54
54
return host ;
55
55
} ;
56
56
}
57
57
58
58
// Just return the tree
59
59
export default function ( options : RouterOptions ) : Rule {
60
-
61
- return chain ( [
62
- addImportToNgModule ( options )
63
- ] ) ;
60
+ return chain ( [ addImportToNgModule ( options ) ] ) ;
64
61
}
65
-
66
-
67
-
0 commit comments