diff options
| author | Dax Raad <[email protected]> | 2025-05-30 20:47:56 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-05-30 20:48:36 -0400 |
| commit | f3da73553c45f17e04b1e77cb13eb0fca714d1bd (patch) | |
| tree | a24317a19e1ab2a89da50db669dc6894f15d00d1 /js/src/util | |
| parent | 9a26b3058ffc1023e5c7e54b6d571c903d15888e (diff) | |
| download | opencode-f3da73553c45f17e04b1e77cb13eb0fca714d1bd.tar.gz opencode-f3da73553c45f17e04b1e77cb13eb0fca714d1bd.zip | |
sync
Diffstat (limited to 'js/src/util')
| -rw-r--r-- | js/src/util/context.ts | 25 | ||||
| -rw-r--r-- | js/src/util/event.ts | 0 | ||||
| -rw-r--r-- | js/src/util/log.ts | 64 | ||||
| -rw-r--r-- | js/src/util/scrap.ts | 5 |
4 files changed, 0 insertions, 94 deletions
diff --git a/js/src/util/context.ts b/js/src/util/context.ts deleted file mode 100644 index bcaf7ee3c..000000000 --- a/js/src/util/context.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { AsyncLocalStorage } from "async_hooks"; - -export namespace Context { - export class NotFound extends Error { - constructor(public readonly name: string) { - super(`No context found for ${name}`); - } - } - - export function create<T>(name: string) { - const storage = new AsyncLocalStorage<T>(); - return { - use() { - const result = storage.getStore(); - if (!result) { - throw new NotFound(name); - } - return result; - }, - provide<R>(value: T, fn: () => R) { - return storage.run<R>(value, fn); - }, - }; - } -} diff --git a/js/src/util/event.ts b/js/src/util/event.ts deleted file mode 100644 index e69de29bb..000000000 --- a/js/src/util/event.ts +++ /dev/null diff --git a/js/src/util/log.ts b/js/src/util/log.ts deleted file mode 100644 index 34707b136..000000000 --- a/js/src/util/log.ts +++ /dev/null @@ -1,64 +0,0 @@ -import path from "path"; -import { AppPath } from "../app/path"; -import fs from "fs/promises"; -export namespace Log { - const write = { - out: (msg: string) => { - process.stdout.write(msg); - }, - err: (msg: string) => { - process.stderr.write(msg); - }, - }; - - export async function file(directory: string) { - const outPath = path.join(AppPath.data(directory), "opencode.out.log"); - const errPath = path.join(AppPath.data(directory), "opencode.err.log"); - await fs.truncate(outPath).catch(() => {}); - await fs.truncate(errPath).catch(() => {}); - const out = Bun.file(outPath); - const err = Bun.file(errPath); - const outWriter = out.writer(); - const errWriter = err.writer(); - write["out"] = (msg) => { - outWriter.write(msg); - outWriter.flush(); - }; - write["err"] = (msg) => { - errWriter.write(msg); - errWriter.flush(); - }; - } - - export function create(tags?: Record<string, any>) { - tags = tags || {}; - - function build(message: any, extra?: Record<string, any>) { - const prefix = Object.entries({ - ...tags, - ...extra, - }) - .filter(([_, value]) => value !== undefined && value !== null) - .map(([key, value]) => `${key}=${value}`) - .join(" "); - return [new Date().toISOString(), prefix, message].filter(Boolean).join(" ") + "\n"; - } - const result = { - info(message?: any, extra?: Record<string, any>) { - write.out(build(message, extra)); - }, - error(message?: any, extra?: Record<string, any>) { - write.err(build(message, extra)); - }, - tag(key: string, value: string) { - if (tags) tags[key] = value; - return result; - }, - clone() { - return Log.create({ ...tags }); - }, - }; - - return result; - } -} diff --git a/js/src/util/scrap.ts b/js/src/util/scrap.ts deleted file mode 100644 index 16005acdc..000000000 --- a/js/src/util/scrap.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const foo: string = "42"; - -export function dummyFunction(): void { - console.log("This is a dummy function"); -} |
