11'use strict' ;
22
33import path from 'path' ;
4- import ScriptBase from '../script-base ' ;
5- import * as genUtils from '../util ' ;
4+ import { NamedBase } from 'yeoman-generator ' ;
5+ import { genNamedBase } from '../generator-base ' ;
66
7- export default class Generator extends ScriptBase {
7+ export default class Generator extends NamedBase {
88
99 constructor ( ...args ) {
1010 super ( ...args ) ;
@@ -25,6 +25,11 @@ export default class Generator extends ScriptBase {
2525 } ) ;
2626 }
2727
28+ initializing ( ) {
29+ // init shared generator properies and methods
30+ genNamedBase ( this ) ;
31+ }
32+
2833 prompting ( ) {
2934 var done = this . async ( ) ;
3035 var promptCb = function ( props ) {
@@ -103,7 +108,7 @@ export default class Generator extends ScriptBase {
103108
104109 writing ( ) {
105110 this . sourceRoot ( path . join ( __dirname , './templates' ) ) ;
106- genUtils . processDirectory ( this , '.' , this . routeDest ) ;
111+ this . processDirectory ( '.' , this . routeDest ) ;
107112 }
108113
109114 end ( ) {
@@ -117,7 +122,7 @@ export default class Generator extends ScriptBase {
117122 "app.use(\'" + this . route + "\', require(\'" + reqPath + "\'));"
118123 ]
119124 } ;
120- genUtils . rewriteFile ( routeConfig ) ;
125+ this . rewriteFile ( routeConfig ) ;
121126 }
122127
123128 if ( this . filters . socketio && this . config . get ( 'insertSockets' ) ) {
@@ -131,7 +136,7 @@ export default class Generator extends ScriptBase {
131136 "require(\'" + reqPath + "\').register(socket);"
132137 ]
133138 } ;
134- genUtils . rewriteFile ( socketConfig ) ;
139+ this . rewriteFile ( socketConfig ) ;
135140 }
136141
137142 if ( this . filters . sequelize && this . config . get ( 'insertModels' ) ) {
@@ -145,7 +150,7 @@ export default class Generator extends ScriptBase {
145150 "db." + this . classedName + " = db.sequelize.import(\'" + reqPath + "\');"
146151 ]
147152 } ;
148- genUtils . rewriteFile ( modelConfig ) ;
153+ this . rewriteFile ( modelConfig ) ;
149154 }
150155 }
151156}
0 commit comments