Extract a valid github URL from a given object. We make the assumption that the given object follows a
package.jsonformat as used by npm.
InstallationThis module is released in the npm registry as
extract-githuband can therefor be installed using:
npm install --save extract-github
UsageThis module was written to only do specific task and do that task well, and that is extracting github information. We therefor export as a single function:
'use strict'; var extract = require('extract-github');
Once you've required the module you can feed it the contents of a package.json to extract to github information.
var github = extract(require('./package.json'));
githubvariable should now contain an object with a
repoproperty which can be re-used to create a new github URL. In addition to parsing package.json's it also supports extracting github information out of
READMEit can do this by extracting Travis-CI badges or just plain ol matching github URL from the content.
var github = extract(require('fs').readFileSync(__dirname +'/README.md'));