Skip to content

Commit 3515ea7

Browse files
committed
fixed j2eo directory issue
1 parent 195236e commit 3515ea7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/scala/org/polystat/Java.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ object Java:
9494
for
9595
code <- readCodeFromStdin.compile.string
9696
stdinTmp <- Files[IO].createTempDirectory.map(path =>
97-
path / "stdin.eo"
97+
path / "stdin.java"
9898
)
9999
_ <- writeOutputTo(stdinTmp)(code)
100100
_ <- runJ2EO(
@@ -108,6 +108,15 @@ object Java:
108108
runJ2EO(j2eoVersion, j2eo, inputDir = path, outputDir = tmp)
109109
case Input.FromDirectory(path) =>
110110
runJ2EO(j2eoVersion, j2eo, inputDir = path, outputDir = tmp)
111+
// J2EO deletes the tmp directory when there are no files to analyze
112+
// This causes the subsequent call to EO.analyze to fail, because there is no temp directory.
113+
// The line below patches this issue by creating the temp directory if it was deleted by J2EO.
114+
_ <- Files[IO]
115+
.exists(tmp)
116+
.ifM(
117+
ifTrue = IO.unit,
118+
ifFalse = Files[IO].createDirectory(tmp),
119+
)
111120
_ <- EO.analyze(
112121
cfg.copy(input = Input.FromDirectory(tmp))
113122
)

0 commit comments

Comments
 (0)