@@ -6,6 +6,7 @@ import {Schema} from './schema';
66import { scullyVersion , scullyComponentVersion } from './version-names' ;
77import { addModuleImportToRootModule , getProjectFromWorkspace , getWorkspace } from 'schematics-utilities' ;
88import { NodePackageInstallTask , RunSchematicTask } from '@angular-devkit/schematics/tasks' ;
9+ import { getSrc } from '../utils/utils' ;
910
1011export default function ( options : Schema ) : Rule {
1112 return ( host : Tree , context : SchematicContext ) => {
@@ -24,25 +25,26 @@ export default function(options: Schema): Rule {
2425 } catch ( e ) { }
2526
2627 // add new polyfills
28+ const srcFolder = getSrc ( host ) ;
2729 // @ts -ignore
28- let polyfills = host . read ( './src/ polyfills.ts' ) . toString ( ) ;
30+ let polyfills = host . read ( ` ${ srcFolder } / polyfills.ts` ) . toString ( ) ;
2931 if ( polyfills . includes ( 'SCULLY IMPORTS' ) ) {
3032 context . logger . info ( '⚠️️ Skipping polyfills.ts' ) ;
3133 } else {
3234 polyfills = `${ polyfills } \n/***************************************************************************************************
3335 \n* SCULLY IMPORTS
3436 \n*/
3537 \n// tslint:disable-next-line: align \nimport 'zone.js/dist/task-tracking';` ;
36- host . overwrite ( './src/ polyfills.ts' , polyfills ) ;
38+ host . overwrite ( ` ${ srcFolder } / polyfills.ts` , polyfills ) ;
3739 }
3840
3941 try {
4042 // inject idleService
41- const appComponent = host . read ( './src/ app/app.component.ts' ) . toString ( ) ;
43+ const appComponent = host . read ( ` ${ srcFolder } / app/app.component.ts` ) . toString ( ) ;
4244 if ( appComponent . includes ( 'IdleMonitorService' ) ) {
43- context . logger . info ( ' ⚠️️ Skipping ./src/ app/app.component.ts' ) ;
45+ context . logger . info ( ` ⚠️️ Skipping ${ srcFolder } / app/app.component.ts` ) ;
4446 } else {
45- const idleImport = " import {IdleMonitorService, TransferStateService} from '@scullyio/ng-lib';" ;
47+ const idleImport = ' import {IdleMonitorService, TransferStateService} from \ '@scullyio/ng-lib\';' ;
4648 // add
4749 const idImport = `${ idleImport } \n ${ appComponent } ` ;
4850 const idle = 'private idle: IdleMonitorService, private transferState: TransferStateService' ;
@@ -65,7 +67,7 @@ export default function(options: Schema): Rule {
6567 output = [ idImport . slice ( 0 , position ) , add , idImport . slice ( position ) ] . join ( '' ) ;
6668 }
6769 }
68- host . overwrite ( './src/ app/app.component.ts' , output ) ;
70+ host . overwrite ( ` ${ srcFolder } / app/app.component.ts` , output ) ;
6971 }
7072
7173 function haveMoreInjects ( fullComponent : string ) {
0 commit comments