19 lines
602 B
JavaScript
19 lines
602 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.formatCdlFile = formatCdlFile;
|
|
function formatCdlFile(content) {
|
|
let indentLevel = 0;
|
|
const formattedLines = [];
|
|
for (const line of content.split("\n")) {
|
|
const strippedLine = line.trim();
|
|
if (strippedLine.endsWith("}")) {
|
|
indentLevel = Math.max(indentLevel - 1, 0);
|
|
}
|
|
formattedLines.push(" ".repeat(indentLevel) + strippedLine);
|
|
if (strippedLine.endsWith("{")) {
|
|
indentLevel += 1;
|
|
}
|
|
}
|
|
return formattedLines.join("\n");
|
|
}
|