UNPKG

zss-engine

Version:
28 lines (27 loc) 990 B
'use server'; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.build = void 0; const helper_js_1 = require("./helper.js"); const build = async (styleSheet, filePath, global) => { if (!helper_js_1.isServer) return; const fs = await import('fs'); const { styleText } = await import('util'); const message = global === '--global' ? styleText('underline', `✅Generated global CSS\n\n`) : styleText('underline', `✅Generated create CSS\n\n`); try { if (fs.existsSync(filePath)) { const cssData = fs.readFileSync(filePath, 'utf-8'); if (!cssData.includes(styleSheet)) { fs.appendFileSync(filePath, styleSheet, 'utf-8'); if (process.argv.includes('--view')) console.log(message + styleSheet); } } return; } catch (error) { console.error('Error writing to file:', error); } }; exports.build = build;