@@ -7,26 +7,25 @@ var requestPromise = require('request-promise');
7
7
var fs = require ( 'fs' ) ;
8
8
var path = require ( 'path' ) ;
9
9
10
- module . exports = yeoman . Base . extend ( {
11
- prompting : function ( ) {
12
- // Have Yeoman greet the user.
13
- this . log ( yosay (
14
- 'Welcome to the ' + chalk . red ( 'Azure Functions' ) + ' generator!'
15
- ) ) ;
16
-
17
- var prompts = [ {
18
- type : 'confirm' ,
19
- name : 'requestFunctionTemplates' ,
20
- message : 'Would you like to see the available templates?' ,
21
- default : true
22
- } ] ;
23
-
24
-
25
- return this . prompt ( prompts ) . then ( answer => {
26
- // To access answer later use this.answer.(answer you need);
27
- this . answer = answer ;
28
- } ) ;
29
- } ,
10
+ module . exports = yeoman . Base . extend ( {
11
+ prompting : function ( ) {
12
+ // Have Yeoman greet the user.
13
+ this . log ( yosay (
14
+ 'Welcome to the ' + chalk . red ( 'Azure Functions' ) + ' generator!'
15
+ ) ) ;
16
+
17
+ var prompts = [ {
18
+ type : 'confirm' ,
19
+ name : 'requestFunctionTemplates' ,
20
+ message : 'Would you like to see the available templates?' ,
21
+ default : true
22
+ } ] ;
23
+
24
+ return this . prompt ( prompts ) . then ( answer => {
25
+ // To access answer later use this.answer.(answer you need);
26
+ this . answer = answer ;
27
+ } ) ;
28
+ } ,
30
29
31
30
configuring : function ( ) {
32
31
/*
@@ -51,7 +50,7 @@ module.exports = yeoman.Base.extend({
51
50
var options = {
52
51
uri : 'https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/contents/Templates' ,
53
52
headers : {
54
- 'User-Agent' : 'Request-Promise'
53
+ 'User-Agent' : 'Request-Promise'
55
54
} ,
56
55
json : true
57
56
} ;
@@ -60,7 +59,7 @@ module.exports = yeoman.Base.extend({
60
59
. then ( templates => {
61
60
this . log ( 'There are %d templates available' , templates . length ) ;
62
61
63
- for ( let i = 0 ; i < templates . length ; i ++ ) {
62
+ for ( let i = 0 ; i < templates . length ; i ++ ) {
64
63
listOfTemplates [ i ] = templates [ i ] [ 'name' ] ;
65
64
listOfUrls [ listOfTemplates [ i ] ] = templates [ i ] [ 'url' ] ;
66
65
}
@@ -88,29 +87,28 @@ module.exports = yeoman.Base.extend({
88
87
. catch ( err => {
89
88
this . log ( 'There was an error in searching for available templates...' ) ;
90
89
this . log ( err ) ;
91
- } )
90
+ } ) ;
92
91
}
93
92
} ,
94
93
95
94
_downloadTemplate : function ( templateToUse , listOfUrls , functionName ) {
96
95
var options = {
97
96
uri : listOfUrls [ templateToUse ] ,
98
97
headers : {
99
- 'User-Agent' : 'Request-Promise'
98
+ 'User-Agent' : 'Request-Promise'
100
99
} ,
101
100
json : true
102
101
} ;
103
102
104
103
this . log ( 'Creating your function ' + functionName + '...' ) ;
105
-
104
+
106
105
requestPromise ( options )
107
106
. then ( files => {
108
107
var pathToSaveFunction = path . resolve ( './' , functionName ) ;
109
108
110
-
111
109
fs . mkdir ( pathToSaveFunction , err => {
112
110
if ( err ) {
113
- if ( err . code != 'EEXIST' ) {
111
+ if ( err . code !== 'EEXIST' ) {
114
112
throw err ;
115
113
}
116
114
}
@@ -140,16 +138,16 @@ module.exports = yeoman.Base.extend({
140
138
. catch ( err => {
141
139
this . log ( 'There was an error in searching for the files for the template ' + templateToUse ) ;
142
140
this . log ( err ) ;
143
- } )
141
+ } ) ;
144
142
} ,
145
143
146
144
_configureTemplate : function ( pathOfTemplate ) {
147
145
// this.log('Configuring Template...');
148
146
// this.log('In path:');
149
147
// this.log(pathOfTemplate);
150
148
151
- // var functionJSON = JSON.parse(fs.readFileSync(path.resolve(pathOfTemplate,'function.json'), 'utf8').trim());
152
- // var metadataJSON = JSON.parse(fs.readFileSync(path.resolve(pathOfTemplate,'metadata.json'), 'utf8').trim());
149
+ // var functionJSON = JSON.parse(fs.readFileSync(path.resolve(pathOfTemplate, 'function.json'), 'utf8').trim());
150
+ // var metadataJSON = JSON.parse(fs.readFileSync(path.resolve(pathOfTemplate, 'metadata.json'), 'utf8').trim());
153
151
154
152
// // Find the matching userPrompt and bindings values to ask the user to change
155
153
// var valuesToChange = [];
@@ -160,17 +158,17 @@ module.exports = yeoman.Base.extend({
160
158
161
159
// this.log(functionJSON['bindings']);
162
160
// this.log(metadataJSON['userPrompt']);
163
- // var valuesToChange = [];
164
161
165
162
// for (let i in metadataJSON['userPrompt']) {
166
- // if (functionJSON.includes(i)) {
163
+ // this.log('i: ' + i);
164
+ // if (metadataJson[i] === functionJson[i]) {
167
165
// valuesToChange.push(i);
168
166
// }
169
167
// }
170
168
171
169
// this.log(functionJSON['bindings']);
172
170
// this.log(metadataJSON['userPrompt']);
173
-
171
+
174
172
// this.log('valuesToChange:');
175
173
// this.log(valuesToChange);
176
174
0 commit comments