UNPKG

623 BJavaScriptView Raw
1'use strict';
2
3const request = require('request');
4const index = require('..');
5
6const sendToCoveralls = (obj, cb) => {
7 let urlBase = 'https://coveralls.io';
8 if (process.env.COVERALLS_ENDPOINT) {
9 urlBase = process.env.COVERALLS_ENDPOINT;
10 }
11
12 const str = JSON.stringify(obj);
13 const url = `${urlBase}/api/v1/jobs`;
14
15 if (index.options.stdout) {
16 process.stdout.write(str);
17 cb(null, { statusCode: 200 }, '');
18 } else {
19 request.post({
20 url,
21 form: {
22 json: str
23 }
24 }, (err, response, body) => {
25 cb(err, response, body);
26 });
27 }
28};
29
30module.exports = sendToCoveralls;