From bf32c59770e289a1784b99a06ddc5e67f7551213 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Wed, 30 Dec 2020 18:50:42 -0500 Subject: [PATCH] add enquire --- .gitignore | 1 + package.json | 1 + src/commands/new_branch.ts | 22 ++++++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3955fd6..018a157 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules/ pnpm-debug.log pnpm-lock.yaml +dist diff --git a/package.json b/package.json index 894cd3b..2d1a034 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "author": "Yanick Champoux (http://techblog.babyl.ca)", "license": "ISC", "dependencies": { + "@types/inquirer": "^7.3.1", "@types/node": "^14.14.16", "@types/yargs": "^15.0.12", "inquirer": "^7.3.3", diff --git a/src/commands/new_branch.ts b/src/commands/new_branch.ts index 4e6eaa3..653ea29 100644 --- a/src/commands/new_branch.ts +++ b/src/commands/new_branch.ts @@ -1,13 +1,27 @@ import Git from 'simple-git'; +import inquirer from 'inquirer'; async function check_workspace_clean() { - return Git().status().then( (result) => { - if(!result.isClean()) throw new Error('workspace not clean, aborting'); - }) + return Git().status().then((result) => { + if (!result.isClean()) throw new Error('workspace not clean, aborting'); + }) } export default async () => { await check_workspace_clean(); - console.log( 'yay'); + const result = await Git().branch({'--merged': 'HEAD'}); + + const ancestors = result.all; + + const resp = await inquirer.prompt([ + { + name: 'parent', + message: 'grand-parent branch: ', + type: 'list', + choices: ancestors, + } + ]) + + console.log(resp); }