baset-baseliner-md
Advanced tools
Comparing version 0.14.2 to 0.14.3
@@ -6,2 +6,14 @@ # Change Log | ||
<a name="0.14.3"></a> | ||
## [0.14.3](https://github.com/Igmat/baset/compare/v0.14.2...v0.14.3) (2018-10-07) | ||
### Bug Fixes | ||
* **baseliner-md:** add errors as type of baseline output ([6333c31](https://github.com/Igmat/baset/commit/6333c31)) | ||
<a name="0.14.2"></a> | ||
@@ -8,0 +20,0 @@ ## [0.14.2](https://github.com/Igmat/baset/compare/v0.14.1...v0.14.2) (2018-09-17) |
@@ -11,2 +11,3 @@ import { AbstractBaseliner } from 'baset-core'; | ||
actual: string; | ||
errors: any[]; | ||
diff: { | ||
@@ -13,0 +14,0 @@ console: string; |
@@ -17,2 +17,3 @@ "use strict"; | ||
const clean_html_1 = require("clean-html"); | ||
const path_1 = __importDefault(require("path")); | ||
const pixelmatch_1 = __importDefault(require("pixelmatch")); | ||
@@ -39,2 +40,9 @@ const pngjs_1 = require("pngjs"); | ||
} | ||
function normalizeStackTrace(trace) { | ||
const filePathRegex = path_1.default.sep === '\\' | ||
? /([a-z]|[A-Z]):\\[^:]*:/g | ||
: /\/[^:]*:/g; | ||
return trace.replace(filePathRegex, absPath => path_1.default.relative(process.cwd(), absPath) | ||
.replace(/\\/g, '/')); | ||
} | ||
const knownTypeTemplates = { | ||
@@ -49,2 +57,7 @@ [baset_core_1.dataTypes.image]: (image) => ` | ||
`, | ||
[baset_core_1.dataTypes.error]: (error) => ` | ||
\`\`\` | ||
${normalizeStackTrace(error.src)} | ||
\`\`\` | ||
`, | ||
}; | ||
@@ -95,2 +108,5 @@ const renderKnown = (property) => ` | ||
actual: baset_core_1.utils.normalizeEndings(mdTemplate(newJsonValues, known)), | ||
errors: known | ||
.filter(({ type }) => type === baset_core_1.dataTypes.error) | ||
.map(({ originalValue }) => originalValue[baset_core_1.dataTypes.error]), | ||
diff: { | ||
@@ -114,5 +130,7 @@ console: '', | ||
const name = nodes[i].children[0].value.replace(':', ''); | ||
const type = nodes[i + 1].type === 'paragraph' | ||
? baset_core_1.dataTypes.image | ||
: baset_core_1.dataTypes.html; | ||
const type = name === 'Throws' | ||
? baset_core_1.dataTypes.error | ||
: nodes[i + 1].type === 'paragraph' | ||
? baset_core_1.dataTypes.image | ||
: baset_core_1.dataTypes.html; | ||
const src = (type === baset_core_1.dataTypes.image) | ||
@@ -141,11 +159,10 @@ ? nodes[i + 1].children[0].url | ||
} | ||
const type = obj[baset_core_1.dataTypes.image] | ||
? baset_core_1.dataTypes.image | ||
: obj[baset_core_1.dataTypes.html] | ||
? baset_core_1.dataTypes.html | ||
: false; | ||
const type = getType(obj); | ||
if (type) { | ||
const result = { | ||
type, | ||
name: path, | ||
originalValue: obj, | ||
name: type === baset_core_1.dataTypes.error | ||
? 'Throws' | ||
: path, | ||
src: (type === baset_core_1.dataTypes.html) | ||
@@ -155,3 +172,5 @@ ? obj[baset_core_1.dataTypes.html] === 'react' | ||
: yield htmlBeautify(obj.value) | ||
: obj.value, | ||
: type === baset_core_1.dataTypes.error | ||
? obj[type].stack | ||
: obj.value, | ||
}; | ||
@@ -180,11 +199,18 @@ if (key !== undefined) | ||
return false; | ||
if (value.type === baset_core_1.dataTypes.image) { | ||
if (!(yield compareImages(value.src, newValue.src))) | ||
return false; | ||
switch (value.type) { | ||
case baset_core_1.dataTypes.image: | ||
if (!(yield compareImages(value.src, newValue.src))) | ||
return false; | ||
break; | ||
case baset_core_1.dataTypes.html: | ||
if (baset_core_1.utils.normalizeEndings(value.src) !== baset_core_1.utils.normalizeEndings(newValue.src)) | ||
return false; | ||
break; | ||
case baset_core_1.dataTypes.error: | ||
if (baset_core_1.utils.normalizeEndings(value.src) !== baset_core_1.utils.normalizeEndings(normalizeStackTrace(newValue.src))) | ||
return false; | ||
break; | ||
default: | ||
break; | ||
} | ||
else { | ||
if (baset_core_1.utils.normalizeEndings(value.src) !== baset_core_1.utils.normalizeEndings(newValue.src)) { | ||
return false; | ||
} | ||
} | ||
} | ||
@@ -225,2 +251,7 @@ return true; | ||
} | ||
function getType(obj) { | ||
return Object.keys(baset_core_1.dataTypes) | ||
.map(key => baset_core_1.dataTypes[key]) | ||
.find(type => !!obj[type]); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "baset-baseliner-md", | ||
"version": "0.14.2", | ||
"version": "0.14.3", | ||
"description": "JSON baseliner plugin for BaseT project.", | ||
@@ -39,4 +39,4 @@ "author": "Ihor Chulinda <ichulinda@gmail.com>", | ||
"dependencies": { | ||
"baset-baseliner-json": "^0.14.2", | ||
"baset-core": "^0.14.2", | ||
"baset-baseliner-json": "^0.14.3", | ||
"baset-core": "^0.14.3", | ||
"clean-html": "^1.5.0", | ||
@@ -48,3 +48,3 @@ "pixelmatch": "^4.0.2", | ||
}, | ||
"gitHead": "f778d3ecb4cdc64d3e489723529bf9a23f01d64d" | ||
"gitHead": "7c9e10ac30215b5320a76c819a3da1c793bb0f4d" | ||
} |
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
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
25828
266
Updatedbaset-baseliner-json@^0.14.3
Updatedbaset-core@^0.14.3