Reputation: 943
I have a cross build project with the following structure:
<project root>
+- jvm
| +- src/main/scala/main.Scala
+- js
| +- src/main/scala/main.Scala
+- shared
+- src/main/scala/myLibrary.scala
+- src/main/resources/myjsfile.js
Now in my js main.Scala file, I want to read in myjsfile.js.
I know in a standard Scala JVM project I can do the following:
val is = getClass.getClassLoader.getResourceAsStream("myjsfile.js")
val str = scala.io.Source.fromInputStream(is).mkString
Now my question is, how can I do this with my current folder structure?
If I run the following main.scala (js version):
package example
object Main extends App {
val is = getClass.getClassLoader.getResourceAsStream("")
val str = scala.io.Source.fromInputStream(is).mkString
println(str)
}
I get the following error:
org.scalajs.jsenv.ExternalJSRun$ClosedException: Termination was requested by user
[error] at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:184)
[error] stack trace is suppressed; run last fooJS / Compile / run for the full output
[error] (fooJS / Compile / run) org.scalajs.jsenv.ExternalJSRun$ClosedException: Termination was requested by user
[error] Total time: 3 s, completed 25 Jun 2020, 10:56:05
[IJ]sbt:root>
How can I overcome this error?
Upvotes: 1
Views: 157