mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-05 00:23:10 +00:00
tweak: start bundling in some ai-sdk packages (#4649)
This commit is contained in:
@@ -4,10 +4,12 @@ import { Log } from "../util/log"
|
||||
import path from "path"
|
||||
import { NamedError } from "../util/error"
|
||||
import { readableStreamToText } from "bun"
|
||||
import { createRequire } from "module"
|
||||
import { Lock } from "../util/lock"
|
||||
|
||||
export namespace BunProc {
|
||||
const log = Log.create({ service: "bun" })
|
||||
const req = createRequire(import.meta.url)
|
||||
|
||||
export async function run(cmd: string[], options?: Bun.SpawnOptions.OptionsObject<any, any, any>) {
|
||||
log.info("running", {
|
||||
@@ -129,4 +131,22 @@ export namespace BunProc {
|
||||
await Bun.write(pkgjson.name!, JSON.stringify(parsed, null, 2))
|
||||
return mod
|
||||
}
|
||||
|
||||
export async function resolve(pkg: string) {
|
||||
const local = workspace(pkg)
|
||||
if (local) return local
|
||||
const dir = path.join(Global.Path.cache, "node_modules", pkg)
|
||||
const pkgjson = Bun.file(path.join(dir, "package.json"))
|
||||
const exists = await pkgjson.exists()
|
||||
if (exists) return dir
|
||||
}
|
||||
|
||||
function workspace(pkg: string) {
|
||||
try {
|
||||
const target = req.resolve(`${pkg}/package.json`)
|
||||
return path.dirname(target)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user