style: fix formatting

This commit is contained in:
Waldemar Reusch
2023-04-01 22:44:13 +02:00
parent 46264c85f4
commit baae22657e
2 changed files with 34 additions and 24 deletions

View File

@ -30,9 +30,11 @@ export default function trimIndent(strings: TemplateStringsArray, ...args: any[]
let string = populateTemplate(strings, ...args)
.replace(/^[\r\n]/, "")
.replace(/\r?\n *$/, "");
const dents = string.match(/^([ \t])+/gm)
?.filter(s => /^\s+$/.test(s))
?.map(s => s.length) ?? [];
const dents =
string
.match(/^([ \t])+/gm)
?.filter(s => /^\s+$/.test(s))
?.map(s => s.length) ?? [];
// No dents? no change required
if (!dents || dents.length == 0) return string;
const minDent = Math.min(...dents);