MakarkinSAkvelon commented on code in PR #25022:
URL: https://github.com/apache/beam/pull/25022#discussion_r1093269220


##########
playground/terraform/build.gradle.kts:
##########
@@ -295,7 +295,25 @@ tasks.register("prepareConfig") {
         val configFileName = "config.g.dart"
         val modulePath = 
project(":playground:frontend").projectDir.absolutePath
         var file = File("$modulePath/lib/$configFileName")
-
+        val lines = file.readLines()
+        val endOfSlice = lines.indexOfFirst { it.contains("Generated content 
below") }
+        if (endOfSlice != -1) {
+            val oldContent = lines.slice(0 until endOfSlice)
+            val flagDelete = file.delete()
+            if (!flagDelete) {
+                throw kotlin.RuntimeException("Deleting file failed")
+            }
+            val sb = kotlin.text.StringBuilder()
+            val lastLine = oldContent[oldContent.size - 1]
+            oldContent.forEach {
+                if (it == lastLine) {
+                    sb.append(it)
+                } else {
+                    sb.appendLine(it)
+                }
+            }
+            file.writeText(sb.toString())
+        }

Review Comment:
   In case we leave this file - config.g.dart - "as-is" Frontend will use the 
wrong Backend URLs and the playground will not work at all



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to