From dfc20fc8d9b845d18916c63de14c89bec84758e6 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Tue, 10 May 2016 15:39:44 +0200 Subject: [PATCH] Don't break if there is no git remote info --- lib/init/prompt.js | 6 ++++-- lib/util/git.js | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/init/prompt.js b/lib/init/prompt.js index e364e76..6ef2bbb 100644 --- a/lib/init/prompt.js +++ b/lib/init/prompt.js @@ -54,8 +54,10 @@ module.exports = function prompt(cb) { if (error) { return cb(error); } - questions[0].default = repoInfo.projectName; - questions[1].default = repoInfo.projectOwner; + if (repoInfo) { + questions[0].default = repoInfo.projectName; + questions[1].default = repoInfo.projectOwner; + } inquirer.prompt(questions, function treatAnswers(answers) { var config = { projectName: answers.projectName, diff --git a/lib/util/git.js b/lib/util/git.js index 1f94cd0..0cfe4ad 100644 --- a/lib/util/git.js +++ b/lib/util/git.js @@ -21,6 +21,10 @@ function getRemoteOriginData(cb) { function parse(originUrl) { var result = /:(\w+)\/([A-Za-z0-9-_]+)/.exec(originUrl); + if (!result) { + return null; + } + return { projectOwner: result[1], projectName: result[2]