[Pkg-javascript-commits] [node-coveralls] 03/332: working-ish!

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 3b464fafef5b6dc7a75873d1f3e636bcded8382c
Author: cainus <gregg at caines.ca>
Date:   Thu Mar 21 06:56:33 2013 -0700

    working-ish!
---
 index.js => bin/coveralls.js | 35 ++++++++++++-----------------------
 package.json                 |  5 ++++-
 2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/index.js b/bin/coveralls.js
similarity index 87%
rename from index.js
rename to bin/coveralls.js
index 66fbc95..567c0ee 100644
--- a/index.js
+++ b/bin/coveralls.js
@@ -1,6 +1,9 @@
+#!/usr/bin/env node
+
 var http = require('http');
 var request = require('request');
 var FormData = require('form-data');
+var TRAVIS_JOB_ID = process.env.TRAVIS_JOB_ID || 5675956 || 'unknown';
 
 process.stdin.resume();
 process.stdin.setEncoding('utf8');
@@ -18,7 +21,8 @@ process.stdin.on('end', function() {
 // cleans off any leading / trailing non-json garbage
 var trimToJson = function(inJson){
 	inJson = inJson.replace(/^[^\{]*/, '');
-	return inJson.replace(/\}[^\}]*$/, '}');
+	inJson = inJson.replace(/\}[^\}]*$/, '}');
+  return inJson;
 };
 
 var convertCoverageValue = function(val){
@@ -47,6 +51,7 @@ var convertFileObject = function(file){
 var convertJsonCovToCoveralls = function(data){
 	var files = data.files;
 	var postJson = {
+    service_job_id : TRAVIS_JOB_ID,
     service_name : "travis-ci",
 		source_files : []
 	};
@@ -81,26 +86,9 @@ var sendToCoveralls = function(postJson){
     console.log("response body: ", body);
   };
   var url = 'https://coveralls.io/api/v1/jobs';
-  //url = 'http://localhost:9090';
-  
-  //var r = request.post(url, done);
-  var form = new FormData();
-  //r.form();
-
-  form.append('json_file', str);
-  form.submit(url, function(err, res){
-    var body = '';
-
-    res.on('data', function(chunk) {
-      body += chunk;
-    });
-
-    res.on('end', function(chunk) {
-      if (chunk) body += chunk;
-      done(err, res, body);
-    });
-
-
+  //url = 'http://localhost:9090/';
+  request({url : url, method : 'POST', form : { json : str}}, function(err, response, body){
+    console.log(arguments);
   });
 };
 
@@ -108,10 +96,11 @@ var sendToCoveralls = function(postJson){
 var reportToCoveralls = function(inJson){
 	inJson = trimToJson(inJson);
 	var data = JSON.parse(inJson);
+  //data = { files : []};  //TODO remove this
 	console.log("successfully read json from json-cov");
 	postJson = convertJsonCovToCoveralls(data);
-	//console.log(JSON.stringify(postJson));
-	console.log("successfully converted input json to coveralls format");
+	console.log(JSON.stringify(postJson));
+	console.log("successfully converted input json to coveralls format: ", postJson);
   //makeLocalWebServer(function(){
     sendToCoveralls(postJson);
   //});
diff --git a/package.json b/package.json
index 0fac7c5..cf79a81 100644
--- a/package.json
+++ b/package.json
@@ -2,13 +2,16 @@
       "name": "coveralls",
       "description" : "taks json-cov output into stdin and POSTs to coveralls.io",
       "keywords" : ["coverage", "coveralls"], 
-      "version": "1.0.0",
+      "version": "1.1.0",
       "bugs": {
        "url": "https://github.com/cainus/node-coveralls/issues"
       },
       "scripts" : {
         "test" : "make test"
       },
+      "bin" : {
+        "coveralls" : "./bin/coveralls.js"
+      }
       "maintainers": [
         {
           "name": "Gregg Caines",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list