|
5 | 5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 |
| -import { JsonObject, normalize } from '@angular-devkit/core'; |
| 8 | +import { JsonObject, dirname, join, normalize } from '@angular-devkit/core'; |
9 | 9 | import {
|
10 | 10 | Rule,
|
11 | 11 | SchematicContext,
|
@@ -92,9 +92,8 @@ function getComponentTemplate(host: Tree, compPath: string, tmplInfo: TemplateIn
|
92 | 92 | template = tmplInfo.templateProp.getFullText();
|
93 | 93 | } else if (tmplInfo.templateUrlProp) {
|
94 | 94 | const templateUrl = (tmplInfo.templateUrlProp.initializer as ts.StringLiteral).text;
|
95 |
| - const dirEntry = host.getDir(compPath); |
96 |
| - const dir = dirEntry.parent ? dirEntry.parent.path : '/'; |
97 |
| - const templatePath = normalize(`/${dir}/${templateUrl}`); |
| 95 | + const dir = dirname(normalize(compPath)); |
| 96 | + const templatePath = join(dir, templateUrl); |
98 | 97 | const buffer = host.read(templatePath);
|
99 | 98 | if (buffer) {
|
100 | 99 | template = buffer.toString();
|
@@ -131,11 +130,7 @@ function getBootstrapComponentPath(host: Tree, project: WorkspaceProject): strin
|
131 | 130 | return pathStringLiteral.text;
|
132 | 131 | })[0];
|
133 | 132 |
|
134 |
| - const dirEntry = host.getDir(modulePath); |
135 |
| - const dir = dirEntry.parent ? dirEntry.parent.path : '/'; |
136 |
| - const compPath = normalize(`/${dir}/${relativePath}.ts`); |
137 |
| - |
138 |
| - return compPath; |
| 133 | + return join(dirname(normalize(modulePath)), relativePath + '.ts'); |
139 | 134 | }
|
140 | 135 | // end helper functions.
|
141 | 136 |
|
@@ -310,16 +305,13 @@ function addServerRoutes(options: AppShellOptions): Rule {
|
310 | 305 | }
|
311 | 306 |
|
312 | 307 | function addShellComponent(options: AppShellOptions): Rule {
|
313 |
| - return (host: Tree, context: SchematicContext) => { |
314 |
| - |
315 |
| - const componentOptions: ComponentOptions = { |
316 |
| - name: 'app-shell', |
317 |
| - module: options.rootModuleFileName, |
318 |
| - project: options.clientProject, |
319 |
| - }; |
320 |
| - |
321 |
| - return schematic('component', componentOptions)(host, context); |
| 308 | + const componentOptions: ComponentOptions = { |
| 309 | + name: 'app-shell', |
| 310 | + module: options.rootModuleFileName, |
| 311 | + project: options.clientProject, |
322 | 312 | };
|
| 313 | + |
| 314 | + return schematic('component', componentOptions); |
323 | 315 | }
|
324 | 316 |
|
325 | 317 | function getClientProject(host: Tree, options: AppShellOptions): WorkspaceProject {
|
|
0 commit comments