Skip to content

Commit

Permalink
Check that golem-scalajs-wit-bindgen exists on user's path (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
hearnadam authored May 8, 2024
1 parent 680acf0 commit ebc36f0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/scala/cloud/golem/WasmComponentPluginInternal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ private[golem] object WasmComponentPluginInternal {
val wasmComponentWitBindgenOutput = (Compile / sourceManaged).value / "scala" / wasmComponentPackageName.value / "Api.scala"
import scala.sys.process.*

val bindGenCommand = "golem-scalajs-wit-bindgen"
val bindgenCommandExists = Seq("bash", "-xc", s"which $bindGenCommand").! == 0
if (!bindgenCommandExists) {
sys.error(s"""
|$bindGenCommand not found. Run `cargo install $bindGenCommand`.
|https://learn.golem.cloud/docs/building-components/tier-1/scala
""".stripMargin)
}

val output = Seq(
"bash",
"-xc",
s"golem-scalajs-wit-bindgen -w ${wasmComponentWitFullPath.value} -p ${wasmComponentPackageName.value}"
s"$bindGenCommand -w ${wasmComponentWitFullPath.value} -p ${wasmComponentPackageName.value}"
).!!

IO.write(wasmComponentWitBindgenOutput, output)
Expand Down

0 comments on commit ebc36f0

Please sign in to comment.