From 1dc05ccc2c6de68dfb4b5313df52d4d42ad2c152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 23 Sep 2019 13:12:03 +0200 Subject: [PATCH] refactor(cli): extract helper `logClassCreation` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- packages/cli/lib/artifact-generator.js | 9 +-------- packages/cli/lib/utils.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/cli/lib/artifact-generator.js b/packages/cli/lib/artifact-generator.js index 488d5abf370b..bd5ad38a5a84 100644 --- a/packages/cli/lib/artifact-generator.js +++ b/packages/cli/lib/artifact-generator.js @@ -79,14 +79,7 @@ module.exports = class ArtifactGenerator extends BaseGenerator { * >> Model MyModel will be created in src/models/my-model.model.ts **/ promptClassFileName(type, typePlural, name) { - this.log( - `${utils.toClassName(type)} ${chalk.yellow( - name, - )} will be created in src/${typePlural}/${chalk.yellow( - utils.toFileName(name) + '.' + `${type}.ts`, - )}`, - ); - this.log(); + utils.logClassCreation(type, typePlural, name, this.log.bind(this)); } scaffold() { diff --git a/packages/cli/lib/utils.js b/packages/cli/lib/utils.js index e8411b3a8a05..9cdf1403228f 100644 --- a/packages/cli/lib/utils.js +++ b/packages/cli/lib/utils.js @@ -119,6 +119,17 @@ exports.logNamingIssues = function(name, log) { } }; +exports.logClassCreation = function(type, typePlural, name, log) { + log( + `${exports.toClassName(type)} ${chalk.yellow( + name, + )} will be created in src/${typePlural}/${chalk.yellow( + exports.toFileName(name) + '.' + `${type}.ts`, + )}`, + ); + log(); +}; + /** * Validate project directory to not exist */