Skip to content

Commit

Permalink
Merge pull request #65 from tindzk/bug/scaffold-root-paths
Browse files Browse the repository at this point in the history
Scaffold: Set correct root path when only one platform was selected
  • Loading branch information
tindzk authored Nov 3, 2019
2 parents d10d4d4 + 7c6122d commit 0ec8e7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/main/scala/seed/cli/Scaffold.scala
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ class Scaffold(log: Log, silent: Boolean = false) {
(if (scalaJsVersion.isEmpty) List() else List(
NamedTable(
List("module", moduleName, "js"),
Map("root" -> Str("js")) ++
Map("root" -> (if (platforms.size == 1) Str(".") else Str("js"))) ++
(if (
jsScalaVersion.isDefined && !jsScalaVersion.contains(jvmScalaVersion)
) Map("scalaVersion" -> Str(jsScalaVersion.get)) else Map()
Expand Down Expand Up @@ -622,7 +622,7 @@ class Scaffold(log: Log, silent: Boolean = false) {
NamedTable(
List("module", moduleName, "jvm"),
Map(
"root" -> Str("jvm"),
"root" -> (if (platforms.size == 1) Str(".") else Str("jvm")),
"sources" -> Arr(List(
if (platforms.size == 1) Str("src") else Str("jvm/src")
))
Expand All @@ -644,7 +644,7 @@ class Scaffold(log: Log, silent: Boolean = false) {
(if (scalaNativeVersion.isEmpty) List() else List(
NamedTable(
List("module", moduleName, "native"),
Map("root" -> Str("native")) ++
Map("root" -> (if (platforms.size == 1) Str(".") else Str("native"))) ++
(if (
nativeScalaVersion.isDefined &&
!nativeScalaVersion.contains(jvmScalaVersion)
Expand Down
8 changes: 6 additions & 2 deletions src/test/scala/seed/cli/ScaffoldSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import minitest.SimpleTestSuite
import seed.Log
import seed.model.{Organisation, Platform}
import toml.Node.NamedTable
import toml.Value.Str
import toml.Value.{Arr, Str}

object ScaffoldSpec extends SimpleTestSuite {
private val scaffold = new Scaffold(Log.urgent, silent = true)

test("Create build file one non-JVM platform") {
test("Create build file for one non-JVM platform") {
val result = scaffold.generateBuildFile(
"example",
stable = true,
Expand All @@ -27,6 +27,10 @@ object ScaffoldSpec extends SimpleTestSuite {

val module = result.nodes(1).asInstanceOf[NamedTable]
assertEquals(module.ref, List("module", "example", "native"))
assertEquals(
module.values,
Map("root" -> Str("."), "sources" -> Arr(List(Str("src"))))
)

assertEquals(result.nodes.length, 2)
}
Expand Down

0 comments on commit 0ec8e7b

Please sign in to comment.