Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Commit 18c4241

Browse files
committed
chore(generators): write the correct path
1 parent e0e65db commit 18c4241

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/generators.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { BuildContext } from './util/interfaces';
55
import { readFileAsync, writeFileAsync } from './util/helpers';
66
import { getTypescriptSourceFile, appendNgModuleDeclaration, insertNamedImportIfNeeded } from './util/typescript-utils';
77
import { applyTemplates, filterOutTemplates, getNgModules, GeneratorOption, GeneratorRequest, hydrateRequest, readTemplates, writeGeneratedFiles } from './generators/util';
8+
import * as path from 'path';
89

910
export { getNgModules, GeneratorOption, GeneratorRequest };
1011

@@ -19,10 +20,12 @@ export function processPageRequest(context: BuildContext, name: string) {
1920

2021
export function processPipeRequest(context: BuildContext, name: string, ngModulePath: string) {
2122
const hydratedRequest = hydrateRequest(context, { type: 'pipe', name });
22-
23+
console.log(hydratedRequest);
24+
console.log(ngModulePath);
2325
return readFileAsync(ngModulePath).then((fileContent: string) => {
24-
fileContent = insertNamedImportIfNeeded(ngModulePath, fileContent, name, `./${name}`);
25-
fileContent = appendNgModuleDeclaration(ngModulePath, fileContent, name);
26+
fileContent = insertNamedImportIfNeeded(ngModulePath, fileContent, hydratedRequest.className, path.relative(path.dirname(ngModulePath), hydratedRequest.dirToWrite));
27+
fileContent = appendNgModuleDeclaration(ngModulePath, fileContent, hydratedRequest.className);
28+
console.log(fileContent);
2629
return writeFileAsync(ngModulePath, fileContent);
2730
}).then(() => {
2831
return processNonTabRequest(context, hydratedRequest);

0 commit comments

Comments
 (0)