UNPKG

920 BJavaScriptView Raw
1#!/usr/bin/env node
2
3var Formatter = require("../formatter");
4var client = require('../http_client');
5
6process.stdin.resume();
7process.stdin.setEncoding("utf8");
8
9var input = "";
10
11process.stdin.on("data", function(chunk) {
12 input += chunk;
13});
14
15var repo_token = process.env.CODECLIMATE_REPO_TOKEN;
16
17if(repo_token === undefined || repo_token.trim() === "") {
18 console.error("No CODECLIMATE_REPO_TOKEN found. A CODECLIMATE_REPO_TOKEN must be specified as an environment variable.");
19 process.exit(1);
20}
21
22process.stdin.on("end", function() {
23 var formatter = new Formatter();
24
25 formatter.format(input, function(err, json) {
26 if (err) {
27 console.error("A problem occurred parsing the lcov data", err);
28 } else {
29 if (process.env.CC_OUTPUT === "stdout") {
30 console.log(json);
31 } else {
32 json['repo_token'] = repo_token;
33 client.postJson(json);
34 }
35 }
36 });
37});