Comparing version 0.3.2 to 0.3.3
@@ -9,2 +9,12 @@ # `tap-arc` Changelog | ||
## [0.3.3] - 2022-03-25 | ||
### Fixed | ||
- correctly display multi-(c)hunk diffs | ||
### Removed | ||
- verbose option no longer affects diff print | ||
## [0.3.2] - 2022-03-24 | ||
@@ -11,0 +21,0 @@ |
30
index.js
@@ -14,3 +14,3 @@ #!/usr/bin/env node | ||
green, | ||
inverse, | ||
italic, | ||
red, | ||
@@ -70,4 +70,3 @@ underline, | ||
function makeDiff (lhs, rhs, options) { | ||
const { verbose } = options | ||
function makeDiff (lhs, rhs) { | ||
const msg = [] | ||
@@ -103,16 +102,15 @@ let isJson = true | ||
if (!compared.match) { | ||
// capture diff after line: "@@ -n,n +n,n @@" | ||
const diff = verbose | ||
? compared.diff | ||
: compared.diff.split(/^(?:@@).*(?:@@)$/gm)[1] | ||
// remove leading header lines | ||
let diff = compared.diff.split('\n') | ||
diff = diff.slice(2, diff.length - 1) | ||
for (const line of diff.split('\n')) { | ||
if (line.indexOf('--- ') === 0) | ||
msg.push(inverse(red(line))) | ||
else if (line.indexOf('+++ ') === 0) | ||
msg.push(inverse(green(line))) | ||
else if (line.charAt(0) === '-') | ||
for (const line of diff) { | ||
const char0 = line.charAt(0) | ||
if (char0 === '-') | ||
msg.push(red(line)) | ||
else if (line.charAt(0) === '+') | ||
else if (char0 === '+') | ||
msg.push(green(line)) | ||
else if (char0 === '@') | ||
msg.push(italic(dim(line))) | ||
else | ||
@@ -171,7 +169,7 @@ msg.push(line) | ||
if (typeof expected === 'string' && typeof actual === 'string') { | ||
msg = [ ...msg, ...makeDiff(actual, expected, options) ] | ||
msg = [ ...msg, ...makeDiff(actual, expected) ] | ||
} | ||
else if (typeof expected === 'object' && typeof actual === 'object') { | ||
// probably an array | ||
msg = [ ...msg, ...makeDiff(actual, expected, options) ] | ||
msg = [ ...msg, ...makeDiff(actual, expected) ] | ||
} | ||
@@ -178,0 +176,0 @@ else if (typeof expected === 'number' || typeof actual === 'number') { |
@@ -5,3 +5,3 @@ { | ||
"author": "tbeseda", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"license": "Apache-2.0", | ||
@@ -8,0 +8,0 @@ "main": "index.js", |
# `tap-arc` | ||
> A small (~24kB) [TAP](https://testanything.org/) reporter with spec-like output, streaming, and failure diffing. | ||
> A small (~23kB) [TAP](https://testanything.org/) reporter with spec-like output, streaming, and failure diffing. | ||
@@ -5,0 +5,0 @@ ## Objectives |
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
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
24202
230