MCPcopy
hub / github.com/Effect-TS/effect / validatePathType

Function validatePathType

packages/cli/src/internal/primitive.ts:512–542  ·  view source on GitHub ↗
(
  path: string,
  pathType: Primitive.Primitive.PathType,
  fileSystem: FileSystem.FileSystem
)

Source from the content-addressed store, hash-verified

510}
511
512const validatePathType = (
513 path: string,
514 pathType: Primitive.Primitive.PathType,
515 fileSystem: FileSystem.FileSystem
516): Effect.Effect<void, string> => {
517 switch (pathType) {
518 case "file": {
519 const checkIsFile = fileSystem.stat(path).pipe(
520 Effect.map((info) => info.type === "File"),
521 Effect.orDie
522 )
523 return Effect.fail(`Expected path '${path}' to be a regular file`).pipe(
524 Effect.unlessEffect(checkIsFile),
525 Effect.asVoid
526 )
527 }
528 case "directory": {
529 const checkIsDirectory = fileSystem.stat(path).pipe(
530 Effect.map((info) => info.type === "Directory"),
531 Effect.orDie
532 )
533 return Effect.fail(`Expected path '${path}' to be a directory`).pipe(
534 Effect.unlessEffect(checkIsDirectory),
535 Effect.asVoid
536 )
537 }
538 case "either": {
539 return Effect.void
540 }
541 }
542}
543
544const wizardInternal = (self: Instruction, help: HelpDoc.HelpDoc): Prompt.Prompt<any> => {
545 switch (self._tag) {

Callers 1

validateInternalFunction · 0.85

Calls 4

statMethod · 0.80
pipeMethod · 0.65
mapMethod · 0.65
failMethod · 0.65

Tested by

no test coverage detected