aboutsummaryrefslogtreecommitdiff
path: root/lib/sendToCoveralls.js
blob: fcf63a8d44b6f81fa00d847006f4b6d74bd4b798 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var request = require('request');
var index = require('../index');

var sendToCoveralls = function(obj, cb){
  var urlBase = 'https://coveralls.io';
  if (process.env.COVERALLS_ENDPOINT) {
    urlBase = process.env.COVERALLS_ENDPOINT;
  }

  var str = JSON.stringify(obj);
  var url = urlBase + '/api/v1/jobs';
  
  if (index.options.stdout) {
    process.stdout.write(str);
    cb(null, { statusCode: 200 }, '');
  } else {
    request.post({url : url, form : { json : str}}, function(err, response, body){
      cb(err, response, body);
    });
  }
};

module.exports = sendToCoveralls;