mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
windows fixes (#374)
Co-authored-by: Matthew Glazar <strager.nds@gmail.com>
This commit is contained in:
parent
a2d3b9f0c8
commit
ec001ca02f
5 changed files with 31 additions and 4 deletions
|
@ -46,7 +46,7 @@ export namespace App {
|
||||||
const data = path.join(
|
const data = path.join(
|
||||||
Global.Path.data,
|
Global.Path.data,
|
||||||
"project",
|
"project",
|
||||||
git ? git.split(path.sep).filter(Boolean).join("-") : "global",
|
git ? directory(git) : "global",
|
||||||
)
|
)
|
||||||
const stateFile = Bun.file(path.join(data, APP_JSON))
|
const stateFile = Bun.file(path.join(data, APP_JSON))
|
||||||
const state = (await stateFile.json().catch(() => ({}))) as {
|
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, "-")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Server } from "./server/server"
|
||||||
import fs from "fs/promises"
|
import fs from "fs/promises"
|
||||||
import path from "path"
|
import path from "path"
|
||||||
import { Share } from "./share/share"
|
import { Share } from "./share/share"
|
||||||
|
import url from "node:url"
|
||||||
import { Global } from "./global"
|
import { Global } from "./global"
|
||||||
import yargs from "yargs"
|
import yargs from "yargs"
|
||||||
import { hideBin } from "yargs/helpers"
|
import { hideBin } from "yargs/helpers"
|
||||||
|
@ -63,7 +64,7 @@ const cli = yargs(hideBin(process.argv))
|
||||||
const server = Server.listen()
|
const server = Server.listen()
|
||||||
|
|
||||||
let cmd = ["go", "run", "./main.go"]
|
let cmd = ["go", "run", "./main.go"]
|
||||||
let cwd = new URL("../../tui/cmd/opencode", import.meta.url).pathname
|
let cwd = url.fileURLToPath(new URL("../../tui/cmd/opencode", import.meta.url))
|
||||||
if (Bun.embeddedFiles.length > 0) {
|
if (Bun.embeddedFiles.length > 0) {
|
||||||
const blob = Bun.embeddedFiles[0] as File
|
const blob = Bun.embeddedFiles[0] as File
|
||||||
const binary = path.join(Global.Path.cache, "tui", blob.name)
|
const binary = path.join(Global.Path.cache, "tui", blob.name)
|
||||||
|
|
|
@ -19,7 +19,7 @@ export namespace Log {
|
||||||
await fs.mkdir(dir, { recursive: true })
|
await fs.mkdir(dir, { recursive: true })
|
||||||
cleanup(dir)
|
cleanup(dir)
|
||||||
if (options.print) return
|
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)
|
const logfile = Bun.file(logpath)
|
||||||
await fs.truncate(logpath).catch(() => {})
|
await fs.truncate(logpath).catch(() => {})
|
||||||
const writer = logfile.writer()
|
const writer = logfile.writer()
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ func LoadThemesFromJSON() error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
themeName := strings.TrimSuffix(entry.Name(), ".json")
|
themeName := strings.TrimSuffix(entry.Name(), ".json")
|
||||||
data, err := themesFS.ReadFile(filepath.Join("themes", entry.Name()))
|
data, err := themesFS.ReadFile(path.Join("themes", entry.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to read theme file %s: %w", entry.Name(), err)
|
return fmt.Errorf("failed to read theme file %s: %w", entry.Name(), err)
|
||||||
}
|
}
|
||||||
|
|
16
scripts/hooks.bat
Normal file
16
scripts/hooks.bat
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
if not exist ".git" (
|
||||||
|
exit /b 0
|
||||||
|
)
|
||||||
|
|
||||||
|
if not exist ".git\hooks" (
|
||||||
|
mkdir ".git\hooks"
|
||||||
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
echo #!/bin/sh
|
||||||
|
echo bun run typecheck
|
||||||
|
) > ".git\hooks\pre-push"
|
||||||
|
|
||||||
|
echo ✅ Pre-push hook installed
|
Loading…
Add table
Add a link
Reference in a new issue