Hackers...do you have a better way to write this piece of code?
Copy code
import org.jetbrains.kotlin.com.intellij.util.TimeoutUtil
val formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")
val regex = Regex("^V\\d+__.*\\.js\$")
File("src/main/resources/db/migration").walk()
.filterNot { it.isDirectory or it.name.matches(regex) }
.forEach {
val timestamp = ZonedDateTime.now(ZoneOffset.UTC).format(formatter)
it.renameTo(File("${it.parent}${File.separatorChar}V${timestamp}__${it.name}"))
TimeoutUtil.sleep(100) // Wait for a moment to avoid prefix conflicts when renaming multiple files in a batch
}
s
scott
06/19/2017, 3:42 PM
vadimvera: is this just a script you occasionally run? or build script? If so, it’s probobly fine
x
x80486
06/19/2017, 3:54 PM
Yeah, I use to prefix the "migration" files in order to execute then=m and make them "unique" in the Gradle build