From 6f5447bda534b36587e6160dccebc905d63ab81e Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Tue, 6 Feb 2018 10:26:29 -0700 Subject: [PATCH] Tailor message when local gulp is missing When there is a package.json file but no node_modules folder, tell them to run the full install command, instead of just adding gulp --- index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 1c488315..b01aa952 100644 --- a/index.js +++ b/index.js @@ -139,11 +139,23 @@ function handleArguments(env) { } if (!env.modulePath) { + var missingNodeModules = + fs.existsSync(path.join(env.cwd, 'package.json')) + && !fs.existsSync(path.join(env.cwd, 'node_modules')); + + var missingGulpMessage = + missingNodeModules + ? 'Local modules not found in' + : 'Local gulp not found in'; log.error( - ansi.red('Local gulp not found in'), + ansi.red(missingGulpMessage), ansi.magenta(tildify(env.cwd)) ); - log.error(ansi.red('Try running: npm install gulp')); + var installCommand = + missingNodeModules + ? 'npm install' + : 'npm install gulp'; + log.error(ansi.red('Try running: ' + installCommand)); exit(1); }