coverage-collector
Advanced tools
Comparing version 0.0.3 to 0.0.4
59
index.js
@@ -5,29 +5,50 @@ var http = require("http"); | ||
var server; | ||
function start(options){ | ||
options=options||{}; | ||
port=options.port||process.env['COLLECTOR_PORT']||3001; | ||
var istanbul=require('istanbul'); | ||
var collector = new istanbul.Collector(); | ||
function start(options) { | ||
options = options || {}; | ||
port = options.port || process.env['COLLECTOR_PORT'] || 3001; | ||
var app = connect(); | ||
global._data=global._data||[]; | ||
app.use(bodyParser({limit:'50mb'})); | ||
app.use(require('./list')()); | ||
app.use(require('./receive')()); | ||
app.use(function(req, res, next){ | ||
if(req.url.substr(1)==='done' && req.method.toLowerCase()==='get'){ | ||
app.use(bodyParser({ | ||
limit: '50mb' | ||
})); | ||
app.use(function serveCoverageHandle(req, res, next) { | ||
if (req.url.substr(1) === 'data' && req.method.toLowerCase() === 'get') { | ||
res.setHeader("Content-Type", "application/javascript"); | ||
res.statusCode = 200; | ||
res.end(JSON.stringify(collector.getFinalCoverage())); | ||
} else { | ||
next(); | ||
} | ||
}); | ||
app.use(function receive(req, res, next) { | ||
if (req.url.substr(1) === 'data' && req.method.toLowerCase() === 'post') { | ||
collector.add(req.body); | ||
//global._data.push(req.body); | ||
res.statusCode = 204; | ||
res.end(); | ||
} else { | ||
next(); | ||
} | ||
}); | ||
app.use(function(req, res, next) { | ||
if (req.url.substr(1) === 'done' && req.method.toLowerCase() === 'get') { | ||
console.log("Shutdown requested"); | ||
res.statusCode=204; | ||
res.statusCode = 204; | ||
res.end(); | ||
if(server){ | ||
if (server) { | ||
server.close(); | ||
server=null; | ||
server = null; | ||
} | ||
}else{ | ||
collector.dispose(); | ||
} else { | ||
next(); | ||
} | ||
}); | ||
app.use(function(req, res){ | ||
res.end(); | ||
}); | ||
server=http.createServer(app).listen(port); | ||
}); | ||
app.use(function(req, res) { | ||
res.end(); | ||
}); | ||
server = http.createServer(app).listen(port); | ||
console.log("Collector started on port %d", port); | ||
} | ||
module.exports=start; | ||
module.exports = start; |
{ | ||
"name": "coverage-collector", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A simple server for collecting code coverage objects", | ||
@@ -25,4 +25,5 @@ "main": "index.js", | ||
"connect": "~2.14.4", | ||
"body-parser": "~1.0.1" | ||
"body-parser": "~1.0.1", | ||
"istanbul": "~0.2.7" | ||
} | ||
} |
@@ -5,1 +5,21 @@ coverage-collector | ||
a simple server for collection of code coverage objects | ||
###Starting the server | ||
``` | ||
var collector=require('coverage-collector'); | ||
collector({port:3001}); | ||
``` | ||
###Collecting data | ||
```curl -X POST http://localhost:3001/data -H "Content-Type: application/json" -d '{"coverage":"object"}'``` | ||
###Retrieving collected data | ||
```curl -X GET http://localhost:3001/data``` | ||
returns | ||
```[{"coverage":"object"}]``` | ||
###Stopping the server | ||
```curl -X GET http://localhost:3001/done``` | ||
###Contributing | ||
If you have issues or you want to discuss other use cases, feel free to open an issue or send a pull request on github |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14550
25
3
5
53
+ Addedistanbul@~0.2.7
+ Addedabbrev@1.0.9(transitive)
+ Addedamdefine@1.0.1(transitive)
+ Addedargparse@1.0.10(transitive)
+ Addedasync@0.2.100.9.2(transitive)
+ Addedescodegen@1.3.3(transitive)
+ Addedesprima@1.1.11.2.54.0.1(transitive)
+ Addedestraverse@1.5.1(transitive)
+ Addedesutils@1.0.0(transitive)
+ Addedfileset@0.1.8(transitive)
+ Addedglob@3.2.11(transitive)
+ Addedhandlebars@1.3.0(transitive)
+ Addedistanbul@0.2.16(transitive)
+ Addedjs-yaml@3.14.1(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.3.00.4.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addednopt@3.0.6(transitive)
+ Addedoptimist@0.3.7(transitive)
+ Addedresolve@0.7.4(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addedsource-map@0.1.43(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addeduglify-js@2.3.6(transitive)
+ Addedwhich@1.0.9(transitive)
+ Addedwordwrap@0.0.3(transitive)