Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

coverage-collector

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coverage-collector - npm Package Compare versions

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
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc