From f079ba59c6274ca36dae7ead65e918e3a9884082 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Sat, 30 Nov 2019 01:22:10 +0100 Subject: [PATCH] fix(setup): show `master` as a default branch when there is no remote yet (#466) --- packages/shipjs/src/step/setup/askQuestions.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/shipjs/src/step/setup/askQuestions.js b/packages/shipjs/src/step/setup/askQuestions.js index e941962a..d5afad08 100644 --- a/packages/shipjs/src/step/setup/askQuestions.js +++ b/packages/shipjs/src/step/setup/askQuestions.js @@ -45,13 +45,18 @@ export default async ({ dir }) => }); async function askBranches(dir) { - const branches = getRemoteBranches(dir); - const baseBranchCandidate = ['develop', 'dev', 'master'].find(item => + let branches = getRemoteBranches(dir); + let baseBranchCandidate = ['develop', 'dev', 'master'].find(item => branches.includes(item) ); - const releaseBranchCandidate = ['releases', 'release', 'master'].find(item => + let releaseBranchCandidate = ['releases', 'release', 'master'].find(item => branches.includes(item) ); + if (branches.length === 0) { + branches = ['master']; + baseBranchCandidate = 'master'; + releaseBranchCandidate = 'master'; + } const { baseBranch, releaseBranch } = await inquirer.prompt([ { type: 'list',