From c862fba4be31e9dcf89f10b3af923e0752cd48d2 Mon Sep 17 00:00:00 2001 From: cueedee Date: Wed, 11 Oct 2017 11:10:55 +0200 Subject: [PATCH] fix(generators/demo): avoid re-installing dependency --- generators/app/index.js | 2 +- generators/demo/index.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/generators/app/index.js b/generators/app/index.js index 2a6e4691..6e1fbd36 100644 --- a/generators/app/index.js +++ b/generators/app/index.js @@ -702,7 +702,7 @@ class AppGenerator extends Generator '\n' + 'Running a number of "' + chalk.yellow( 'npm install ' + chalk.cyan( '' ) + ' --save' + chalk.cyan( '[' ) + '-dev' + chalk.cyan( ']' )) - + '"s for you to install required dependencies.' + + '"s for you to install required dependencies...\n' )); this.npmInstall( devDeps, { saveDev: true } ); diff --git a/generators/demo/index.js b/generators/demo/index.js index 7a6bf758..d8c5eadc 100644 --- a/generators/demo/index.js +++ b/generators/demo/index.js @@ -202,9 +202,22 @@ class DemoGenerator extends Generator if ( !( data.i18n )) { return; } - var deps = [ 'madlib-locale' ]; + var pkgPath = this.destinationPath( 'package.json' ) + , fs = this.fs + , npm = fs.readJSON( pkgPath ) + , dep = 'madlib-locale' + ; + + if ( npm.dependencies[ dep ] ) { return; } + + this.log( chalk.bold( + '\n' + + 'Running "' + + chalk.yellow( 'npm install ' + chalk.cyan( dep ) + ' --save' ) + + '" for you to install required dependencies...\n' + )); - this.npmInstall( deps, { save: true } ); + this.npmInstall( [ dep ], { save: true } ); } )();