From 87b8ee8c972ad03b8105e3c4c7c61841351a79aa Mon Sep 17 00:00:00 2001 From: usama54321 Date: Thu, 28 Jun 2018 17:36:49 +0500 Subject: [PATCH] add local check for angular cli too --- index.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index f74239c..bdff572 100644 --- a/index.js +++ b/index.js @@ -67,13 +67,19 @@ if (!angularCliBasePath) { var candidatePath = path.join(yarnModulesPath(), 'node_modules/@angular/cli'); angularCliBasePath = fs.existsSync(candidatePath) && candidatePath; } + if (!angularCliBasePath) { - console.error( - chalk.red( - "Couldn't find the global installation of the Angular CLI... is it installed?\n" + - 'You can install the CLI globally using "npm install @angular/cli -g"' - ) - ); + try { + //try locally once before erroring + require('@angular/cli/bin/ng') + } catch(e) { + console.error( + chalk.red( + "Couldn't find the global or local installation of the Angular CLI... is it installed?\n" + + 'You can install the CLI globally using "npm install @angular/cli -g"' + ) + ); + } } else { var angularCliPath = path.join(angularCliBasePath, 'bin/ng');