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',
repository: 'zeakd/gh-raw',
}).then(res => {
console.log(res)
}).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',
repository: 'zeakd/gh-raw',
}).then(res => {
console.log(res)
})
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',
})
ghRaw.get('/data/text.md', {
repository: 'zeakd/gh-raw',
blob: 'samples'
})
ghRaw.get('/data/text.md', {
repository: 'zeakd/gh-raw',
blob: '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'
blob: 'master'
}