1.0.0 • Published 7 months ago

get-github-default-branch-name v1.0.0

Weekly downloads
698
License
MIT
Repository
github
Last release
7 months ago

The default branch name is no longer master. To avoid things to break it is a good idea to replace in your codebase the hard coded master word and fetch whatever the default branch is dynamically.

This module provide a way to fetch the default branch name synchronously which could save you lots of hours of refactoring.
Of course you should only do the call synchronously if you can't do otherwise.

Previous result are saved so if you call the method multiple time against the same repo the request will be made only once.

Usage

$ npm install --save get-github-default-branch-name
import {
    getGithubDefaultBranchName,
    getGithubDefaultBranchNameSync,
} from "get-github-default-branch-name";

//Prints "develop" because the default branch of garronej/evt is "main" instead of "master"
getGithubDefaultBranchName({
    "owner": "garronej",
    "repo": "evt",
}).then(defaultBranchName => console.log(defaultBranchName));

//Synchronous version, avoid using if possible. Only OK for scripts.

const defaultBranchName = getGithubDefaultBranchNameSync({
    "owner": "garronej",
    "repo": "evt",
});

console.log(defaultBranchName); // Prints "main"

Contribute

npm install
npm run build
npm test
1.0.0

7 months ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago