Skip to content

Commit

Permalink
fix(main): fix error occured when first commit (close #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
isuke committed Oct 18, 2018
1 parent dc7fdde commit 769c987
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions git-consistent
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ try {
}
} catch (e) {
console.error(`${colors.error}${e.message}${colors.reset}`)
e.status ? process.exit(e.status) : process.exit(1)
}
15 changes: 12 additions & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@ const colors = require('./colors')
// Functions
//
const getCurrentBranchName = () => {
return execSync('git rev-parse --abbrev-ref HEAD')
.toString()
.trim()
try {
return execSync('git rev-parse --abbrev-ref HEAD 2> /dev/null')
.toString()
.trim()
} catch (e) {
// it is First Commit
if (e.status === 128) {
return ''
} else {
throw e
}
}
}

const branchText = (definition) => {
Expand Down

0 comments on commit 769c987

Please sign in to comment.