travis-ci-repo-info v1.1.1
Repository Info
Get repository info for one or more repositories.
Installation
$ npm install travis-ci-repo-infoUsage
var repoinfo = require( 'travis-ci-repo-info' );repoinfo( options, clbk )
Gets repository info for one or more repositories.
var opts = {
'repos': [
'math-io/erf',
'math-io/erfc',
'unknown/repo'
]
};
repoinfo( opts, clbk );
function clbk( error, results ) {
if ( error ) {
throw new Error( error.message );
}
console.dir( results );
/*
{
"meta": {
"total": 3,
"success": 2,
"failure": 1
},
"data": {
"math-io/erf": {...},
"math-io/erfc": {...}
},
"failures": {
"unknown/repo": "Not Found"
}
}
*/
}The function accepts the following options:
- repos:
arrayof Github repository slugs (required). Aslugshould obey the format:owner/:repo. - token: Travis CI access token.
- hostname: endpoint hostname. Default:
'api.travis-ci.org'.
To authenticate with Travis CI, set the token option.
var opts = {
'repos': ['kgryte/utils-copy'],
'token': 'tkjorjk34ek3nj4!'
};
repoinfo( opts, clbk );By default, the function retrieves repository info from the Travis CI API for open source. To retrieve from a different Travis CI API endpoint, set the hostname option.
var opts = {
'repos': ['kgryte/utils-deep-get'],
'hostname': 'api.travis-ci.com'
};
repoinfo( opts, clbk );repoinfo.factory( options, clbk )
Creates a reusable function.
var opts = {
'repos': [
'math-io/gamma',
'math-io/factorial'
],
'token': 'tkjorjk34ek3nj4!',
'hostname': 'api.travis-ci.org'
};
var get = repoinfo.factory( opts, clbk );
get();
get();
get();
// ...The factory method accepts the same options as repoinfo().
Notes
- If the module encounters an application-level
error(e.g., no network connection, etc), thaterroris returned immediately to the providedcallback. - If the module encounters a downstream
error(e.g., timeout, reset connection, etc), thaterroris included in the returned results under thefailuresfield.
Examples
var repoinfo = require( 'travis-ci-repo-info' );
var opts = {
'repos': [
'math-io/erf',
'math-io/erfc',
'math-io/erfinv'
]
};
repoinfo( opts, clbk );
function clbk( error, results ) {
if ( error ) {
throw new Error( error.message );
}
console.dir( results );
}To run the example code from the top-level application directory,
$ node ./examples/index.jsCLI
Installation
To use the module as a general utility, install the module globally
$ npm install -g travis-ci-repo-infoUsage
Usage: travisrepoinfo [options] slug1 slug2 ...
Options:
-h, --help Print this message.
-V, --version Print the package version.
--hostname host Hostname. Default: api.travis-ci.org.
--token token Travis CI access token.Notes
If a
slugis not provided, the implementation will attempt to infer aslugby executinggit config remote.origin.urlin the current working directory.
In addition to the
tokenoption, the token may be specified by aTRAVISCI_TOKENenvironment variable. The command-line option always takes precedence.- If a repository's info is successfully resolved, the repository info is written to
stdout. - If a repository's info cannot be resolved due to a downstream
error(failure), the repositoryslug(and its associatederror) is written tosterr. - Output order is not guaranteed to match input order.
Examples
Setting the access token using the command-line option:
$ DEBUG=* travisrepoinfo --token <token> math-io/erfinv
# => {...}Setting the access token using an environment variable:
$ DEBUG=* TRAVISCI_TOKEN=<token> travisrepoinfo math-io/erfinv
# => {...}For local installations, modify the command to point to the local installation directory; e.g.,
$ DEBUG=* ./node_modules/.bin/travisrepoinfo --token <token> math-io/erfinv
# => {...}Or, if you have cloned this repository and run npm install, modify the command to point to the executable; e.g.,
$ DEBUG=* node ./bin/cli --token <token> math-io/erfinv
# => {...}Tests
Unit
This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:
$ make testAll new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-covIstanbul creates a ./reports/coverage directory. To access an HTML version of the report,
$ make view-covBrowser Support
This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:
$ make test-browsersTo view the tests in a local web browser,
$ make view-browser-testsLicense
Copyright
Copyright © 2016. Athan Reines.