mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-18 20:15:38 +00:00
28 lines
650 B
JavaScript
28 lines
650 B
JavaScript
// NOTICE: This file is generated by Rollup. To modify it,
|
|
// please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
|
|
'use strict';
|
|
|
|
/**
|
|
* Add one or two empty line(s) before a node. Mutates the node.
|
|
*
|
|
* @template {import('postcss').Node} T
|
|
* @param {T} node
|
|
* @param {string} newline
|
|
* @returns {T}
|
|
*/
|
|
function addEmptyLineBefore(node, newline) {
|
|
const { raws } = node;
|
|
|
|
if (typeof raws.before !== 'string') {
|
|
return node;
|
|
}
|
|
|
|
raws.before = !/\r?\n/.test(raws.before)
|
|
? newline.repeat(2) + raws.before
|
|
: raws.before.replace(/(\r?\n)/, `${newline}$1`);
|
|
|
|
return node;
|
|
}
|
|
|
|
module.exports = addEmptyLineBefore;
|