2
0

RunTerminal.kt 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright 2020 Mamoe Technologies and contributors.
  3. *
  4. * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
  5. * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
  6. *
  7. * https://github.com/mamoe/mirai/blob/master/LICENSE
  8. */
  9. package net.mamoe.mirai.console.terminal
  10. import kotlinx.coroutines.runBlocking
  11. import net.mamoe.mirai.console.MiraiConsole
  12. import java.io.File
  13. fun main() {
  14. configureUserDir()
  15. MiraiConsoleTerminalLoader.startAsDaemon()
  16. runCatching { runBlocking { MiraiConsole.job.join() } }
  17. }
  18. internal fun configureUserDir() {
  19. val projectDir = runCatching {
  20. File(".").resolve("frontend").resolve("mirai-console-terminal")
  21. }.getOrElse { return }
  22. if (projectDir.isDirectory) {
  23. val run = projectDir.resolve("run")
  24. run.mkdir()
  25. System.setProperty("user.dir", run.absolutePath)
  26. println("[Mirai Console] Set user.dir = ${run.absolutePath}")
  27. }
  28. }