Skip to content

Commit

Permalink
Merge pull request #6 from ronniegane/ronniegane/windows-compatibility
Browse files Browse the repository at this point in the history
Added Windows compatibility to build and test scripts
  • Loading branch information
lbialy authored Apr 16, 2017
2 parents 446cbdf + 12a9cf6 commit 5837685
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
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)
)

}
}

0 comments on commit 5837685

Please sign in to comment.