UNPKG

ggit

Version:

Local promise-returning git command wrappers

27 lines (23 loc) 577 B
var la = require('lazy-ass') var check = require('check-more-types') var exec = require('./exec') /* Returns the branch name */ function branchName () { var cmd = 'git rev-parse --abbrev-ref HEAD' return exec.exec(cmd).then(function cleanOutput (str) { la(check.unemptyString(str), 'expected branch name string', str) return str.trim() }) } module.exports = branchName if (!module.parent) { ;(function tryBranchName () { branchName() .then(function (name) { console.log('Current branch name is "%s"', name) }) .done() })() }