branch-name
Get the current branch name.
Why?
- Clean, minimal, promise-based API.
- Respects your
$PATH
. - Uses the most reliable branch detection algorithm.
- Gives you control in weird situations.
Install
npm install branch-name --save
Usage
Get it into your program.
const branchName = require('branch-name');
Get the current branch name.
branchName.get().then((name) => {
console.log(name);
});
Get the current branch name, but with a fallback result for detached head and non-repository situations.
branchName.assume('dev').then((name) => {
console.log(name);
});
Get the current branch name, with the default master
as a fallback.
branchName.assumeMaster().then((name) => {
console.log(name);
});
Contributing
See our contributing guidelines for more details.
- Fork it.
- Make a feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request.
License
MPL-2.0 © Seth Holladay
Go make something, dang it.