Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/github-modules/get-repo-package-json
🐱 Fetch a GitHub repository's package.json file using the GitHub API
https://github.com/github-modules/get-repo-package-json
Last synced: about 1 month ago
JSON representation
🐱 Fetch a GitHub repository's package.json file using the GitHub API
- Host: GitHub
- URL: https://github.com/github-modules/get-repo-package-json
- Owner: github-modules
- Created: 2016-08-07T04:47:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-07T08:05:26.000Z (over 6 years ago)
- Last Synced: 2024-11-08T08:54:46.021Z (about 1 month ago)
- Language: JavaScript
- Homepage: http://npm.im/get-repo-package-json
- Size: 26.4 KB
- Stars: 8
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# get-repo-package-json
Fetch a GitHub repository's package.json file using the GitHub API
## Installation
```sh
npm install get-repo-package-json --save
```## Usage
The basics:
```js
const getPackage = require('get-repo-package-json')getPackage('segmentio/nightmare').then(pkg => { console.log(pkg) })
```To fetch a specific commit/branch/tag, use a long-form URL:
```js
await getPackage('https://github.com/monkey/business/tree/experiment')
```Or specify a `ref` option:
```js
await getPackage('monkey/business', {ref: '0e783153885ed78f71d138085a77644ff8e59aa1'})
```To see more supported repository string formats, see the
[github-url-to-object](https://zeke.github.io/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](https://zeke.github.io/github-url-to-object/).
- `options` (optional object)
- `access_token` - GitHub API key. Can also be set as a `GITHUB_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
```sh
npm install
npm test
```## License
MIT