tap-parser
Advanced tools
Comparing version 11.0.2 to 12.0.0
191
bin/cmd.js
#!/usr/bin/env node | ||
const Parser = require('../') | ||
const etoa = require('events-to-array') | ||
// not sure why all the c8 ignore is needed, but it's marking | ||
// cases and conditionals as uncovered branches, when it's clear | ||
// that they're actually being run. | ||
const { Parser } = require('../') | ||
const util = require('util') | ||
@@ -15,10 +18,14 @@ | ||
function version () { | ||
/* c8 ignore start */ | ||
function version() { | ||
console.log(require('../package.json').version) | ||
process.exit(0) | ||
} | ||
/* c8 ignore stop */ | ||
for (let i = 0; i < args.length; i++) { | ||
const arg = args[i] | ||
/* c8 ignore start */ | ||
if (arg === '-j') { | ||
/* c8 ignore stop */ | ||
const val = +args[i + 1] | ||
@@ -28,15 +35,19 @@ if (val >= 0) { | ||
i += 1 | ||
} else | ||
json = 2 | ||
} else json = 2 | ||
continue | ||
/* c8 ignore start */ | ||
} else { | ||
/* c8 ignore stop */ | ||
const m = arg.match(/^--json(?:=([0-9]+))?$/) | ||
/* c8 ignore start */ | ||
if (m) { | ||
if (+m[1] >= 0) | ||
/* c8 ignore stop */ | ||
if (+m[1] >= 0) { | ||
json = +m[1] | ||
else if (+args[i + 1] >= 0) { | ||
} else if (+args[i + 1] >= 0) { | ||
json = +args[i + 1] | ||
i += 1 | ||
} else | ||
} else { | ||
json = 2 | ||
} | ||
continue | ||
@@ -46,33 +57,89 @@ } | ||
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 === '-B' || arg === '--no-bail') | ||
bail = false | ||
else if (arg === '-t' || arg === '--tap') | ||
json = 'tap' | ||
else if (arg === '-l' || arg === '--lines') | ||
json = 'lines' | ||
else if (arg === '-h' || arg === '--help') | ||
usage() | ||
else if (arg === '-f' || arg === '--flat') | ||
flat = true | ||
else if (arg === '-F' || arg === '--no-flat') | ||
flat = false | ||
else if (arg === '--strict') | ||
strict = true | ||
else if (arg === '--no-strict') | ||
strict = false | ||
else if (arg === '-s' || arg === '--silent') | ||
json = 'silent' | ||
else | ||
console.error('Unrecognized arg: %j', arg) | ||
switch (arg) { | ||
/* c8 ignore start */ | ||
case '-v': | ||
case '--version': | ||
/* c8 ignore stop */ | ||
version() | ||
break | ||
/* c8 ignore start */ | ||
case '-o': | ||
case '--omit-version': | ||
/* c8 ignore stop */ | ||
omitVersion = true | ||
break | ||
/* c8 ignore start */ | ||
case '-w': | ||
case '--ignore-all-whitespace': | ||
/* c8 ignore stop */ | ||
preserveWhitespace = false | ||
break | ||
/* c8 ignore start */ | ||
case '--bail': | ||
case '-b': | ||
/* c8 ignore stop */ | ||
bail = true | ||
break | ||
/* c8 ignore start */ | ||
case '--no-bail': | ||
case '-B': | ||
/* c8 ignore stop */ | ||
bail = false | ||
break | ||
/* c8 ignore start */ | ||
case '-t': | ||
case '--tap': | ||
/* c8 ignore stop */ | ||
json = 'tap' | ||
break | ||
/* c8 ignore start */ | ||
case '-h': | ||
case '--help': | ||
/* c8 ignore stop */ | ||
usage() | ||
break | ||
/* c8 ignore start */ | ||
case '-l': | ||
case '--lines': | ||
/* c8 ignore stop */ | ||
json = 'lines' | ||
break | ||
/* c8 ignore start */ | ||
case '-f': | ||
case '--flat': | ||
/* c8 ignore stop */ | ||
flat = true | ||
break | ||
/* c8 ignore start */ | ||
case '-F': | ||
case '--no-flat': | ||
/* c8 ignore stop */ | ||
flat = false | ||
break | ||
/* c8 ignore start */ | ||
case '--strict': | ||
/* c8 ignore stop */ | ||
strict = true | ||
break | ||
/* c8 ignore start */ | ||
case '--no-strict': | ||
/* c8 ignore stop */ | ||
strict = false | ||
break | ||
/* c8 ignore start */ | ||
case '-s': | ||
case '--silent': | ||
/* c8 ignore stop */ | ||
json = 'silent' | ||
break | ||
/* c8 ignore start */ | ||
default: | ||
/* c8 ignore stop */ | ||
console.error('Unrecognized arg: %j', arg) | ||
break | ||
} | ||
} | ||
function usage () { | ||
/* c8 ignore start */ | ||
function usage() { | ||
console.log(`Usage: | ||
@@ -114,3 +181,3 @@ tap-parser <options> | ||
-o | --omit-version | ||
Ignore the \`TAP version 13\` line at the start of tests | ||
Ignore the \`TAP version 13\` or \`TAP version 14\` line at the start of tests | ||
@@ -128,18 +195,20 @@ --strict | ||
// prevent the EPIPE upstream when the data drops on the floor | ||
/* istanbul ignore else */ | ||
if (!process.stdin.isTTY) | ||
if (!process.stdin.isTTY) { | ||
process.stdin.resume() | ||
} | ||
process.exit() | ||
} | ||
/* c8 ignore stop */ | ||
const yaml = require('tap-yaml') | ||
function format (msg) { | ||
if (json === 'tap') | ||
function format(msg) { | ||
if (json === 'tap') { | ||
return Parser.stringify(msg, options) | ||
else if (json !== null) | ||
/* c8 ignore start */ | ||
} else if (json !== null) { | ||
/* c8 ignore stop */ | ||
return JSON.stringify(msg, null, +json) | ||
else | ||
} else { | ||
return util.inspect(msg, null, Infinity) | ||
} | ||
} | ||
@@ -155,18 +224,26 @@ | ||
if (json === 'lines' || json === 'silent') { | ||
/* c8 ignore start */ | ||
if (json === 'silent' || json === 'lines') { | ||
/* c8 ignore stop */ | ||
const parser = new Parser(options) | ||
if (json === 'lines') | ||
if (json === 'lines') { | ||
parser.on('line', l => process.stdout.write(l)) | ||
parser.on('complete', () => process.exitCode = parser.ok ? 0 : 1) | ||
} | ||
parser.on('complete', () => (process.exitCode = parser.ok ? 0 : 1)) | ||
process.stdin.pipe(parser) | ||
} else { | ||
const input = [] | ||
process.stdin.on('data', c => input.push(c)).on('end', () => { | ||
const buf = Buffer.concat(input) | ||
const result = Parser.parse(buf, options) | ||
const summary = result[ result.length - 1 ] | ||
console.log(format(result)) | ||
if (summary[0] !== 'complete' || !summary[1].ok) | ||
process.exitCode = 1 | ||
}) | ||
process.stdin | ||
.on('data', c => input.push(c)) | ||
.on('end', () => { | ||
const buf = Buffer.concat(input) | ||
const result = Parser.parse(buf, options) | ||
const summary = result[result.length - 1] | ||
console.log(format(result)) | ||
/* c8 ignore start */ | ||
if (summary[0] !== 'complete' || !summary[1].ok) { | ||
/* c8 ignore stop */ | ||
process.exitCode = 1 | ||
} | ||
}) | ||
} |
{ | ||
"name": "tap-parser", | ||
"version": "11.0.2", | ||
"version": "12.0.0", | ||
"description": "parse the test anything protocol", | ||
"main": "index.js", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/mjs/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/mjs/index.js", | ||
"require": "./dist/cjs/index.js" | ||
} | ||
}, | ||
"bin": { | ||
@@ -10,29 +17,33 @@ "tap-parser": "bin/cmd.js" | ||
"dependencies": { | ||
"events-to-array": "^1.0.1", | ||
"minipass": "^3.1.6", | ||
"tap-yaml": "^1.0.0" | ||
"events-to-array": "^2.0.3", | ||
"tap-yaml": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/glob": "^8.0.0", | ||
"@types/node": "^18.11.9", | ||
"@types/tap": "^15.0.6", | ||
"c8": "^7.12.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"glob": "^7.0.5", | ||
"tap": "^16.0.0" | ||
"minipass": "^3.3.4", | ||
"prettier": "^2.7.1", | ||
"tap": "^16.3.0", | ||
"ts-node": "^10.9.1", | ||
"typedoc": "^0.23.20", | ||
"typescript": "^4.7.4" | ||
}, | ||
"scripts": { | ||
"snap": "tap", | ||
"test": "tap", | ||
"snap": "c8 tap", | ||
"test": "c8 tap", | ||
"preprepare": "rm -rf dist", | ||
"prepare": "tsc -p tsconfig-cjs.json && tsc -p tsconfig-esm.json", | ||
"postprepare": "bash fixup.sh", | ||
"pretest": "npm run prepare", | ||
"presnap": "npm run prepare", | ||
"format": "prettier --write . --loglevel warn", | ||
"preversion": "npm test", | ||
"postversion": "npm publish", | ||
"postpublish": "git push origin --follow-tags" | ||
"prepublishOnly": "git push origin --follow-tags", | ||
"typedoc": "typedoc --tsconfig tsconfig-esm.json ./src/*.ts" | ||
}, | ||
"testling": { | ||
"files": "test/*.js", | ||
"browsers": [ | ||
"ie/6..latest", | ||
"chrome/10", | ||
"chrome/latest", | ||
"firefox/3.5", | ||
"firefox/latest", | ||
"opera/latest", | ||
"safari/latest" | ||
] | ||
}, | ||
"repository": { | ||
@@ -50,15 +61,32 @@ "type": "git", | ||
"files": [ | ||
"index.js", | ||
"bin/cmd.js" | ||
"dist", | ||
"bin" | ||
], | ||
"prettier": { | ||
"semi": false, | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"jsxSingleQuote": false, | ||
"bracketSameLine": true, | ||
"arrowParens": "avoid", | ||
"endOfLine": "lf" | ||
}, | ||
"eslintIgnore": [ | ||
"/node_modules", | ||
"/dist" | ||
], | ||
"tap": { | ||
"check-coverage": true, | ||
"coverage-map": "map.js" | ||
"coverage": false, | ||
"node-arg": [ | ||
"--no-warnings", | ||
"--loader", | ||
"ts-node/esm" | ||
], | ||
"ts": false | ||
}, | ||
"nyc": { | ||
"hookRunInThisContext": true | ||
}, | ||
"engines": { | ||
"node": ">= 8" | ||
"node": ">= 12" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196129
2
66
2901
422
12
1
+ Addedevents-to-array@2.0.3(transitive)
- Removedminipass@^3.1.6
- Removedevents-to-array@1.1.2(transitive)
- Removedminipass@3.3.6(transitive)
- Removedyallist@4.0.0(transitive)
Updatedevents-to-array@^2.0.3
Updatedtap-yaml@^1.0.2