Skip to content

Commit ec001ca

Browse files
thdxrstrager
andauthored
windows fixes (anomalyco#374)
Co-authored-by: Matthew Glazar <strager.nds@gmail.com>
1 parent a2d3b9f commit ec001ca

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

packages/opencode/src/app/app.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export namespace App {
4646
const data = path.join(
4747
Global.Path.data,
4848
"project",
49-
git ? git.split(path.sep).filter(Boolean).join("-") : "global",
49+
git ? directory(git) : "global",
5050
)
5151
const stateFile = Bun.file(path.join(data, APP_JSON))
5252
const state = (await stateFile.json().catch(() => ({}))) as {
@@ -133,4 +133,13 @@ export namespace App {
133133
}),
134134
)
135135
}
136+
137+
function directory(input: string): string {
138+
return input
139+
.split(path.sep)
140+
.filter(Boolean)
141+
.join("-")
142+
.replace(/[^A-Za-z0-9_]/g, "-")
143+
}
136144
}
145+

packages/opencode/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Server } from "./server/server"
44
import fs from "fs/promises"
55
import path from "path"
66
import { Share } from "./share/share"
7+
import url from "node:url"
78
import { Global } from "./global"
89
import yargs from "yargs"
910
import { hideBin } from "yargs/helpers"
@@ -63,7 +64,7 @@ const cli = yargs(hideBin(process.argv))
6364
const server = Server.listen()
6465

6566
let cmd = ["go", "run", "./main.go"]
66-
let cwd = new URL("../../tui/cmd/opencode", import.meta.url).pathname
67+
let cwd = url.fileURLToPath(new URL("../../tui/cmd/opencode", import.meta.url))
6768
if (Bun.embeddedFiles.length > 0) {
6869
const blob = Bun.embeddedFiles[0] as File
6970
const binary = path.join(Global.Path.cache, "tui", blob.name)

packages/opencode/src/util/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export namespace Log {
1919
await fs.mkdir(dir, { recursive: true })
2020
cleanup(dir)
2121
if (options.print) return
22-
logpath = path.join(dir, new Date().toISOString().split(".")[0] + ".log")
22+
logpath = path.join(dir, new Date().toISOString().split(".")[0].replace(/:/g, "") + ".log")
2323
const logfile = Bun.file(logpath)
2424
await fs.truncate(logpath).catch(() => {})
2525
const writer = logfile.writer()

packages/tui/internal/theme/loader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"image/color"
88
"os"
9+
"path"
910
"path/filepath"
1011
"strings"
1112

@@ -42,7 +43,7 @@ func LoadThemesFromJSON() error {
4243
continue
4344
}
4445
themeName := strings.TrimSuffix(entry.Name(), ".json")
45-
data, err := themesFS.ReadFile(filepath.Join("themes", entry.Name()))
46+
data, err := themesFS.ReadFile(path.Join("themes", entry.Name()))
4647
if err != nil {
4748
return fmt.Errorf("failed to read theme file %s: %w", entry.Name(), err)
4849
}

scripts/hooks.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
3+
if not exist ".git" (
4+
exit /b 0
5+
)
6+
7+
if not exist ".git\hooks" (
8+
mkdir ".git\hooks"
9+
)
10+
11+
(
12+
echo #!/bin/sh
13+
echo bun run typecheck
14+
) > ".git\hooks\pre-push"
15+
16+
echo ✅ Pre-push hook installed

0 commit comments

Comments
 (0)