1- import { basename , dirname , join , relative } from 'path' ;
1+ import { basename , dirname , join , relative , sep } from 'path' ;
22import { readdirSync } from 'fs' ;
33import { Logger } from '../logger/logger' ;
4+ import { toUnixPath } from '../util/helpers' ;
45
56import * as Constants from '../util/constants' ;
67import * as GeneratorConstants from './constants' ;
@@ -157,7 +158,9 @@ export function nonPageFileManipulation(context: BuildContext, name: string, ngM
157158 fileContent = content ;
158159 return generateTemplates ( context , hydratedRequest ) ;
159160 } ) . then ( ( ) => {
160- fileContent = insertNamedImportIfNeeded ( ngModulePath , fileContent , hydratedRequest . className , `${ relative ( dirname ( ngModulePath ) , hydratedRequest . dirToWrite ) } /${ hydratedRequest . fileName } ` ) ;
161+ const importPath = toUnixPath ( `${ relative ( dirname ( ngModulePath ) , hydratedRequest . dirToWrite ) } ${ sep } ${ hydratedRequest . fileName } ` ) ;
162+
163+ fileContent = insertNamedImportIfNeeded ( ngModulePath , fileContent , hydratedRequest . className , importPath ) ;
161164 if ( type === 'provider' ) {
162165 fileContent = appendNgModuleDeclaration ( ngModulePath , fileContent , hydratedRequest . className , type ) ;
163166 } else {
@@ -171,11 +174,12 @@ export function tabsModuleManipulation(tabs: string[][], hydratedRequest: Hydrat
171174 const ngModulePath = tabs [ 0 ] . find ( ( element : any ) : boolean => {
172175 return element . indexOf ( 'module' ) !== - 1 ;
173176 } ) ;
174- const tabsNgModulePath = `${ hydratedRequest . dirToWrite } /${ hydratedRequest . fileName } .module.ts` ;
177+ const tabsNgModulePath = `${ hydratedRequest . dirToWrite } ${ sep } ${ hydratedRequest . fileName } .module.ts` ;
178+ const importPath = toUnixPath ( relative ( dirname ( tabsNgModulePath ) , ngModulePath . replace ( '.module.ts' , '' ) ) ) ;
175179
176180 return readFileAsync ( tabsNgModulePath ) . then ( ( content ) => {
177181 let fileContent = content ;
178- fileContent = insertNamedImportIfNeeded ( tabsNgModulePath , fileContent , tabHydratedRequests [ 0 ] . className , relative ( dirname ( tabsNgModulePath ) , ngModulePath . replace ( '.module.ts' , '' ) ) ) ;
182+ fileContent = insertNamedImportIfNeeded ( tabsNgModulePath , fileContent , tabHydratedRequests [ 0 ] . className , importPath ) ;
179183 fileContent = appendNgModuleDeclaration ( tabsNgModulePath , fileContent , tabHydratedRequests [ 0 ] . className ) ;
180184
181185 return writeFileAsync ( tabsNgModulePath , fileContent ) ;
0 commit comments