generate-dest
Advanced tools
+19
-20
@@ -10,9 +10,8 @@ /*! | ||
| var askWhen = require('ask-when'); | ||
| var path = require('path'); | ||
| var isValid = require('is-valid-app'); | ||
| var path = require('path'); | ||
| var ask = require('ask-when'); | ||
| module.exports = function(app, base, env, options) { | ||
| if (!isValid(app, 'generate-dest')) return; | ||
| app.use(askWhen()); | ||
@@ -26,3 +25,3 @@ /** | ||
| * ``` | ||
| * @name dest:prompt-dest | ||
| * @name prompt-dest | ||
| * @api public | ||
@@ -40,27 +39,27 @@ */ | ||
| app.question('dest', 'Destination directory?', {default: app.cwd}) | ||
| .askWhen('dest', {save: false}, function(err, answers) { | ||
| if (err) { | ||
| next(err); | ||
| return; | ||
| } | ||
| app.question('dest', 'Destination directory?', {default: app.cwd}); | ||
| ask.when(app, 'dest', {save: false}, function(err, answers) { | ||
| if (err) { | ||
| next(err); | ||
| return; | ||
| } | ||
| var dest = path.resolve(answers.dest || app.cwd); | ||
| base.option('dest', dest); | ||
| app.option('dest', dest); | ||
| next(); | ||
| }); | ||
| var dest = path.resolve(answers.dest || app.cwd); | ||
| base.option('dest', dest); | ||
| app.option('dest', dest); | ||
| next(); | ||
| }); | ||
| }); | ||
| /** | ||
| * Alias for the [prompt-dest](#destprompt-dest) task. _(A generator's `default` task | ||
| * is run when no specific task name is given. This allows the `prompt-dest` task be | ||
| * run with the `gen dest` command)_ | ||
| * Alias for the [prompt-dest](#prompt-dest) task. _(the `default` task is run when no | ||
| * specific task name is given. This allows the `prompt-dest` task be run with the | ||
| * `$ gen dest` command)_ | ||
| * | ||
| * ```sh | ||
| * $ gen dest:default | ||
| * # or | ||
| * # aliased as | ||
| * $ gen dest | ||
| * ``` | ||
| * @name dest:default | ||
| * @name dest | ||
| * @api public | ||
@@ -67,0 +66,0 @@ */ |
+4
-3
| { | ||
| "name": "generate-dest", | ||
| "description": "`Generate` generator that prompts the user for the destination directory to use. Can be used as a sub-generator or plugin in your generator.", | ||
| "version": "0.1.3", | ||
| "description": "Prompts the user for the destination directory to use. Can be used from the command line when installed globally, or as plugin or sub-generator in your generator.", | ||
| "version": "0.1.4", | ||
| "homepage": "https://github.com/generate/generate-dest", | ||
@@ -92,3 +92,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
| "verb", | ||
| "verb-readme-generator" | ||
| "verb-readme-generator", | ||
| "base" | ||
| ], | ||
@@ -95,0 +96,0 @@ "lint": { |
4846
-0.43%64
-1.54%