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

Update stack at 2021/01/11 #1

Open
jiyuujin opened this issue Jan 11, 2021 · 2 comments
Open

Update stack at 2021/01/11 #1

jiyuujin opened this issue Jan 11, 2021 · 2 comments
Labels

Comments

@jiyuujin
Copy link
Contributor

  • sbt 1.4.6
  • scala 2.13.4
  • play 2.7.3
@jiyuujin
Copy link
Contributor Author

jiyuujin commented Jan 11, 2021

  • Process の扱いが変わった
  • オーバライドメソッド afterStarted() の扱いが変わった
import scala.sys.process.Process

def apply(base: File): PlayRunHook = {
  object WebpackServerScript extends PlayRunHook {
    var process: Option[Process] = None
    val isWin: Boolean = System.getProperty("os.name").toUpperCase().indexOf("WIN") >= 0
    val config: Config = ConfigFactory.parseFile(new File("conf/application.conf")).resolve()
    val npmCommand: String = config.getString("npm.command")
    override def afterStarted(): Unit = {
      process = if (isWin)
        Option(Process(s"cmd /c $npmCommand run serve", base).run)
      else
        Option(Process(s"""$npmCommand run serve""", base).run)
    }
    override def afterStopped(): Unit = {
      process.foreach(p => { p.destroy() })
      process = None
    }
  }

  WebpackServerScript
}

@jiyuujin
Copy link
Contributor Author

Update https://github.com/jiyuujin/resources-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant