mirror of
https://github.com/aljazceru/opencode.git
synced 2026-02-06 00:24:34 +01:00
process
This commit is contained in:
@@ -8,19 +8,17 @@ import { AppPath } from "../app/path";
|
||||
export namespace Storage {
|
||||
const log = Log.create({ service: "storage" });
|
||||
|
||||
function state() {
|
||||
return App.service("storage", async () => {
|
||||
const app = await App.use();
|
||||
const storageDir = AppPath.storage(app.root);
|
||||
await fs.mkdir(storageDir, { recursive: true });
|
||||
const storage = new FileStorage(new LocalStorageAdapter(storageDir));
|
||||
await storage.write("test", "test");
|
||||
log.info("created", { path: storageDir });
|
||||
return {
|
||||
storage,
|
||||
};
|
||||
});
|
||||
}
|
||||
const state = App.state("storage", async () => {
|
||||
const app = await App.use();
|
||||
const storageDir = AppPath.storage(app.root);
|
||||
await fs.mkdir(storageDir, { recursive: true });
|
||||
const storage = new FileStorage(new LocalStorageAdapter(storageDir));
|
||||
await storage.write("test", "test");
|
||||
log.info("created", { path: storageDir });
|
||||
return {
|
||||
storage,
|
||||
};
|
||||
});
|
||||
|
||||
function expose<T extends keyof FileStorage>(key: T) {
|
||||
const fn = FileStorage.prototype[key];
|
||||
@@ -36,4 +34,6 @@ export namespace Storage {
|
||||
|
||||
export const write = expose("write");
|
||||
export const read = expose("read");
|
||||
export const list = expose("list");
|
||||
export const readToString = expose("readToString");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user