Skip to content

Commit

Permalink
Merge from command line
Browse files Browse the repository at this point in the history
and bump version to 1.0.4
  • Loading branch information
Crisci, Fabio | Piuccio | TRVDD committed Sep 27, 2013
1 parent c5451f9 commit bf70ddf
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ Where `id` is the report name. It's possible to merge more than two reports addi

The returned JSON has the same structure of a single report.

It's also possible to merge multiple reports from the command line

node merge.js -o destination_report.json report1.json report2.json [... reportN.json]


## Interpreters

node-coverage has a modular system for interpreting and instrumenting JavaScript files. This allows you to create an interpreter for any type of file.
Expand Down
1 change: 1 addition & 0 deletions instrument.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
var fileSystem = require("./lib/fileSystem");
var argv = require("optimist")
.usage("Instrument a folder for code coverage.\n$0 source destination")
Expand Down
36 changes: 36 additions & 0 deletions merge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node
var fs = require("fs");
var report = require("./lib/report");
var argv = require("optimist")
.usage("Merge coverage reports.\n$0 -o destination source [source ...]")
.boolean("h").alias("h", "help")
.alias("o", "output").describe("o", "Output file.")
.argv;


if (argv.h) {
help(true);
} else if (!argv.o) {
console.error("Output file is mandatory.");
help();
} else if (argv._.length < 2) {
console.error("Output file is mandatory.");
help();
} else {
good(argv.o, argv._);
}

function help (cleanExit) {
require("optimist").showHelp();
if (cleanExit) {
process.exit(0);
}
}

function good (destination, files) {
var reports = [];
files.forEach(function (file) {
reports.push(JSON.parse(fs.readFileSync(file)));
});
fs.writeFileSync(destination, JSON.stringify(report.mergeReports(reports)));
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"name": "node-coverage",
"description": "node-coverage is a tool that measures code coverage of JavaScript application.",
"version": "1.0.3",
"version": "1.0.4",
"homepage": "https://github.com/piuccio/node-coverage",
"repository": {
"type": "git",
Expand All @@ -25,7 +25,8 @@
"main": "./index",
"bin": {
"node-coverage-instrument": "./instrument.js",
"node-coverage": "./server.js"
"node-coverage": "./server.js",
"node-coverage-merge": "./merge.js"
},
"dependencies": {
"optimist": "~0.3.1",
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
var fs = require("fs");
var argv = require("optimist")
.usage("Start a simple web server to instrument JS code.")
Expand Down

0 comments on commit bf70ddf

Please sign in to comment.