UNPKG

1.06 kBJavaScriptView Raw
1'use strict';
2
3const logger = require('./logger')();
4const index = require('..');
5
6function handleInput(input, cb, userOptions) {
7 logger.debug(input);
8 logger.debug(`user options ${userOptions}`);
9 index.getOptions((err, options) => {
10 if (err) {
11 logger.error('error from getOptions');
12 cb(err);
13 return;
14 }
15
16 logger.debug(options);
17
18 index.convertLcovToCoveralls(input, options, (err, postData) => {
19 if (err) {
20 logger.error('error from convertLcovToCoveralls');
21 cb(err);
22 return;
23 }
24
25 logger.info('sending this to coveralls.io: ', JSON.stringify(postData));
26 index.sendToCoveralls(postData, (err, response, body) => {
27 if (err) {
28 cb(err);
29 return;
30 }
31
32 if (response.statusCode >= 400) {
33 cb(`Bad response: ${response.statusCode} ${body}`);
34 return;
35 }
36
37 logger.debug(response.statusCode);
38 logger.debug(body);
39 cb(null, body);
40 });
41 });
42 }, userOptions);
43}
44
45module.exports = handleInput;