jest-allure2-reporter
Version:
Idiomatic Jest reporter for Allure Framework
20 lines • 708 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.autoIndent = autoIndent;
function autoIndent(text) {
const [first, ...rest] = text.split('\n');
const indent = detectIndent(rest);
if (indent > 0) {
return [first, ...rest.map((line) => line.slice(indent))].join('\n');
}
return text;
}
function detectIndent(lines) {
const result = lines.reduce((min, line) => {
const trimmed = line.trimStart();
const indent = trimmed === '' ? min : line.length - trimmed.length;
return Math.min(indent, min);
}, Number.POSITIVE_INFINITY);
return Number.isFinite(result) ? result : 0;
}
//# sourceMappingURL=autoIndent.js.map