import { Rule, Tree } from '@angular-devkit/schematics'; export function removeBlankLines(): Rule { return (tree: Tree) => { tree.visit((filePath) => { if (!filePath.startsWith('/jtc-output')) { return; } const buffer = tree.read(filePath); if (!buffer) return; const content = buffer.toString(); const cleanedContent = content .split('\n') .filter((line, index, arr) => { // Remove completely blank lines if (line.trim() === '') { // Keep only one blank line return !(index > 0 && arr[index - 1].trim() === ''); } return true; }) .join('\n'); tree.overwrite(filePath, cleanedContent); }); return tree; }; }