MCPcopy
hub / github.com/anomalyco/opencode / remappedFs

Function remappedFs

packages/opencode/test/storage/storage.test.ts:38–55  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

36}
37
38function remappedFs(root: string) {
39 return Layer.effect(
40 FSUtil.Service,
41 Effect.gen(function* () {
42 const fs = yield* FSUtil.Service
43 return FSUtil.Service.of({
44 ...fs,
45 isDir: (file) => fs.isDir(remap(root, file)),
46 readJson: (file) => fs.readJson(remap(root, file)),
47 writeWithDirs: (file, content, mode) => fs.writeWithDirs(remap(root, file), content, mode),
48 readFileString: (file) => fs.readFileString(remap(root, file)),
49 remove: (file) => fs.remove(remap(root, file)),
50 glob: (pattern, options) =>
51 fs.glob(pattern, options?.cwd ? { ...options, cwd: remap(root, options.cwd) } : options),
52 })
53 }),
54 ).pipe(Layer.provide(LayerNode.compile(FSUtil.node)))
55}
56
57// Layer.fresh forces a new Storage instance — without it, Effect's in-test layer cache
58// returns the outer testEffect's Storage (which uses the real FSUtil), not a new

Callers 1

remappedStorageFunction · 0.70

Calls 3

remapFunction · 0.70
removeMethod · 0.65
globMethod · 0.65

Tested by

no test coverage detected