Skip to content

Commit 14ad08d

Browse files
committed
chore: wip
1 parent 645caa2 commit 14ad08d

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

bun.lockb

0 Bytes
Binary file not shown.

storage/framework/core/logging/src/index.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import process from 'node:process'
2+
import { appendFile } from 'node:fs/promises'
23
import { consola, createConsola } from 'consola'
34
import { ExitCode } from '@stacksjs/types'
45
import { config } from '@stacksjs/config'
@@ -45,20 +46,10 @@ export const logFilePath = logsPath('console.log')
4546
async function writeToLogFile(message: string) {
4647
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`
4748
try {
48-
const file = Bun.file(logFilePath)
49-
const writer = file.writer()
50-
const text = await file.text()
51-
writer.write(`${text}\n`)
52-
writer.write(`${formattedMessage}\n`)
53-
await writer.end()
49+
await appendFile(logFilePath, formattedMessage)
5450
}
5551
catch (error) {
56-
// Assuming the error is due to the file not existing
57-
// Create the file and then write the message
58-
const file = Bun.file(logFilePath) // Use the create option
59-
const writer = file.writer()
60-
writer.write(`${formattedMessage}\n`)
61-
await writer.end()
52+
console.error('Failed to write to log file:', error)
6253
}
6354
}
6455

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as fs from 'fs-extra'
2-
import { pathExists as existsSync, mkdirSync, writeFileSync } from 'fs-extra'
2+
import { pathExists as existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs-extra'
33

44
export async function exists(path: string): Promise<boolean> {
55
return await existsSync(path)
66
}
77

8-
export { fs, existsSync, mkdirSync, writeFileSync }
8+
export { fs, existsSync, mkdirSync, writeFileSync, readFileSync }

0 commit comments

Comments
 (0)