Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a relative path for loading the JS main #566

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions effekt/jvm/src/main/scala/effekt/Runner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +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 = path.unixPath.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"
Expand Down Expand Up @@ -183,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 =
Expand Down
Loading