Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Mar 6, 2024
1 parent 645caa2 commit 14ad08d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Binary file modified bun.lockb
Binary file not shown.
15 changes: 3 additions & 12 deletions storage/framework/core/logging/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import process from 'node:process'
import { appendFile } from 'node:fs/promises'
import { consola, createConsola } from 'consola'
import { ExitCode } from '@stacksjs/types'
import { config } from '@stacksjs/config'
Expand Down Expand Up @@ -45,20 +46,10 @@ export const logFilePath = logsPath('console.log')
async function writeToLogFile(message: string) {
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`
try {
const file = Bun.file(logFilePath)
const writer = file.writer()
const text = await file.text()
writer.write(`${text}\n`)
writer.write(`${formattedMessage}\n`)
await writer.end()
await appendFile(logFilePath, formattedMessage)
}
catch (error) {
// Assuming the error is due to the file not existing
// Create the file and then write the message
const file = Bun.file(logFilePath) // Use the create option
const writer = file.writer()
writer.write(`${formattedMessage}\n`)
await writer.end()
console.error('Failed to write to log file:', error)
}
}

Expand Down
4 changes: 2 additions & 2 deletions storage/framework/core/storage/src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as fs from 'fs-extra'
import { pathExists as existsSync, mkdirSync, writeFileSync } from 'fs-extra'
import { pathExists as existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs-extra'

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

export { fs, existsSync, mkdirSync, writeFileSync }
export { fs, existsSync, mkdirSync, writeFileSync, readFileSync }

0 comments on commit 14ad08d

Please sign in to comment.