1
- import { basename , dirname , join , relative } from 'path' ;
1
+ import { basename , dirname , join , relative , sep } from 'path' ;
2
2
import { readdirSync } from 'fs' ;
3
3
import { Logger } from '../logger/logger' ;
4
+ import { toUnixPath } from '../util/helpers' ;
4
5
5
6
import * as Constants from '../util/constants' ;
6
7
import * as GeneratorConstants from './constants' ;
@@ -157,7 +158,9 @@ export function nonPageFileManipulation(context: BuildContext, name: string, ngM
157
158
fileContent = content ;
158
159
return generateTemplates ( context , hydratedRequest ) ;
159
160
} ) . 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 ) ;
161
164
if ( type === 'provider' ) {
162
165
fileContent = appendNgModuleDeclaration ( ngModulePath , fileContent , hydratedRequest . className , type ) ;
163
166
} else {
@@ -171,11 +174,12 @@ export function tabsModuleManipulation(tabs: string[][], hydratedRequest: Hydrat
171
174
const ngModulePath = tabs [ 0 ] . find ( ( element : any ) : boolean => {
172
175
return element . indexOf ( 'module' ) !== - 1 ;
173
176
} ) ;
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' , '' ) ) ) ;
175
179
176
180
return readFileAsync ( tabsNgModulePath ) . then ( ( content ) => {
177
181
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 ) ;
179
183
fileContent = appendNgModuleDeclaration ( tabsNgModulePath , fileContent , tabHydratedRequests [ 0 ] . className ) ;
180
184
181
185
return writeFileAsync ( tabsNgModulePath , fileContent ) ;
0 commit comments