@@ -21,38 +21,38 @@ import {
21
21
} from '@angular-devkit/schematics' ;
22
22
import * as stringUtils from '../strings' ;
23
23
24
- import * as ts from 'typescript' ;
24
+ // import * as ts from 'typescript';
25
25
import 'rxjs/add/operator/merge' ;
26
- import { findModule , buildRelativePath } from '../utility/find-module' ;
27
- import { addProviderToModule } from '../utility/ast-utils' ;
28
- import { InsertChange } from '../utility/change' ;
26
+ // import {findModule, buildRelativePath} from '../utility/find-module';
27
+ // import {addProviderToModule} from '../utility/ast-utils';
28
+ // import {InsertChange} from '../utility/change';
29
29
30
30
function addProviderToNgModule ( options : any ) : Rule {
31
31
return ( host : Tree ) => {
32
- if ( options . skipProvide ) {
32
+ if ( ! options . module ) {
33
33
return host ;
34
34
}
35
35
36
- const modulePath = findModule ( host , options . sourceDir + '/' + options . path ) ;
37
-
38
- const sourceText = host . read ( modulePath ) ! . toString ( 'utf-8' ) ;
39
- const source = ts . createSourceFile ( modulePath , sourceText , ts . ScriptTarget . Latest , true ) ;
40
-
41
- const servicePath = `/${ options . sourceDir } /${ options . path } /`
42
- + ( options . flat ? '' : stringUtils . dasherize ( options . name ) + '/' )
43
- + stringUtils . dasherize ( options . name )
44
- + '.service' ;
45
- const relativePath = buildRelativePath ( modulePath , servicePath ) ;
46
- const changes = addProviderToModule ( source , modulePath ,
47
- stringUtils . classify ( `${ options . name } Service` ) ,
48
- relativePath ) ;
49
- const recorder = host . beginUpdate ( modulePath ) ;
50
- for ( const change of changes ) {
51
- if ( change instanceof InsertChange ) {
52
- recorder . insertLeft ( change . pos , change . toAdd ) ;
53
- }
54
- }
55
- host . commitUpdate ( recorder ) ;
36
+ // TODO: Add option support for module path
37
+ // let modulePath = '';
38
+ // const sourceText = host.read(modulePath) !.toString('utf-8');
39
+ // const source = ts.createSourceFile(modulePath, sourceText, ts.ScriptTarget.Latest, true);
40
+ //
41
+ // const servicePath = `/${options.sourceDir}/${options.path}/`
42
+ // + (options.flat ? '' : stringUtils.dasherize(options.name) + '/')
43
+ // + stringUtils.dasherize(options.name)
44
+ // + '.service';
45
+ // const relativePath = buildRelativePath(modulePath, servicePath);
46
+ // const changes = addProviderToModule(source, modulePath,
47
+ // stringUtils.classify(`${options.name}Service`),
48
+ // relativePath);
49
+ // const recorder = host.beginUpdate(modulePath);
50
+ // for (const change of changes) {
51
+ // if (change instanceof InsertChange) {
52
+ // recorder.insertLeft(change.pos, change.toAdd);
53
+ // }
54
+ // }
55
+ // host.commitUpdate(recorder);
56
56
57
57
return host ;
58
58
} ;
0 commit comments