Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

get-repo-package-json

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-repo-package-json

Fetch a GitHub repository's package.json file using the GitHub API

latest
Source
npmnpm
Version
2.0.0
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

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 = 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:

await getPackage('https://github.com/monkey/business/tree/experiment')

Or specify a ref option:

await getPackage('monkey/business', {ref: '0e783153885ed78f71d138085a77644ff8e59aa1'})

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 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

npm install
npm test

License

MIT

Keywords

package.json

FAQs

Package last updated on 07 Jun 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts