fix: unbuild version reduced to 2.0

This commit is contained in:
vben
2024-08-03 10:12:45 +08:00
parent 27ffc9e71b
commit d3ed6757ac
8 changed files with 322 additions and 54 deletions

View File

@@ -11,7 +11,6 @@ export async function outputJSON(
await fs.mkdir(dir, { recursive: true });
const jsonData = JSON.stringify(data, null, spaces);
await fs.writeFile(filePath, jsonData, 'utf8');
console.log(`JSON data written to ${filePath}`);
} catch (error) {
console.error('Error writing JSON file:', error);
throw error;
@@ -22,8 +21,7 @@ export async function ensureFile(filePath: string) {
try {
const dir = dirname(filePath);
await fs.mkdir(dir, { recursive: true });
await fs.writeFile(filePath, '', { flag: 'a' }); // 'a' flag to append if file exists, otherwise create
console.log(`File ensured: ${filePath}`);
await fs.writeFile(filePath, '', { flag: 'a' });
} catch (error) {
console.error('Error ensuring file:', error);
throw error;