Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gh-raw

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gh-raw

Simply get raw files for github repository

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gh-raw

Simply get raw files of github repository

Install

$ npm install gh-raw

Usage

if you want to get file of github repository

const ghRaw = require('gh-raw')

ghRaw.get('/data/text.md', {
  blob: 'master', // branch name
  repository: 'zeakd/gh-raw',
}).then(res => {
  console.log(res)
  /*
    ---
    title: sample text
    ---

    # text

    This is sample text
    This is another text
   */ 
}).catch(error => {
  console.error(error);
})

you can also get file from past commit

const ghRaw = require('gh-raw')

ghRaw.get('/data/text.md', {
  blob: '9f311db2f4d5032252351806778306dfba1f4be4', // full commit hash
  repository: 'zeakd/gh-raw',
}).then(res => {
  console.log(res)
  /*
    ---
    title: sample text
    ---

    # text

    This is sample text
   */ 
})

How it works?

it use https://raw.githubusercontent.com/

API

ghRaw.get(path, [options])

options is required without extend because repository should be specified.

ghRaw.get('/data/text.md', {
  repository: 'zeakd/gh-raw',
})

// specific branch
ghRaw.get('/data/text.md', {
  repository: 'zeakd/gh-raw',
  blob: 'samples'

  // or you can use alias
  // branch: 'samples'
})

// specific commit
ghRaw.get('/data/text.md', {
  repository: 'zeakd/gh-raw',
  blob: '9f311db2f4d5032252351806778306dfba1f4be4'

  // or you can use alias
  // commit: '9f311db2f4d5032252351806778306dfba1f4be4'
})

ghRaw.extend(options)

ghRaw is extendable. it would be convenient to extend with reposotory option.

const rawRepo = ghRaw.extend({
  repository: 'zeakd/gh-raw',
})

rawRepo.get('data/text.md')

const sampleRepo = rawRepo.extend({
  blob: 'samples',
})

sampleRepo.get('data/text.md')

options

{
  repository: 'zeakd/gh-raw' // default: undefined, 
  blob: 'master' // default: 'master'. alias : ['branch', 'commit']
}

Keywords

FAQs

Package last updated on 05 Oct 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc