From 47a5c4091840d7dfa4429c407b68a1c0407316e7 Mon Sep 17 00:00:00 2001 From: YakirSr Date: Tue, 23 Jul 2024 16:56:53 +0300 Subject: [PATCH] added colorized indications --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 953f126..88ba57e 100644 --- a/index.js +++ b/index.js @@ -33,7 +33,14 @@ function execute(cmd, pipe = true) { }); } +const greenOpenTag = "\x1b[32m"; +const blueOpenTag = "\x1b[36m"; +const redOpenTag = "\x1b[31m"; +const closingTag = "\x1b[0m"; + + (async function run() { + if (fetchFirst) { await execute(`git fetch`).catch(() => { console.log("Couldn't fetch. Fetch manually before to display new remote branches"); @@ -71,10 +78,13 @@ function execute(cmd, pipe = true) { default: checkedOutBranch, } ]); - await execute(`git checkout ${branch}`); + await execute(`git checkout ${branch}`).then(() => { + console.log(`${greenOpenTag}Success:${closingTag} You have successfully checkout ${blueOpenTag}${branch}${closingTag} branch!`); + }) })() .catch((e) => { + console.log(`${redOpenTag}Failure:${closingTag} Failed to checkout branch!`); console.log(e.message || e); process.exit(1); });