Rename formatNodes to formatCSS
This commit is contained in:
parent
de1884fdd9
commit
93184084c6
2 changed files with 2 additions and 2 deletions
15
src/lib/formatCSS.js
Normal file
15
src/lib/formatCSS.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function indentRecursive(node, indent = 0) {
|
||||
node.each &&
|
||||
node.each((child, i) => {
|
||||
if (!child.raws.before || child.raws.before.includes('\n')) {
|
||||
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`
|
||||
}
|
||||
child.raws.after = `\n${' '.repeat(indent)}`
|
||||
indentRecursive(child, indent + 1)
|
||||
})
|
||||
}
|
||||
|
||||
export default function formatNodes(root) {
|
||||
indentRecursive(root)
|
||||
root.first.raws.before = ''
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue