mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 13:30:52 +00:00
fix: don't allow ':' in log file and project dir
Windows does not allow ':' in file or directory names. Make sure the log file and the project directory do not contain ':' to prevent ENOENT errors.
This commit is contained in:
parent
6bc32551a0
commit
7fa2d78c3d
2 changed files with 11 additions and 2 deletions
|
@ -46,7 +46,7 @@ export namespace App {
|
|||
const data = path.join(
|
||||
Global.Path.data,
|
||||
"project",
|
||||
git ? git.split(path.sep).filter(Boolean).join("-") : "global",
|
||||
git ? directory(git) : "global",
|
||||
)
|
||||
const stateFile = Bun.file(path.join(data, APP_JSON))
|
||||
const state = (await stateFile.json().catch(() => ({}))) as {
|
||||
|
@ -133,4 +133,13 @@ export namespace App {
|
|||
}),
|
||||
)
|
||||
}
|
||||
|
||||
function directory(input: string): string {
|
||||
return input
|
||||
.split(path.sep)
|
||||
.filter(Boolean)
|
||||
.join("-")
|
||||
.replace(/[^A-Za-z0-9_]/g, "-")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ export namespace Log {
|
|||
await fs.mkdir(dir, { recursive: true })
|
||||
cleanup(dir)
|
||||
if (options.print) return
|
||||
logpath = path.join(dir, new Date().toISOString().split(".")[0] + ".log")
|
||||
logpath = path.join(dir, new Date().toISOString().split(".")[0].replace(/:/g, "") + ".log")
|
||||
const logfile = Bun.file(logpath)
|
||||
await fs.truncate(logpath).catch(() => {})
|
||||
const writer = logfile.writer()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue