(options: ModuleOptions)
| 51 | } |
| 52 | |
| 53 | function addImportToNgModule(options: ModuleOptions): Rule { |
| 54 | return (host: Tree) => { |
| 55 | if (!options.module) { |
| 56 | return host; |
| 57 | } |
| 58 | |
| 59 | const modulePath = options.module; |
| 60 | |
| 61 | const sourceText = host.readText(modulePath); |
| 62 | const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true); |
| 63 | |
| 64 | const relativePath = buildRelativeModulePath(options, modulePath); |
| 65 | const changes = addImportToModule( |
| 66 | source, |
| 67 | modulePath, |
| 68 | strings.classify(`${options.name}Module`), |
| 69 | relativePath, |
| 70 | ); |
| 71 | |
| 72 | const recorder = host.beginUpdate(modulePath); |
| 73 | for (const change of changes) { |
| 74 | if (change instanceof InsertChange) { |
| 75 | recorder.insertLeft(change.pos, change.toAdd); |
| 76 | } |
| 77 | } |
| 78 | host.commitUpdate(recorder); |
| 79 | |
| 80 | return host; |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | function addRouteDeclarationToNgModule( |
| 85 | options: ModuleOptions, |
no test coverage detected