next-pr
v1.0.0
Published
Predict the next pull request number for a GitHub repository
Readme
next-pr
Predict the next pull request number for a GitHub repository.
Useful when you need a PR's number before it exists; for example, to reference it in a changelog entry that ships with the PR itself.
CLI
$ npx next-pr nodejs/node
58124Full GitHub URLs and .git suffixes work too:
$ npx next-pr https://github.com/nodejs/node.git
58124Unauthenticated requests are limited to 60 per hour by GitHub. Set a
GITHUB_TOKEN environment variable to raise the limit (any token with public
repo read access works, including the automatic token in GitHub Actions):
$ GITHUB_TOKEN=ghp_... npx next-pr nodejs/nodeAPI
$ npm install next-primport { nextPrNumber } from "next-pr";
const number = await nextPrNumber("nodejs/node");
// or: await nextPrNumber("https://github.com/nodejs/node")
console.log(number); // e.g. 58124nextPrNumber(repo, options?)
repo: aowner/reposlug or a github.com URL.options.token: GitHub API token. Defaults toprocess.env.GITHUB_TOKEN.
Returns a Promise<number>. Rejects with an Error if the repo slug is
malformed or the GitHub API returns a non-2xx response (e.g. an unknown repo
or a hit rate limit).
parseRepo(input)
The slug/URL parser used internally, exported for convenience. Returns
{ owner, repo } or throws on invalid input.
Caveats
The result is a prediction, not a reservation: if someone opens an issue or PR between the lookup and your PR, the number will be off by however many landed in between.
