Skip to content

Commit 35ef161

Browse files
committed
fixes issue yiwang#2 - issue with really large json files
1 parent 8e09d62 commit 35ef161

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

bin/json2htmlcov

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ var str = fs.readFileSync(file, 'utf8');
1818
var fn = jade.compile(str, { filename: file });
1919

2020
// Read JSON from stdin
21-
var cov = JSON.parse(fs.readFileSync('/dev/stdin').toString());
21+
var chunks = [];
22+
process.stdin
23+
.on("data", function(chunk) { chunks.push(chunk); })
24+
.on("end", convertInput)
25+
.setEncoding("utf8");
2226

23-
// Dump HTML
24-
process.stdout.write(fn({
25-
cov: cov,
26-
coverageClass: coverageClass
27-
}));
27+
// Callback to do our conversion
28+
function convertInput() {
29+
var cov = JSON.parse(chunks.join(""));
30+
process.stdout.write(fn({
31+
cov: cov,
32+
coverageClass: coverageClass
33+
}));
34+
}

0 commit comments

Comments
 (0)