Skip to content

Commit 6e08484

Browse files
committed
0.2.0
- removes commander - improves readability - adds a named function tapHTML for readability - updates dependencies
1 parent 22ea276 commit 6e08484

File tree

8 files changed

+79
-37
lines changed

8 files changed

+79
-37
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 0.2.0 (12/20/2017)
2+
3+
- removes commander
4+
- improves readability
5+
- adds a named function `tapHTML` for readability
6+
- updates dependencies
7+
18
# 0.1.8 (11/13/2017)
29

310
- uses preact to reduce bundle size.

README.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,21 @@ npm install tap-html --save-dev
2121
```
2222
Usage: tap-html [options]
2323
24+
Commands:
25+
-h, --help, help Output usage information
26+
-v, --version, version Output the version number
2427
2528
Options:
29+
-o, --outFile [path] If instead of piping content you want it to be written to an html file locally please specify the relative path
30+
```
31+
32+
By default tap parser should be pipeable as such:
2633

27-
-V, --version output the version number
28-
-o, --out <file> if instead of piping content you want it to be written to an html file locally please specify the relative path
29-
-h, --help output usage information
3034
```
35+
tape test/**.js | tap-html | html-cleanup > index.html
36+
```
37+
38+
To generate a report running the following will create a file for you.
3139

3240
> This will generate a tap-html.html file
3341

bin/index.js

+37-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
11
#!/usr/bin/env node
22

3-
const program = require('commander');
43
const path = require('path');
5-
64
const parser = require('../');
75
const generate = require('../lib/generate');
86

9-
program
10-
.version(require('../package').version)
11-
.option('-o, --out <file>', 'if instead of piping content you want it to be written to an html file locally please specify the relative path')
12-
.parse(process.argv);
7+
let program = {};
8+
const args = process.argv.slice(2);
9+
10+
args.forEach((arg, i) => {
11+
switch (arg) {
12+
case '-v':
13+
case '--version':
14+
case 'version':
15+
console.log(`v${require('../package.json').version}`); // eslint-disable-line
16+
process.exit(0);
17+
break;
18+
case '-h':
19+
case '--help':
20+
case 'help':
21+
console.log(`` + // eslint-disable-line
22+
`
23+
Usage: tap-html [options]
24+
25+
Commands:
26+
-h, --help, help Output usage information
27+
-v, --version, version Output the version number
28+
29+
Options:
30+
-o, --outFile [path] If instead of piping content you want it to be written to an html file locally please specify the relative path
31+
`);
32+
process.exit(0);
33+
break;
34+
case '-o':
35+
case '--out':
36+
program['out'] = path.resolve(process.cwd(), args[i + 1]);
37+
break;
38+
}
39+
});
40+
41+
const { out } = program;
1342

1443
process.stdin
1544
.pipe(parser((res) => {
1645
// generate the html report
17-
if(program.out) {
46+
if(out) {
1847
// write the output to the specified location
19-
generate(res, path.resolve(process.cwd(), program.out));
48+
generate(res, out);
2049
} else {
2150
generate(res);
2251
}

docs/example/index.html

+1-1
Large diffs are not rendered by default.

docs/index.html

+1-1
Large diffs are not rendered by default.

index.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ const Parser = require('tap-parser');
22
const Through = require('through2');
33
const Duplexer = require('duplexer');
44

5-
module.exports = (callback) => {
6-
var tap = new Parser();
7-
var out = Through.obj();
8-
var dup = Duplexer(tap, out);
5+
module.exports = function tapHTML(callback) {
6+
const tap = new Parser();
7+
const out = Through.obj();
8+
const dup = Duplexer(tap, out);
99

10-
var currentPlan = -1;
11-
var currentAssertion = -1;
12-
var data = [];
13-
var plan = null;
10+
let currentPlan = -1;
11+
let currentAssertion = -1;
12+
let data = [];
13+
let plan = null;
1414

15-
var startTime = Date.now();
15+
const startTime = Date.now();
1616

1717
tap.on('comment', (res) => {
1818
if (!plan) {
@@ -89,9 +89,8 @@ module.exports = (callback) => {
8989
data = data.filter((d) => d > '');
9090

9191
function calculateTime(test) {
92-
if (test.end) {
93-
return;
94-
}
92+
if (test.end) return;
93+
9594
test.end = test.assertions[test.assertions.length - 1].end;
9695
test.assertions.forEach((assertion) => {
9796
assertion.start = test.start;

lib/generate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = (report, outfile) => {
1111
// this should be configurable
1212
const output = path.dirname(outfile) || process.cwd();
1313

14-
var compiler = webpack({
14+
const compiler = webpack({
1515
entry: path.resolve(__dirname, '..', 'src', 'index.js'),
1616
context: path.resolve(__dirname, '..'),
1717
output: {
@@ -85,7 +85,7 @@ module.exports = (report, outfile) => {
8585
compiler.outputFileSystem = msf;
8686
}
8787

88-
compiler.run(function(err) {
88+
compiler.run((err) => {
8989
if (err) console.error(err); // eslint-disable-line
9090
if (outfile) {
9191
try {

package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "tap-html",
3-
"version": "0.1.8",
3+
"version": "0.2.0",
44
"description": "📊 an html tap reporter",
55
"author": "Gabriel J. Csapo <[email protected]>",
6-
"license": "ISC",
6+
"license": "MIT",
77
"repository": {
88
"type": "git",
99
"url": "git+https://github.com/gabrielcsapo/tap-html.git"
@@ -29,34 +29,33 @@
2929
"babel-loader": "^7.1.1",
3030
"babel-preset-env": "^1.6.1",
3131
"babel-preset-react": "^6.24.1",
32-
"commander": "^2.12.2",
3332
"css-loader": "^0.28.4",
3433
"duplexer": "^0.1.1",
35-
"file-loader": "^1.1.5",
34+
"file-loader": "^1.1.6",
3635
"font-awesome": "^4.7.0",
3736
"html-webpack-inline-source-plugin": "0.0.9",
3837
"html-webpack-plugin": "^2.29.0",
3938
"memory-fs": "^0.4.1",
40-
"preact": "^8.2.6",
39+
"preact": "^8.2.7",
4140
"preact-compat": "^3.17.0",
4241
"prop-types": "^15.6.0",
4342
"psychic-ui": "^1.0.7",
44-
"style-loader": "^0.19.0",
43+
"style-loader": "^0.19.1",
4544
"tap-parser": "^7.0.0",
4645
"through2": "^2.0.3",
4746
"url-loader": "^0.6.2",
48-
"webpack": "^3.9.1"
47+
"webpack": "^3.10.0"
4948
},
5049
"devDependencies": {
51-
"@storybook/react": "^3.2.16",
50+
"@storybook/react": "^3.2.18",
5251
"babel-minify-webpack-plugin": "^0.2.0",
5352
"babel-polyfill": "^6.26.0",
54-
"eslint": "^4.12.1",
53+
"eslint": "^4.13.1",
5554
"eslint-plugin-react": "^7.5.1",
5655
"react": "^16.2.0",
5756
"react-dom": "^16.2.0",
5857
"tap": "^11.0.0",
5958
"tape": "^4.6.3",
60-
"tryitout": "^1.2.0"
59+
"tryitout": "^1.2.2"
6160
}
6261
}

0 commit comments

Comments
 (0)