Comparing version 0.3.1 to 0.3.2
@@ -9,2 +9,12 @@ # `tap-arc` Changelog | ||
## [0.3.2] - 2022-03-24 | ||
### Added | ||
- `--verbose` prints full diff as reported by `tcompare` | ||
### Fixed | ||
- actual vs expected colors in equality assertions | ||
## [0.3.1] - 2022-03-24 | ||
@@ -11,0 +21,0 @@ |
24
index.js
@@ -14,2 +14,3 @@ #!/usr/bin/env node | ||
green, | ||
inverse, | ||
red, | ||
@@ -69,3 +70,4 @@ underline, | ||
function makeDiff (lhs, rhs) { | ||
function makeDiff (lhs, rhs, options) { | ||
const { verbose } = options | ||
const msg = [] | ||
@@ -102,11 +104,15 @@ let isJson = true | ||
// capture diff after line: "@@ -n,n +n,n @@" | ||
const diff = compared.diff.split(/^(?:@@).*(?:@@)$/gm)[1] | ||
const diff = verbose | ||
? compared.diff | ||
: compared.diff.split(/^(?:@@).*(?:@@)$/gm)[1] | ||
for (const line of diff.split('\n')) { | ||
const char0 = line.charAt(0) | ||
if (char0 === '-') | ||
if (line.indexOf('--- ') === 0) | ||
msg.push(inverse(red(line))) | ||
else if (line.indexOf('+++ ') === 0) | ||
msg.push(inverse(green(line))) | ||
else if (line.charAt(0) === '-') | ||
msg.push(red(line)) | ||
else if (line.charAt(0) === '+') | ||
msg.push(green(line)) | ||
else if (char0 === '+') | ||
msg.push(red(line)) | ||
else | ||
@@ -165,7 +171,7 @@ msg.push(line) | ||
if (typeof expected === 'string' && typeof actual === 'string') { | ||
msg = [ ...msg, ...makeDiff(actual, expected) ] | ||
msg = [ ...msg, ...makeDiff(actual, expected, options) ] | ||
} | ||
else if (typeof expected === 'object' && typeof actual === 'object') { | ||
// probably an array | ||
msg = [ ...msg, ...makeDiff(actual, expected) ] | ||
msg = [ ...msg, ...makeDiff(actual, expected, options) ] | ||
} | ||
@@ -172,0 +178,0 @@ else if (typeof expected === 'number' || typeof actual === 'number') { |
@@ -5,3 +5,3 @@ { | ||
"author": "tbeseda", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"license": "Apache-2.0", | ||
@@ -8,0 +8,0 @@ "main": "index.js", |
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
24245
233