@@ -42,6 +42,12 @@ module.exports = generators.Base.extend({
42
42
choices : [ 'Input' /*, 'Radio', 'Checkbox', 'Array'*/ , 'Empty' ] ,
43
43
default : 'Input'
44
44
} ,
45
+ {
46
+ type : 'confirm' ,
47
+ name : 'useDirective' ,
48
+ message : 'Do you want a directive added to your addon?' ,
49
+ default : true
50
+ } ,
45
51
{
46
52
type : 'input' ,
47
53
name : 'username' ,
@@ -53,12 +59,13 @@ module.exports = generators.Base.extend({
53
59
*/
54
60
this . addon . name = answers . name ;
55
61
this . addon . type = answers . type ;
62
+ this . addon . useDirective = answers . useDirective ;
56
63
this . addon . username = answers . username ;
57
64
58
65
/* Changing cases
59
66
*/
60
67
this . addon . type = this . addon . type . toLowerCase ( ) ; // ex. Input > input
61
- this . addon . directive = camelcase ( this . addon . name ) ; // ex. add on > addOn
68
+ this . addon . module = camelcase ( this . addon . name ) ; // ex. add on > addOn
62
69
this . addon . typeName = this . addon . name . replace ( / / g, '' ) ; // ex. add on > addon
63
70
this . addon . paramName = this . addon . name . replace ( / / g, '-' ) ; // ex. add on > add-on
64
71
@@ -99,11 +106,12 @@ module.exports = generators.Base.extend({
99
106
/* What to inject in the test controller
100
107
*/
101
108
var testModule = [ 'schemaForm' ] ;
102
- var dest = file . replace ( '_' , '.' )
103
- . replace ( 'module.js ' , this . addon . paramName + '.js ') ;
109
+ var sources = [ ] ;
110
+ var dest = file . replace ( '_ ' , '. ') ;
104
111
105
112
if ( this . addon . type !== 'empty' ) {
106
- testModule . push ( this . addon . directive ) ;
113
+ testModule . push ( this . addon . module ) ;
114
+ sources . push ( 'src/module.js' ) ;
107
115
}
108
116
109
117
/* Base files */
@@ -112,29 +120,29 @@ module.exports = generators.Base.extend({
112
120
this . destinationPath ( './' ) + dest ,
113
121
{
114
122
name : this . addon . name ,
115
- directive : this . addon . directive ,
123
+ module : this . addon . module ,
116
124
testModuleInj : JSON . stringify ( testModule ) ,
117
125
typeName : this . addon . typeName ,
118
126
paramName : this . addon . paramName ,
119
127
schema : schema ,
120
128
form : JSON . stringify ( form ) ,
121
- username : this . addon . username
129
+ username : this . addon . username ,
130
+ sources : JSON . stringify ( sources )
122
131
}
123
132
) ;
124
133
} . bind ( this ) ) ;
125
134
126
135
/* Type files */
127
136
this . addon . files [ this . addon . type ] . forEach ( function ( file ) {
128
137
var dest = file . replace ( '_' , '.' )
129
- . replace ( 'template.html' , this . addon . paramName + '.html' )
130
- . replace ( 'module.js' , this . addon . paramName + '.js' ) ;
138
+ . replace ( 'template.html' , this . addon . paramName + '.html' ) ;
131
139
132
140
this . fs . copyTpl (
133
141
this . templatePath ( this . templatePath ( this . addon . type + '/src/' ) + file ) ,
134
142
this . destinationPath ( './src/' ) + dest ,
135
143
{
136
144
name : this . addon . name ,
137
- directive : this . addon . directive ,
145
+ module : this . addon . module ,
138
146
typeName : this . addon . typeName ,
139
147
paramName : this . addon . paramName
140
148
}
0 commit comments