1 | var la = require('lazy-ass')
|
2 | var check = require('check-more-types')
|
3 | var exec = require('./exec')
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | function branchName () {
|
9 | var cmd = 'git rev-parse --abbrev-ref HEAD'
|
10 | return exec(cmd).then(function cleanOutput (str) {
|
11 | la(check.unemptyString(str), 'expected branch name string', str)
|
12 | return str.trim()
|
13 | })
|
14 | }
|
15 |
|
16 | module.exports = branchName
|
17 |
|
18 | if (!module.parent) {
|
19 | ;(function tryBranchName () {
|
20 | branchName()
|
21 | .then(function (name) {
|
22 | console.log('Current branch name is "%s"', name)
|
23 | })
|
24 | .done()
|
25 | })()
|
26 | }
|