@@ -4,71 +4,64 @@ var ScriptBase = require('../script-base.js');
44var fs = require ( 'fs' ) ;
55
66var Generator = module . exports = function Generator ( args , options ) {
7- ScriptBase . apply ( this , arguments ) ;
8- this . fileName = this . name ;
7+ ScriptBase . apply ( this , arguments ) ;
8+ this . fileName = this . name ;
99} ;
1010
1111util . inherits ( Generator , ScriptBase ) ;
1212
1313Generator . prototype . askForOverwrite = function askForOverwrite ( ) {
14- var cb = this . async ( ) ;
14+ var cb = this . async ( ) ;
1515
16- // TODO: Any yeoman.util function to handle this?
17- var fileExists = fs . existsSync ( this . env . cwd + '/app/scripts/' + buildRelativePath ( this . fileName ) + ".js" ) ;
18- if ( fileExists ) {
19- var prompts = [ {
20- name : 'overwriteDecorator ' ,
21- message : 'Would you like to overwrite existing decorator? ' ,
22- default : 'Y/n ',
23- warning : 'Yes: Decorator will be replaced.'
24- } ] ;
16+ // TODO: Any yeoman.util function to handle this?
17+ var fileExists = fs . existsSync ( this . env . cwd + '/app/scripts/' + buildRelativePath ( this . fileName ) + ".js" ) ;
18+ if ( fileExists ) {
19+ var prompts = [ {
20+ type : 'confirm ' ,
21+ name : 'overwriteDecorator ' ,
22+ message : 'Would you like to overwrite existing decorator? ',
23+ default : false
24+ } ] ;
2525
26- this . prompt ( prompts , function ( err , props ) {
27- if ( err ) {
28- return this . emit ( 'error' , err ) ;
29- }
26+ this . prompt ( prompts , function ( props ) {
27+ this . overwriteDecorator = props . overwriteDecorator ;
3028
31- this . overwriteDecorator = ( / y / i) . test ( props . overwriteDecorator ) ;
32-
33- cb ( ) ;
34- } . bind ( this ) ) ;
35- }
36- else {
37- cb ( ) ;
38- return ;
39- }
29+ cb ( ) ;
30+ } . bind ( this ) ) ;
31+ }
32+ else {
33+ cb ( ) ;
34+ return ;
35+ }
4036} ;
4137
4238Generator . prototype . askForNewName = function askForNewName ( ) {
43- var cb = this . async ( ) ;
39+ var cb = this . async ( ) ;
4440
45- if ( this . overwriteDecorator === undefined || this . overwriteDecorator === true ) {
46- cb ( ) ;
47- return ;
48- }
49- else {
50- var prompts = [ ] ;
51- prompts . push ( {
52- name : 'decortatorName ' ,
53- message : 'Alternative name for the decorator: '
54- } ) ;
41+ if ( this . overwriteDecorator === undefined || this . overwriteDecorator === true ) {
42+ cb ( ) ;
43+ return ;
44+ }
45+ else {
46+ var prompts = [ ] ;
47+ prompts . push ( {
48+ name : 'decoratorName ' ,
49+ message : 'Alternative name for the decorator'
50+ } ) ;
5551
56- this . prompt ( prompts , function ( err , props ) {
57- if ( err ) {
58- return this . emit ( 'error' , err ) ;
59- }
60- this . fileName = props . decortatorName ;
52+ this . prompt ( prompts , function ( props ) {
53+ this . fileName = props . decoratorName ;
6154
62- cb ( ) ;
63- } . bind ( this ) ) ;
64- }
55+ cb ( ) ;
56+ } . bind ( this ) ) ;
57+ }
6558} ;
6659
6760Generator . prototype . createDecoratorFiles = function createDecoratorFiles ( ) {
68- this . appTemplate ( 'decorator' , 'scripts/' + buildRelativePath ( this . fileName ) ) ;
69- this . addScriptToIndex ( buildRelativePath ( this . fileName ) ) ;
61+ this . appTemplate ( 'decorator' , 'scripts/' + buildRelativePath ( this . fileName ) ) ;
62+ this . addScriptToIndex ( buildRelativePath ( this . fileName ) ) ;
7063} ;
7164
7265function buildRelativePath ( fileName ) {
73- return 'decorators/' + fileName + "Decorator" ;
74- }
66+ return 'decorators/' + fileName + "Decorator" ;
67+ }
0 commit comments