From 9ee24b4163ba7bdcd179b5c12765d4d31d49d892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Mon, 2 Sep 2024 16:44:24 +0200 Subject: [PATCH 1/2] Use a relative path for loading the JS main --- effekt/jvm/src/main/scala/effekt/Runner.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/effekt/jvm/src/main/scala/effekt/Runner.scala b/effekt/jvm/src/main/scala/effekt/Runner.scala index 79d80ca67..765ad57c7 100644 --- a/effekt/jvm/src/main/scala/effekt/Runner.scala +++ b/effekt/jvm/src/main/scala/effekt/Runner.scala @@ -147,8 +147,9 @@ object JSNodeRunner extends Runner[String] { def build(path: String)(using C: Context): String = val out = C.config.outputPath().getAbsolutePath val jsFilePath = (out / path).canonicalPath.escape + val jsFileName = jsFilePath.split("/").last // create "executable" using shebang besides the .js file - val jsScript = s"require('${jsFilePath}').main()" + val jsScript = s"require('./${jsFileName}').main()" os match { case OS.POSIX => val shebang = "#!/usr/bin/env node" From 8c1c05780108664095cf0b2147edd67e121d9e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcial=20Gai=C3=9Fert?= Date: Mon, 2 Sep 2024 16:53:35 +0200 Subject: [PATCH 2/2] Fix path handling on Windows --- effekt/jvm/src/main/scala/effekt/Runner.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/effekt/jvm/src/main/scala/effekt/Runner.scala b/effekt/jvm/src/main/scala/effekt/Runner.scala index 765ad57c7..b62b69ea8 100644 --- a/effekt/jvm/src/main/scala/effekt/Runner.scala +++ b/effekt/jvm/src/main/scala/effekt/Runner.scala @@ -147,9 +147,10 @@ object JSNodeRunner extends Runner[String] { def build(path: String)(using C: Context): String = val out = C.config.outputPath().getAbsolutePath val jsFilePath = (out / path).canonicalPath.escape - val jsFileName = jsFilePath.split("/").last + val jsFileName = path.unixPath.split("/").last // create "executable" using shebang besides the .js file val jsScript = s"require('./${jsFileName}').main()" + os match { case OS.POSIX => val shebang = "#!/usr/bin/env node" @@ -184,7 +185,7 @@ object JSWebRunner extends Runner[String] { import java.nio.file.Path val out = C.config.outputPath().getAbsolutePath val jsFilePath = (out / path).unixPath - val jsFileName = jsFilePath.split("/").last + val jsFileName = path.unixPath.split("/").last val htmlFilePath = jsFilePath.stripSuffix(s".$extension") + ".html" val mainName = "$" + jsFileName.stripSuffix(".js") + ".main" val htmlContent =