Skip to content

Control automatic port forwarding with a devcontainer.json file #49

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

Merged
merged 9 commits into from
Feb 27, 2025
Prev Previous commit
Next Next commit
Split devcontainer.json file path out to a settings module
  • Loading branch information
aaronlehmann committed Feb 26, 2025
commit 933e1d4711e4e0049f9942af679c6fc764500849
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import org.json.JSONObject
import com.coder.jetbrains.settings.CoderBackendSettings

/**
* Automatically forward ports that have something listening on them by scanning
Expand Down Expand Up @@ -56,8 +57,7 @@ class CoderPortForwardService(
}

private fun start() {
// TODO: make path configurable?
val devcontainerFile = File(System.getProperty("user.home"), ".cache/JetBrains/devcontainer.json")
val devcontainerFile = CoderBackendSettings.getDevcontainerFile()
if (devcontainerFile.exists()) {
try {
val json = devcontainerFile.readText()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.coder.jetbrains.settings

import java.io.File

object CoderBackendSettings {
fun getDevcontainerFile(): File {
// TODO: make path configurable?
return File(System.getProperty("user.home"), ".cache/JetBrains/devcontainer.json")
}
}