|
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,
|
@@ -91,9 +91,8 @@ function getComponentTemplate(host: Tree, compPath: string, tmplInfo: TemplateIn
|
91 | 91 | template = tmplInfo.templateProp.getFullText();
|
92 | 92 | } else if (tmplInfo.templateUrlProp) {
|
93 | 93 | const templateUrl = (tmplInfo.templateUrlProp.initializer as ts.StringLiteral).text;
|
94 |
| - const dirEntry = host.getDir(compPath); |
95 |
| - const dir = dirEntry.parent ? dirEntry.parent.path : '/'; |
96 |
| - const templatePath = normalize(`/${dir}/${templateUrl}`); |
| 94 | + const dir = dirname(normalize(compPath)); |
| 95 | + const templatePath = join(dir, templateUrl); |
97 | 96 | const buffer = host.read(templatePath);
|
98 | 97 | if (buffer) {
|
99 | 98 | template = buffer.toString();
|
@@ -130,11 +129,7 @@ function getBootstrapComponentPath(host: Tree, project: WorkspaceProject): strin
|
130 | 129 | return pathStringLiteral.text;
|
131 | 130 | })[0];
|
132 | 131 |
|
133 |
| - const dirEntry = host.getDir(modulePath); |
134 |
| - const dir = dirEntry.parent ? dirEntry.parent.path : '/'; |
135 |
| - const compPath = normalize(`/${dir}/${relativePath}.ts`); |
136 |
| - |
137 |
| - return compPath; |
| 132 | + return join(dirname(normalize(modulePath)), relativePath + '.ts'); |
138 | 133 | }
|
139 | 134 | // end helper functions.
|
140 | 135 |
|
@@ -313,16 +308,13 @@ function addServerRoutes(options: AppShellOptions): Rule {
|
313 | 308 | }
|
314 | 309 |
|
315 | 310 | function addShellComponent(options: AppShellOptions): Rule {
|
316 |
| - return (host: Tree, context: SchematicContext) => { |
317 |
| - |
318 |
| - const componentOptions: ComponentOptions = { |
319 |
| - name: 'app-shell', |
320 |
| - module: options.rootModuleFileName, |
321 |
| - project: options.clientProject, |
322 |
| - }; |
323 |
| - |
324 |
| - return schematic('component', componentOptions)(host, context); |
| 311 | + const componentOptions: ComponentOptions = { |
| 312 | + name: 'app-shell', |
| 313 | + module: options.rootModuleFileName, |
| 314 | + project: options.clientProject, |
325 | 315 | };
|
| 316 | + |
| 317 | + return schematic('component', componentOptions); |
326 | 318 | }
|
327 | 319 |
|
328 | 320 | function getClientProject(host: Tree, options: AppShellOptions): WorkspaceProject {
|
|
0 commit comments