get-repo-package-json
Fetch a GitHub repository's package.json file using the GitHub API
Installation
npm install get-repo-package-json --save
Usage
The basics:
const getPackage =
To fetch a specific commit/branch/tag, use a long-form URL:
await
Or specify a ref
option:
await
To see more supported repository string formats, see the github-url-to-object demo.
API
This package exports a single function that returns a promise.
getPackage(repository, [options])
repository
(string) - Any string supported by github-url-to-object.options
(optional object)access_token
- GitHub API key. Can also be set as aGITHUB_ACCESS_TOKEN
environment variable.ref
- The name of the commit/branch/tag. Defaults to nothing, so the GitHub API will return the repo's default branch.
Tests
npm installnpm test
License
MIT