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

Added Windows compatibility to build and test scripts #6

Merged
merged 1 commit into from
Apr 16, 2017
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
7 changes: 5 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ val Error = 1 // 1 exit code

PlayKeys.playRunHooks <+= baseDirectory.map(UIBuild.apply)

def runScript(script: String)(implicit dir: File): Int = Process(script, dir) !
val isWindows = System.getProperty("os.name").toLowerCase().contains("win")

def runScript(script: String)(implicit dir: File): Int = {
if(isWindows){ Process("cmd /c " + script, dir) } else { Process(script, dir) } }!

def uiWasInstalled(implicit dir: File): Boolean = (dir / "node_modules").exists()

Expand Down Expand Up @@ -72,4 +75,4 @@ dist <<= dist dependsOn `ui-prod-build`

stage <<= stage dependsOn `ui-prod-build`

test <<= (test in Test) dependsOn `ui-test`
test <<= (test in Test) dependsOn `ui-test`
15 changes: 12 additions & 3 deletions project/UIBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ object UIBuild {

var process: Option[Process] = None

var npmInstall: String = "npm install"
var npmRun: String = "npm run build -- --watch"

// Windows requires npm commands prefixed with cmd /c
if (System.getProperty("os.name").toLowerCase().contains("win")){
npmInstall = "cmd /c" + npmInstall
npmRun = "cmd /c" + npmRun
}

override def beforeStarted(): Unit = {
if (!(base / "ui" / "node_modules").exists()) Process("npm install", base / "ui").!
if (!(base / "ui" / "node_modules").exists()) Process(npmInstall, base / "ui").!
}

override def afterStarted(addr: InetSocketAddress): Unit = {
process = Option(
Process("npm run build -- --watch", base / "ui").run
Process(npmRun, base / "ui").run
)
}

Expand All @@ -28,4 +37,4 @@ object UIBuild {

UIBuildHook
}
}
}
8 changes: 6 additions & 2 deletions test/ProtractorSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ class ProtractorSpec extends PlaySpec with OneServerPerSuite {
}

private def runProtractorTests(baseUrl: String): Int = {
Process(s"npm run play-e2e -- --baseUrl $baseUrl", app.getFile("ui"))
var runProtractor: String = "npm run play-e2e -- --baseUrl " + baseUrl
if (System.getProperty("os.name").toLowerCase().contains("win")){
runProtractor = "cmd /c " + runProtractor
}
Process(runProtractor, app.getFile("ui"))
.run(pipingInputAndOutput)
.exitValue()
}
Expand All @@ -35,4 +39,4 @@ class ProtractorSpec extends PlaySpec with OneServerPerSuite {
stderr => fromInputStream(stderr).getLines().foreach(println)
)

}
}