( path: string, pathType: Primitive.Primitive.PathType, fileSystem: FileSystem.FileSystem )
| 510 | } |
| 511 | |
| 512 | const 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 | |
| 544 | const wizardInternal = (self: Instruction, help: HelpDoc.HelpDoc): Prompt.Prompt<any> => { |
| 545 | switch (self._tag) { |
no test coverage detected