Skip to content
This repository has been archived by the owner on Jul 8, 2020. It is now read-only.

Commit

Permalink
closes #364: yeoman promise syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
gruppjo committed Jun 27, 2016
1 parent 3de0520 commit f6fb6eb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 19 deletions.
7 changes: 3 additions & 4 deletions generators/apiomat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ module.exports = yeoman.Base.extend({
* saves modelJSON to this.model on success
*/
prompting: function () {
var done = this.async();

var prompts = [{
type: 'input',
name: 'modelPath',
Expand All @@ -23,9 +21,10 @@ module.exports = yeoman.Base.extend({
name: 'moduleName',
message: '\nEnter the module to generate your files into \nRecommended - leave empty for main.\n'
}];
this.prompt(prompts, function (props) {

return this.prompt(prompts)
.then(function (props) {
this.props = props;
done();
}.bind(this));
},

Expand Down
11 changes: 4 additions & 7 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ module.exports = yeoman.Base.extend({
if (!this.options['skip-prompts']) {
// tell yeoman we're doing asynchronous stuff here
// so it can wait with subsequent tasks
var done = this.async();

this.prompt(prompts.main, function (answers) { // prompt
return this.prompt(prompts.main)
.then(function (answers) { // prompt
this.answers = answers;

done();
}.bind(this));
}
},
Expand Down Expand Up @@ -196,10 +194,9 @@ module.exports = yeoman.Base.extend({
ecosystemPrompts: function () {
if (!this.options['skip-prompts']) {
// ecosystem prompts
var done = this.async();
this.prompt(prompts.ecosystems, function (answers) { // prompt
return this.prompt(prompts.ecosystems)
.then(function (answers) { // prompt
this.answers.ecosystems = answers.ecosystems;
done();
}.bind(this));
}
},
Expand Down
9 changes: 3 additions & 6 deletions generators/module/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ module.exports = yeoman.Base.extend({
if (!this.options['skip-prompts']) {
// tell yeoman we're doing asynchronous stuff here
// so it can wait with subsequent tasks
var done = this.async();

this.prompt({
return this.prompt({
type: 'list',
name: 'template',
message: '\nChoose a starter template\n',
Expand All @@ -47,11 +46,9 @@ module.exports = yeoman.Base.extend({
name: 'blank'
}
]
},
function (answers) { // prompt
})
.then(function (answers) { // prompt
this.answers = answers;

done();
}.bind(this));
}
else {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
"generator-appmobi": "^0.0.5",
"mkdirp": "^0.5.1",
"underscore.string": "^3.2.0",
"yeoman-generator": "^0.22.1",
"yeoman-generator": "^0.23.4",
"yosay": "^1.0.4"
},
"devDependencies": {
"coveralls": "^2.11.2",
"eslint": "^2.1.0",
"gulp": "^3.9.0",
"gulp-eslint": "^2.0.0",
"gulp-istanbul": "^0.10.0",
"gulp-istanbul": "^1.0.0",
"gulp-load-plugins": "^1.0.0",
"gulp-mocha": "^2.1.2",
"gulp-plumber": "^1.0.1",
Expand Down

0 comments on commit f6fb6eb

Please sign in to comment.