Skip to content

Commit

Permalink
0.2.0
Browse files Browse the repository at this point in the history
- removes commander
- improves readability
- adds a named function tapHTML for readability
- updates dependencies
  • Loading branch information
gabrielcsapo committed Dec 20, 2017
1 parent 22ea276 commit 6e08484
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 37 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 0.2.0 (12/20/2017)

- removes commander
- improves readability
- adds a named function `tapHTML` for readability
- updates dependencies

# 0.1.8 (11/13/2017)

- uses preact to reduce bundle size.
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ npm install tap-html --save-dev
```
Usage: tap-html [options]
Commands:
-h, --help, help Output usage information
-v, --version, version Output the version number
Options:
-o, --outFile [path] If instead of piping content you want it to be written to an html file locally please specify the relative path
```

By default tap parser should be pipeable as such:

-V, --version output the version number
-o, --out <file> if instead of piping content you want it to be written to an html file locally please specify the relative path
-h, --help output usage information
```
tape test/**.js | tap-html | html-cleanup > index.html
```

To generate a report running the following will create a file for you.

> This will generate a tap-html.html file
Expand Down
45 changes: 37 additions & 8 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,51 @@
#!/usr/bin/env node

const program = require('commander');
const path = require('path');

const parser = require('../');
const generate = require('../lib/generate');

program
.version(require('../package').version)
.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')
.parse(process.argv);
let program = {};
const args = process.argv.slice(2);

args.forEach((arg, i) => {
switch (arg) {
case '-v':
case '--version':
case 'version':
console.log(`v${require('../package.json').version}`); // eslint-disable-line
process.exit(0);
break;
case '-h':
case '--help':
case 'help':
console.log(`` + // eslint-disable-line
`
Usage: tap-html [options]
Commands:
-h, --help, help Output usage information
-v, --version, version Output the version number
Options:
-o, --outFile [path] If instead of piping content you want it to be written to an html file locally please specify the relative path
`);
process.exit(0);
break;
case '-o':
case '--out':
program['out'] = path.resolve(process.cwd(), args[i + 1]);
break;
}
});

const { out } = program;

process.stdin
.pipe(parser((res) => {
// generate the html report
if(program.out) {
if(out) {
// write the output to the specified location
generate(res, path.resolve(process.cwd(), program.out));
generate(res, out);
} else {
generate(res);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/example/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

23 changes: 11 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ const Parser = require('tap-parser');
const Through = require('through2');
const Duplexer = require('duplexer');

module.exports = (callback) => {
var tap = new Parser();
var out = Through.obj();
var dup = Duplexer(tap, out);
module.exports = function tapHTML(callback) {
const tap = new Parser();
const out = Through.obj();
const dup = Duplexer(tap, out);

var currentPlan = -1;
var currentAssertion = -1;
var data = [];
var plan = null;
let currentPlan = -1;
let currentAssertion = -1;
let data = [];
let plan = null;

var startTime = Date.now();
const startTime = Date.now();

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

function calculateTime(test) {
if (test.end) {
return;
}
if (test.end) return;

test.end = test.assertions[test.assertions.length - 1].end;
test.assertions.forEach((assertion) => {
assertion.start = test.start;
Expand Down
4 changes: 2 additions & 2 deletions lib/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = (report, outfile) => {
// this should be configurable
const output = path.dirname(outfile) || process.cwd();

var compiler = webpack({
const compiler = webpack({
entry: path.resolve(__dirname, '..', 'src', 'index.js'),
context: path.resolve(__dirname, '..'),
output: {
Expand Down Expand Up @@ -85,7 +85,7 @@ module.exports = (report, outfile) => {
compiler.outputFileSystem = msf;
}

compiler.run(function(err) {
compiler.run((err) => {
if (err) console.error(err); // eslint-disable-line
if (outfile) {
try {
Expand Down
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "tap-html",
"version": "0.1.8",
"version": "0.2.0",
"description": "📊 an html tap reporter",
"author": "Gabriel J. Csapo <[email protected]>",
"license": "ISC",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/gabrielcsapo/tap-html.git"
Expand All @@ -29,34 +29,33 @@
"babel-loader": "^7.1.1",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"commander": "^2.12.2",
"css-loader": "^0.28.4",
"duplexer": "^0.1.1",
"file-loader": "^1.1.5",
"file-loader": "^1.1.6",
"font-awesome": "^4.7.0",
"html-webpack-inline-source-plugin": "0.0.9",
"html-webpack-plugin": "^2.29.0",
"memory-fs": "^0.4.1",
"preact": "^8.2.6",
"preact": "^8.2.7",
"preact-compat": "^3.17.0",
"prop-types": "^15.6.0",
"psychic-ui": "^1.0.7",
"style-loader": "^0.19.0",
"style-loader": "^0.19.1",
"tap-parser": "^7.0.0",
"through2": "^2.0.3",
"url-loader": "^0.6.2",
"webpack": "^3.9.1"
"webpack": "^3.10.0"
},
"devDependencies": {
"@storybook/react": "^3.2.16",
"@storybook/react": "^3.2.18",
"babel-minify-webpack-plugin": "^0.2.0",
"babel-polyfill": "^6.26.0",
"eslint": "^4.12.1",
"eslint": "^4.13.1",
"eslint-plugin-react": "^7.5.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"tap": "^11.0.0",
"tape": "^4.6.3",
"tryitout": "^1.2.0"
"tryitout": "^1.2.2"
}
}

0 comments on commit 6e08484

Please sign in to comment.