From f6fb6ebcd26ed551785631b1dac41c601bb63ebf Mon Sep 17 00:00:00 2001 From: gruppjo Date: Mon, 27 Jun 2016 13:15:01 +0200 Subject: [PATCH] closes #364: yeoman promise syntax --- generators/apiomat/index.js | 7 +++---- generators/app/index.js | 11 ++++------- generators/module/index.js | 9 +++------ package.json | 4 ++-- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/generators/apiomat/index.js b/generators/apiomat/index.js index 844a9a7..1b0873f 100644 --- a/generators/apiomat/index.js +++ b/generators/apiomat/index.js @@ -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', @@ -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)); }, diff --git a/generators/app/index.js b/generators/app/index.js index cc01c59..8bf820e 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -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)); } }, @@ -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)); } }, diff --git a/generators/module/index.js b/generators/module/index.js index 7f1ed3e..535b0e3 100644 --- a/generators/module/index.js +++ b/generators/module/index.js @@ -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', @@ -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 { diff --git a/package.json b/package.json index 58cbe1a..c1182d2 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "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": { @@ -59,7 +59,7 @@ "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",