|
1 | 1 | 'use server'; |
2 | 2 |
|
3 | | -import { readFileSync, appendFileSync, existsSync } from 'fs'; |
| 3 | +import * as fs from 'fs'; |
| 4 | +import * as path from 'path'; |
4 | 5 | import { isServer } from './helper'; |
5 | | -import { join } from 'path'; |
6 | 6 |
|
7 | 7 | export const buildIn = async (styleSheet: string, global?: string): Promise<void> => { |
8 | | - const styleFilePath = join(__dirname, '../../core/styles/style.module.css'); |
9 | | - const globalFilePath = join(__dirname, '../../core/styles/global.css'); |
| 8 | + const styleFilePath = path.join(__dirname, '../../core/styles/style.module.css'); |
| 9 | + const globalFilePath = path.join(__dirname, '../../core/styles/global.css'); |
10 | 10 |
|
11 | 11 | const filePath = global === '--global' ? globalFilePath : styleFilePath; |
12 | 12 | const message = global === '--global' ? ' ✅ Generating global static css \n' : ' ✅ Generating module static css \n'; |
13 | 13 |
|
14 | 14 | if (!isServer) return; |
15 | 15 | try { |
16 | | - if (existsSync(filePath)) { |
17 | | - const cssData = readFileSync(filePath, 'utf-8'); |
| 16 | + if (fs.existsSync(filePath)) { |
| 17 | + const cssData = fs.readFileSync(filePath, 'utf-8'); |
18 | 18 | if (!cssData.includes(styleSheet)) { |
19 | | - appendFileSync(filePath, styleSheet, 'utf-8'); |
| 19 | + fs.appendFileSync(filePath, styleSheet, 'utf-8'); |
20 | 20 | console.log(message + styleSheet); |
21 | 21 | } |
22 | 22 | } else { |
23 | | - appendFileSync(filePath, styleSheet, 'utf-8'); |
| 23 | + fs.appendFileSync(filePath, styleSheet, 'utf-8'); |
24 | 24 | console.log(message + styleSheet); |
25 | 25 | } |
26 | 26 | } catch (error) { |
|
0 commit comments