Comparing version 0.0.0 to 0.0.1
16
index.js
@@ -12,3 +12,3 @@ var Module = require('module'); | ||
if (lines.length > 0) { | ||
lines[0] = 'if (!__cov["' + filename + '"]) {__cov["' + filename + '"] = { 0: true}; }' + lines[0]; | ||
lines[0] = 'if (!__cov["' + filename + '"]) {__cov["' + filename + '"] = { 0: 1}; }' + lines[0]; | ||
} | ||
@@ -71,3 +71,3 @@ | ||
var html = '<div class="row">'; | ||
html += '<div class="span3">'; | ||
html += '<div class="span5">'; | ||
html += '<a href="#' + id + | ||
@@ -113,3 +113,3 @@ '" class="filename" name="' + id + | ||
fs.writeFileSync(cwd + '/coverage.html', fs.readFileSync(path.join(__dirname, 'coverage.html')).toString().replace('CODE', html)); | ||
fs.writeFileSync(cwd + '/coverage.html', fs.readFileSync(path.join(__dirname, 'coverage.html')).toString().replace('CODE', html.replace(/\$'/g, '$\''))); | ||
console.log('===================='); | ||
@@ -124,3 +124,3 @@ console.log('TOTAL COVERAGE:', Math.round((total_covered / (total_lines)) * 100) + '%'); | ||
var all = { 'C': comments, 'S': strings, 'R': res }; | ||
var safe = { '<': '<', '>': '>', '&': '&' }; | ||
var safe = { '<': '<', '>': '>', '&': '&' }; | ||
@@ -132,8 +132,6 @@ return code | ||
{ var l=comments.length; comments.push(m); return '~~~C'+l+'~~~'; }) | ||
.replace(/\/\/.*/g, function(m, f) | ||
{ var l=comments.length; comments.push(m); return '~~~C'+l+'~~~'; }) | ||
.replace(/([^\\])((?:'(?:\\'|[^'])*')|(?:"(?:\\"|[^"])*"))/g, function(m, f, s) | ||
.replace(/([^\\])((?:'(?:\\'|[^'\n])*')|(?:"(?:\\"|[^"\n])*"))/g, function(m, f, s) | ||
{ var l=strings.length; strings.push(s); return f+'~~~S'+l+'~~~'; }) | ||
.replace(/\/(\\\/|[^\/\n])*\/[gim]{0,3}/g, function(m) | ||
{ var l=res.length; res.push(m); return '~~~R'+l+'~~~'; }) | ||
// .replace(/\/(\\\/|[^\/\n])*\/[gim]{0,3}/g, function(m) | ||
// { var l=res.length; res.push(m); return '~~~R'+l+'~~~'; }) | ||
.replace(/(var|function|typeof|new|return|if|for|in|while|break|do|continue|switch|case)([^a-z0-9\$_])/gi, | ||
@@ -140,0 +138,0 @@ '<span class="kwrd">$1</span>$2') |
{ | ||
"author": "Anatoliy Chakkaev <rpm1602@gmail.com>", | ||
"name": "semicov", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "dependencies": {}, |
@@ -1,2 +0,2 @@ | ||
Crappy test coverage tool. It just works. It also can generate some shitty report. | ||
Test coverage tool. It can generate nifty html report. | ||
@@ -7,2 +7,16 @@ ## Installation | ||
## It works only... | ||
...only if your code has semicolons. And it will break badly-written javascript: | ||
```javascript | ||
if (condition) doSomething(); | ||
else doSomethingElse(); | ||
``` | ||
So, basically it should work very well for any code passed following [jslint](http://www.jslint.com) validations: | ||
- [semicolons](http://www.jslint.com/lint.html#semicolon) | ||
- [required blocks](http://www.jslint.com/lint.html#required) | ||
## Usage | ||
@@ -16,7 +30,5 @@ | ||
process.on('exit', function () { | ||
require('semicov').report(); | ||
}); | ||
process.on('exit', require('semicov').report); | ||
And it will generate shitty report for you. | ||
And it will generate `./coverage.html` for you. | ||
8359
33
132