MCPcopy Create free account
hub / github.com/Effect-TS/effect / resolveCurrentPath

Function resolveCurrentPath

packages/effect/src/unstable/cli/Prompt.ts:2116–2137  ·  view source on GitHub ↗
(
  path: Option.Option<string>,
  options: FileOptionsReq
)

Source from the content-addressed store, hash-verified

2114const showConfirmation = Confirm.$is("Show")
2115
2116const resolveCurrentPath = (
2117 path: Option.Option<string>,
2118 options: FileOptionsReq
2119): Effect.Effect<string, never, FileSystem.FileSystem> => {
2120 if (Option.isSome(path)) {
2121 return Effect.succeed(path.value)
2122 }
2123 if (Option.isSome(options.startingPath)) {
2124 const startingPath = options.startingPath.value
2125 return Effect.flatMap(FileSystem.FileSystem, (fs) =>
2126 // Ensure the user provided starting path exists
2127 Effect.orDie(fs.exists(startingPath)).pipe(
2128 Effect.flatMap((exists) =>
2129 exists ? Effect.void : Effect.die(
2130 `The provided starting path '${startingPath}' does not exist`
2131 )
2132 ),
2133 Effect.as(startingPath)
2134 ))
2135 }
2136 return Effect.sync(() => process.cwd())
2137}
2138
2139const getFileList = Effect.fnUntraced(function*(directory: string, options: FileOptionsReq) {
2140 const fs = yield* FileSystem.FileSystem

Callers 4

fileFunction · 0.85
handleFileClearFunction · 0.85
Prompt.tsFile · 0.85
handleFileProcessFunction · 0.85

Calls 3

pipeMethod · 0.65
succeedMethod · 0.45
syncMethod · 0.45

Tested by

no test coverage detected