From b161de9bcad38660c634268f176f90cb22abe6f3 Mon Sep 17 00:00:00 2001 From: gossi Date: Sun, 23 Dec 2018 19:30:49 +0100 Subject: [PATCH] bugfix name arg --- bin/ember-cli-create.js | 4 +--- src/commands/create.js | 4 ++++ src/prompts/create-wizard.js | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/ember-cli-create.js b/bin/ember-cli-create.js index da0467d..9b1ba98 100755 --- a/bin/ember-cli-create.js +++ b/bin/ember-cli-create.js @@ -13,9 +13,7 @@ programm .option('--npm', 'Use npm as package manager (instead of yarn)') .option('--welcome', 'To install the {{ember-welcome-page}}') .action(function (name, options) { - const cmd = new CreateCommand({ - name: name - }, options); + const cmd = new CreateCommand({ name }, options); cmd.run(); }); diff --git a/src/commands/create.js b/src/commands/create.js index 3de8d06..f17087d 100644 --- a/src/commands/create.js +++ b/src/commands/create.js @@ -25,6 +25,10 @@ module.exports = class CreateCommand { answers.preset = this.options.preset; } + if (!answers.name && this.args.name) { + answers.name = this.args.name; + } + return this.compileConfig(answers); } diff --git a/src/prompts/create-wizard.js b/src/prompts/create-wizard.js index bffabc7..a83a134 100644 --- a/src/prompts/create-wizard.js +++ b/src/prompts/create-wizard.js @@ -17,6 +17,7 @@ function dasherize(str) { module.exports = function (args, options) { // put options into local variables (so they are overridable with answers) let preset = options.preset; + let name = args.name; return [ { @@ -48,11 +49,12 @@ module.exports = function (args, options) { message: 'What is the name of your project', suffix: ':', when: () => { - return !args.name; + return !name; }, validate(input) { if (input !== '') { - return true; + name = input; + return name; } return 'Please enter a name for your project'; @@ -62,8 +64,8 @@ module.exports = function (args, options) { name: 'directory', message: 'Where to create your project?', suffix: ':', - default(answers) { - return './' + answers.name; + default() { + return './' + name; }, validate(input) { return input !== '';