mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
discover logic
This commit is contained in:
parent
fc9081afe4
commit
a2e460bc4b
1 changed files with 22 additions and 20 deletions
|
|
@ -131,26 +131,28 @@ export namespace Project {
|
|||
if (input.vcs !== "git") return
|
||||
if (input.icon) return
|
||||
const glob = new Bun.Glob("**/{favicon}.{ico,png,svg,jpg,jpeg,webp}")
|
||||
for await (const match of glob.scan({
|
||||
cwd: input.worktree,
|
||||
absolute: true,
|
||||
onlyFiles: true,
|
||||
followSymlinks: false,
|
||||
dot: false,
|
||||
})) {
|
||||
const file = Bun.file(match)
|
||||
const buffer = await file.arrayBuffer()
|
||||
const base64 = Buffer.from(buffer).toString("base64")
|
||||
const mime = file.type || "image/png"
|
||||
const url = `data:${mime};base64,${base64}`
|
||||
await update({
|
||||
projectID: input.id,
|
||||
icon: {
|
||||
url,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
const matches = await Array.fromAsync(
|
||||
glob.scan({
|
||||
cwd: input.worktree,
|
||||
absolute: true,
|
||||
onlyFiles: true,
|
||||
followSymlinks: false,
|
||||
dot: false,
|
||||
}),
|
||||
)
|
||||
const shortest = matches.sort((a, b) => a.length - b.length)[0]
|
||||
const file = Bun.file(shortest)
|
||||
const buffer = await file.arrayBuffer()
|
||||
const base64 = Buffer.from(buffer).toString("base64")
|
||||
const mime = file.type || "image/png"
|
||||
const url = `data:${mime};base64,${base64}`
|
||||
await update({
|
||||
projectID: input.id,
|
||||
icon: {
|
||||
url,
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
async function migrateFromGlobal(newProjectID: string, worktree: string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue