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

Discover node executable with nvm #124

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/hydrogen
20 changes: 20 additions & 0 deletions project/AsyncUtilsBuildPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import _root_.scalafix.sbt.ScalafixTestkitPlugin.autoImport.*
import _root_.scalafix.sbt.{ScalafixPlugin, ScalafixTestkitPlugin}
import com.typesafe.tools.mima.plugin.MimaPlugin
import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport.*
import org.scalajs.jsenv.JSEnv
import org.scalajs.jsenv.nodejs.NodeJSEnv
import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport.*
import org.typelevel.sbt.TypelevelMimaPlugin.autoImport.*
import org.typelevel.sbt.gha.GenerativePlugin.autoImport.*
import org.typelevel.sbt.mergify.MergifyPlugin
Expand Down Expand Up @@ -109,6 +112,7 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
"org.typelevel" %% "cats-tagless-core" % CatsTaglessV,
) ++ (if (scalaVersion.value.startsWith("2")) scala2CompilerPlugins else Nil)
},
jsEnv := nvmJsEnv.value,
)
.jvmPlatform(Scala2Versions)
.jsPlatform(Scala2Versions)
Expand All @@ -123,6 +127,7 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
"org.typelevel" %% "cats-effect" % CatsEffect3V,
) ++ (if (scalaVersion.value.startsWith("2")) scala2CompilerPlugins else Nil)
},
jsEnv := nvmJsEnv.value,
)
.dependsOn(`async-utils-core`)

Expand Down Expand Up @@ -328,6 +333,18 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
*/
githubWorkflowScalaVersions := Seq("2.13"),
githubWorkflowBuildSbtStepPreamble := Nil,

nodeExecutable :=
scala.util.Try {
import scala.sys.process.*

Process("bash" :: "-c" :: ". $HOME/.nvm/nvm.sh --no-use && nvm which" :: Nil)
.lineStream
.last
}
.toOption
.map(file),
nvmJsEnv := new NodeJSEnv(nodeExecutable.value.map(_.getAbsolutePath).foldLeft(NodeJSEnv.Config())(_ withExecutable _))
)

override def extraProjects: Seq[Project] = autoImport.allProjects
Expand All @@ -336,4 +353,7 @@ object AsyncUtilsBuildPlugin extends AutoPlugin {
def %(vav: Version): ModuleID =
oan % vav.toString
}

private lazy val nvmJsEnv: TaskKey[JSEnv] = taskKey("use nvm to find node")
private lazy val nodeExecutable: TaskKey[Option[File]] = taskKey("path to Node executable for JS tasks")
}