Skip to content

Commit

Permalink
Use chalk for coloring important stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
draperunner committed May 8, 2019
1 parent 749efcd commit cd36a24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
34 changes: 20 additions & 14 deletions git-pretty.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
const inquirer = require('inquirer')
const chalk = require('chalk')

async function ask(question, choices) {
const { answer } = await inquirer.prompt([{
Expand All @@ -18,15 +19,20 @@ function askYesNo(question) {
return ask(question, ['Yes', 'No'])
}

function printCode(code) {
console.log(chalk.bgGreenBright(chalk.black(` ${code} `)))
}

function interactiveRebase() {
console.log('We\'re going to do an interactive rebase!')
console.log('Welcome to the DANGER ZONE!')
console.log(`We\'re going to do an ${chalk.bold('** interactive rebase! **')}`)
console.log()
console.log(chalk.bgRed('Welcome to the DANGER ZONE!'))
console.log()
console.log('git rebase -i {COMMITISH}')
printCode('git rebase -i {COMMITISH}')
console.log()
console.log('And when that\'s done, do this:')
console.log()
console.log('git push --force origin {branch}')
printCode('git push --force origin {branch}')
console.log()
}

Expand All @@ -51,7 +57,7 @@ async function main() {
if (answer === '2') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git reset --hard')
printCode('git reset --hard')
console.log()
return '12'
}
Expand All @@ -63,7 +69,7 @@ async function main() {
if (answer === '1') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git revert {COMMITISH}')
printCode('git revert {COMMITISH}')
console.log()
return '21'
}
Expand All @@ -85,32 +91,32 @@ async function main() {
if (answer === '1') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git add {my_awesome_file}')
console.log('git commit --amend')
printCode('git add {my_awesome_file}')
printCode('git commit --amend')
console.log()
return '2211'
}

if (answer === '2') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git commit --amend')
printCode('git commit --amend')
console.log()
return '2212'
}

if (answer === '3') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git reset HEAD~')
printCode('git reset HEAD~')
console.log()
return '2213'
}

if (answer === '4') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git reset --hard HEAD^')
printCode('git reset --hard HEAD^')
console.log()
return '2214'
}
Expand All @@ -122,7 +128,7 @@ async function main() {
if (answer === '1') {
console.log('We\'ll reset and commit from scratch:')
console.log()
console.log('git reset {COMMITISH}')
printCode('git reset {COMMITISH}')
console.log()
console.log('Then split off a logical chunk from your mess, stage it and commit it with a good message.')
console.log('Still have a mess? Do it again.')
Expand Down Expand Up @@ -184,7 +190,7 @@ async function main() {
if (answer === '1') {
console.log('Looks like this is what you are looking for:')
console.log()
console.log('git rebase origin/{branch}')
printCode('git rebase origin/{branch}')
console.log()
return '321'
}
Expand All @@ -199,7 +205,7 @@ async function main() {
if (answer === '4') {
console.log('To delete all local branches that are already merged into the currently checked out branch:')
console.log()
console.log('git branch --merged | egrep -v \'(^\\*|master|dev)\' | xargs git branch -d')
printCode('git branch --merged | egrep -v \'(^\\*|master|dev)\' | xargs git branch -d')
console.log()
console.log('You can see that master and dev are excluded in case they are an ancestor.')
console.log('Check out https://stackoverflow.com/questions/6127328/how-can-i-delete-all-git-branches-which-have-been-merged')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"inquirer": "^6.3.1"
},
"devDependencies": {
"chalk": "^2.4.2",
"eslint": "^5.16.0"
}
}

0 comments on commit cd36a24

Please sign in to comment.