MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / readOrCreate

Function readOrCreate

packages/core/config/src/write.ts:27–36  ·  view source on GitHub ↗
(
  fs: FileSystem.FileSystem,
  path: string,
)

Source from the content-addressed store, hash-verified

25
26/** Read the raw JSONC text from a config file, or create a default one. */
27const readOrCreate = (
28 fs: FileSystem.FileSystem,
29 path: string,
30): Effect.Effect<string, PlatformError> =>
31 Effect.gen(function* () {
32 const exists = yield* fs.exists(path);
33 if (exists) return yield* fs.readFileString(path);
34 yield* fs.writeFileString(path, DEFAULT_CONFIG);
35 return DEFAULT_CONFIG;
36 });
37
38/**
39 * Add an integration entry to the config file. Creates the file if it doesn't exist.

Callers 2

addIntegrationToConfigFunction · 0.85
addSecretToConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected