UNPKG

beathers

Version:

Beather is a lightweight SCSS library that serves as a comprehensive design system for your projects. It offers a structured and consistent approach to manage colors, fonts, and other design related variables, making it easier to maintain a cohesive visua

20 lines (19 loc) 893 B
import fs from 'fs-extra'; import * as path from 'node:path'; export async function CallNewVariables(projectRoot, isInstalledPackage = false) { const scssFilePath = isInstalledPackage ? path.join(projectRoot, 'scss', 'beathers.min.scss') : path.join(projectRoot, 'src', 'scss', 'beathers.min.scss'); if (!(await fs.pathExists(scssFilePath))) return; let scssContent = await fs.readFile(scssFilePath, 'utf8'); if (scssContent.includes('@use "./variables"')) return; const styleCommentIndex = scssContent.indexOf('// Style'); if (styleCommentIndex === -1) return; const beforeComment = scssContent.slice(0, styleCommentIndex); const afterComment = scssContent.slice(styleCommentIndex); scssContent = beforeComment + '@use "./variables";\n\n' + afterComment; await fs.writeFile(scssFilePath, scssContent, 'utf8'); }