tap-parser
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -9,3 +9,11 @@ #!/usr/bin/env node | ||
var json = null | ||
var bail = false | ||
var preserveWhitespace = true | ||
var omitVersion = false | ||
function version () { | ||
console.log(require('../package.json').version) | ||
process.exit(0) | ||
} | ||
args.forEach(function (arg, i) { | ||
@@ -20,7 +28,18 @@ if (arg === '-j') { | ||
if (arg === '-t' || arg === '--tap') | ||
if (arg === '-v' || arg === '--version') | ||
version() | ||
else if (arg === '-o' || arg === '--omit-version') | ||
omitVersion = true | ||
else if (arg === '-w' || arg === '--ignore-all-whitespace') | ||
preserveWhitespace = false | ||
else if (arg === '-b' || arg === '--bail') | ||
bail = true | ||
else if (arg === '-t' || arg === '--tap') | ||
json = 'tap' | ||
if (arg === '-h' || arg === '--help') | ||
else if (arg === '-l' || arg === '--lines') | ||
json = 'lines' | ||
else if (arg === '-h' || arg === '--help') | ||
usage() | ||
else | ||
console.error('Unrecognized arg: %j', arg) | ||
}) | ||
@@ -31,17 +50,27 @@ | ||
Usage: | ||
tap-parser [-j [<indent>] | --json[=indent] | -t | --tap] | ||
tap-parser <options> | ||
Parses TAP data from stdin, and outputs an object representing | ||
the data found in the TAP stream to stdout. | ||
Parses TAP data from stdin, and outputs the parsed result | ||
in the format specified by the options. Default output is | ||
uses node's `util.format()` method. | ||
If there are any failures in the TAP stream, then exits with a | ||
non-zero status code. | ||
Options: | ||
Data is output by default using node's `util.format()` method, but | ||
JSON can be specified using the `-j` or `--json` flag with a number | ||
of spaces to use as the indent (default=2). | ||
-j [<indent>] | --json[=indent] | ||
Output event data as JSON with the specified indentation (default=2) | ||
If you pass -t or --tap as an argument, then the output will be a | ||
re-imagined synthesized purified idealized manufactured TAP stream, | ||
rather than JSON or util.format. | ||
-t | --tap | ||
Output data as reconstituted TAP based on parsed results | ||
-l | --lines | ||
Output each parsed line as it is recognized by the parser | ||
-b | --bail | ||
Emit a `Bail out!` at the first failed test point encountered | ||
-w | --ignore-all-whitespace | ||
Skip over blank lines outside of YAML blocks | ||
-o | --omit-version | ||
Ignore the `TAP version 13` line at the start of tests | ||
*/}.toString().split('\n').slice(1, -1).join('\n')) | ||
@@ -110,10 +139,21 @@ | ||
var parser = new Parser() | ||
var options = { | ||
bail: bail, | ||
preserveWhitespace: preserveWhitespace, | ||
omitVersion: omitVersion | ||
} | ||
var parser = new Parser(options) | ||
var events = etoa(parser, [ 'pipe', 'unpipe', 'prefinish', 'finish', 'line' ]) | ||
process.stdin.pipe(parser) | ||
process.on('exit', function () { | ||
console.log(format(events)) | ||
if (!parser.ok) | ||
process.exit(1) | ||
}) | ||
if (json === 'lines') | ||
parser.on('line', function (l) { | ||
process.stdout.write(l) | ||
}) | ||
else | ||
process.on('exit', function () { | ||
console.log(format(events)) | ||
if (!parser.ok) | ||
process.exit(1) | ||
}) |
{ | ||
"name": "tap-parser", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "parse the test anything protocol", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
33432
795
221