Skip to content

Commit 890f71b

Browse files
committed
creating directories if they don't exist
1 parent 06dfa4d commit 890f71b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/main/scala/org/polystat/cli/EO.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ object EO:
7878
_ <- cfg.output.dirs.traverse_ { outDir =>
7979
for
8080
_ <- IO.println(s"Cleaning $outDir before writing...")
81-
_ <- outDir.clean
81+
_ <- outDir.createDirIfDoesntExist.flatMap(_.clean)
8282
yield ()
8383
}
8484
_ <- writeToDirs(analyzed)

src/main/scala/org/polystat/cli/InputUtils.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import PolystatConfig.{Input, PolystatUsage}
1313

1414
object InputUtils:
1515
extension (path: Path)
16+
17+
def createDirIfDoesntExist: IO[Path] =
18+
Files[IO]
19+
.exists(path)
20+
.ifM(
21+
ifTrue = IO.pure(path),
22+
ifFalse = Files[IO].createDirectories(path).as(path),
23+
)
1624
def replaceExt(newExt: String): Path =
1725
Path(
1826
path.toString

src/main/scala/org/polystat/cli/Main.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ object Main extends IOApp:
6363
for
6464
tempDir <- tmp match
6565
case Some(path) =>
66-
IO.println(s"Cleaning ${path.absolute}...") *> path.clean
66+
IO.println(s"Cleaning ${path.absolute}...") *>
67+
path.createDirIfDoesntExist.flatMap(_.clean)
6768
case None => Files[IO].createTempDirectory
6869
processedConfig = ProcessedConfig(
6970
filteredAnalyzers = filterAnalyzers(inex),

0 commit comments

Comments
 (0)