/repo-images

Collect all the image file URLs in a GitHub repository

Primary LanguageJavaScript

repo-images

Collect all the image file URLs in a GitHub repository

Installation

npm install repo-images --save

Usage

const repoImages = require('repo-images')

repoImages('user/repo').then(images => {
  // an array of image objects
})

Each object in the returned array has this structure:

{
  path: 'build/icon.icns',
  mode: '100644',
  type: 'blob',
  sha: '3e7e2a36f9d1a5dfcaae886d0c0e5043b3ffee6a',
  size: 1192844,
  url: 'https://api.github.com/repos/ummoji/ummoji-desktop/git/blobs/3e7e2a36f9d1a5dfcaae886d0c0e5043b3ffee6a',
  rawgit: 'https://cdn.rawgit.com/ummoji/ummoji-desktop/master/build/icon.icns'
}

The default branch is master, but you can override it:

repoImages('user/repo', {branch: 'not-master'})

Authentication

  • If token option is set, it will be used.
  • If process.env.GITHUB_ACCESS_TOKEN is set, it will be used.
  • If neither is set, an unauthenticated request will be made.

Promises or Callbacks

If you don't like promises, you can use a node-style callback:

repoImages('user/repo', function(err, images) {
  if (err) throw err
  console.log(images)
})

Tests

npm install
npm test

Dependencies

  • gh-got: Convenience wrapper for got to interact with the GitHub API
  • pify: Promisify a callback-style function

Dev Dependencies

  • standard: JavaScript Standard Style
  • tap-spec: Formatted TAP output like Mocha's spec reporter
  • tape: tap-producing test harness for node and browsers

License

MIT

Generated by package-json-to-readme