MCPcopy Create free account
hub / github.com/anomalyco/opencode / cassettePath

Function cassettePath

packages/http-recorder/src/cassette.ts:41–50  ·  view source on GitHub ↗
(directory: string, name: string)

Source from the content-addressed store, hash-verified

39export class Service extends Context.Service<Service, Interface>()("@opencode-ai/http-recorder/Cassette") {}
40
41const cassettePath = (directory: string, name: string) => {
42 if (!name || path.isAbsolute(name) || path.win32.isAbsolute(name) || name.split(/[\\/]/).includes(".."))
43 throw new Error(`Invalid cassette name "${name}"`)
44 const root = path.resolve(directory)
45 const target = path.resolve(root, `${name}.json`)
46 const relative = path.relative(root, target)
47 if (!relative || relative.startsWith("..") || path.isAbsolute(relative))
48 throw new Error(`Invalid cassette name "${name}"`)
49 return target
50}
51
52export const hasCassetteSync = (name: string, options: { readonly directory?: string } = {}) =>
53 fs.existsSync(cassettePath(options.directory ?? DEFAULT_RECORDINGS_DIR, name))

Callers 2

hasCassetteSyncFunction · 0.85
pathForFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected