JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4281
  • Score
    100M100P100Q148884F
  • License MPL-2.0

Get the current branch name.

Package Exports

  • branch-name

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (branch-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

branch-name Build status for branch-name on Circle CI.

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);  // prints current branch if possible, 'dev' otherwise
});

Get the current branch name, with the default master as a fallback.

branchName.assumeMaster().then((name) => {
   console.log(name);  // prints current branch if possible, 'master' otherwise
});

Contributing

See our contributing guidelines for more details.

  1. Fork it.
  2. Make a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request.

License

MPL-2.0 © Seth Holladay

Go make something, dang it.