Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 3a925f8

Browse files
committed
Avoid duplication: read nodejs version from file
1 parent 8fc3134 commit 3a925f8

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

build.sbt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,20 @@ lazy val core = (project in file("./core"))
2929
libraryDependencies ++= Dependencies.core.value
3030
)
3131

32-
lazy val nodejs_v14 = createNodeVersionSpecificProject("14.15.4")
33-
lazy val nodejs_v12 = createNodeVersionSpecificProject("12.20.1")
34-
lazy val nodejs_v10 = createNodeVersionSpecificProject("10.23.1")
32+
lazy val nodeVerMap = {
33+
val ciYaml = scala.io.Source.fromFile(".github/workflows/ci.yaml")
34+
try {
35+
val nodejsVersionLine = ciYaml.getLines().filter(_.contains("nodejs:")).toSeq.head
36+
"\\d+\\.\\d+\\.\\d+".r.findAllIn(nodejsVersionLine).toSeq match {
37+
case Seq(a, b, c) => Map("14" -> a, "12" -> b, "10" -> c)
38+
}
39+
} finally {
40+
ciYaml.close()
41+
}
42+
}
43+
lazy val nodejs_v14 = createNodeVersionSpecificProject(nodeVerMap("14"))
44+
lazy val nodejs_v12 = createNodeVersionSpecificProject(nodeVerMap("12"))
45+
lazy val nodejs_v10 = createNodeVersionSpecificProject(nodeVerMap("10"))
3546

3647
def createNodeVersionSpecificProject(nodeFullVersion: String) = {
3748
val majorVersion = nodeFullVersion.split("\\.")(0)

0 commit comments

Comments
 (0)