Skip to content

Commit a69ff24

Browse files
committed
Fixed up some stuff for eslint and worked on configure template
1 parent 3ee373b commit a69ff24

File tree

4 files changed

+34
-37
lines changed

4 files changed

+34
-37
lines changed

generators/app/index.js

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,25 @@ var requestPromise = require('request-promise');
77
var fs = require('fs');
88
var path = require('path');
99

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+
},
3029

3130
configuring: function () {
3231
/*
@@ -51,7 +50,7 @@ module.exports = yeoman.Base.extend({
5150
var options = {
5251
uri: 'https://api.github.com/repos/Azure/azure-webjobs-sdk-templates/contents/Templates',
5352
headers: {
54-
'User-Agent': 'Request-Promise'
53+
'User-Agent': 'Request-Promise'
5554
},
5655
json: true
5756
};
@@ -60,7 +59,7 @@ module.exports = yeoman.Base.extend({
6059
.then(templates => {
6160
this.log('There are %d templates available', templates.length);
6261

63-
for (let i = 0; i < templates.length; i ++) {
62+
for (let i = 0; i < templates.length; i++) {
6463
listOfTemplates[i] = templates[i]['name'];
6564
listOfUrls[listOfTemplates[i]] = templates[i]['url'];
6665
}
@@ -88,29 +87,28 @@ module.exports = yeoman.Base.extend({
8887
.catch(err => {
8988
this.log('There was an error in searching for available templates...');
9089
this.log(err);
91-
})
90+
});
9291
}
9392
},
9493

9594
_downloadTemplate: function (templateToUse, listOfUrls, functionName) {
9695
var options = {
9796
uri: listOfUrls[templateToUse],
9897
headers: {
99-
'User-Agent': 'Request-Promise'
98+
'User-Agent': 'Request-Promise'
10099
},
101100
json: true
102101
};
103102

104103
this.log('Creating your function ' + functionName + '...');
105-
104+
106105
requestPromise(options)
107106
.then(files => {
108107
var pathToSaveFunction = path.resolve('./', functionName);
109108

110-
111109
fs.mkdir(pathToSaveFunction, err => {
112110
if (err) {
113-
if (err.code != 'EEXIST') {
111+
if (err.code !== 'EEXIST') {
114112
throw err;
115113
}
116114
}
@@ -140,16 +138,16 @@ module.exports = yeoman.Base.extend({
140138
.catch(err => {
141139
this.log('There was an error in searching for the files for the template ' + templateToUse);
142140
this.log(err);
143-
})
141+
});
144142
},
145143

146144
_configureTemplate: function(pathOfTemplate) {
147145
// this.log('Configuring Template...');
148146
// this.log('In path:');
149147
// this.log(pathOfTemplate);
150148

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());
153151

154152
// // Find the matching userPrompt and bindings values to ask the user to change
155153
// var valuesToChange = [];
@@ -160,17 +158,17 @@ module.exports = yeoman.Base.extend({
160158

161159
// this.log(functionJSON['bindings']);
162160
// this.log(metadataJSON['userPrompt']);
163-
// var valuesToChange = [];
164161

165162
// for (let i in metadataJSON['userPrompt']) {
166-
// if (functionJSON.includes(i)) {
163+
// this.log('i: ' + i);
164+
// if (metadataJson[i] === functionJson[i]) {
167165
// valuesToChange.push(i);
168166
// }
169167
// }
170168

171169
// this.log(functionJSON['bindings']);
172170
// this.log(metadataJSON['userPrompt']);
173-
171+
174172
// this.log('valuesToChange:');
175173
// this.log(valuesToChange);
176174

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ gulp.task('nsp', function (cb) {
2121
});
2222

2323
gulp.task('pre-test', function () {
24-
return gulp.src('generators\**\*.js')
24+
return gulp.src('generators*.js')
2525
.pipe(excludeGitignore())
2626
.pipe(istanbul({
2727
includeUntested: true
@@ -45,7 +45,7 @@ gulp.task('test', ['pre-test'], function (cb) {
4545
});
4646

4747
gulp.task('watch', function () {
48-
gulp.watch(['generators\**\*.js', 'test/**'], ['test']);
48+
gulp.watch(['generators*.js', 'test/**'], ['test']);
4949
});
5050

5151
gulp.task('prepublish', ['nsp']);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-azurefunctions",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "A Yeoman Generator for Azure Functions",
55
"homepage": "",
66
"author": {

test/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22
var path = require('path');
3-
var assert = require('yeoman-assert');
43
var helpers = require('yeoman-test');
54

65
describe('generator-azurefunctions:app', function () {

0 commit comments

Comments
 (0)