mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-01 04:46:43 +08:00
fix(jetbrains): move findBun into PrepareLocalCliTask to avoid non-static inner class error
This commit is contained in:
@@ -18,38 +18,6 @@ plugins {
|
||||
alias(libs.plugins.openapi.generator)
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the absolute path to `bun`. The Gradle daemon's PATH is often
|
||||
* stripped down and doesn't include Homebrew or user-local bin dirs.
|
||||
* Probe common install locations so the build works without manual PATH setup.
|
||||
*/
|
||||
fun findBun(): String {
|
||||
// 1. Already on PATH?
|
||||
val which = runCatching {
|
||||
ProcessBuilder("which", "bun")
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
.inputStream.bufferedReader().readLine()?.trim()
|
||||
}.getOrNull()
|
||||
if (which != null && File(which).isFile) return which
|
||||
|
||||
// 2. Common install locations
|
||||
val home = System.getProperty("user.home")
|
||||
val candidates = listOf(
|
||||
"$home/.bun/bin/bun",
|
||||
"/opt/homebrew/bin/bun",
|
||||
"/usr/local/bin/bun",
|
||||
"$home/.nvm/current/bin/bun",
|
||||
)
|
||||
for (path in candidates) {
|
||||
val f = File(path)
|
||||
if (f.isFile && f.canExecute()) return f.absolutePath
|
||||
}
|
||||
|
||||
// 3. Fall back — let the OS resolve it (will fail with a clear message)
|
||||
return "bun"
|
||||
}
|
||||
|
||||
abstract class PrepareLocalCliTask : DefaultTask() {
|
||||
@get:InputFile
|
||||
abstract val script: RegularFileProperty
|
||||
@@ -78,6 +46,38 @@ abstract class PrepareLocalCliTask : DefaultTask() {
|
||||
commandLine(findBun(), "script/build.ts", "--prepare-cli")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the absolute path to `bun`. The Gradle daemon's PATH is often
|
||||
* stripped down and doesn't include Homebrew or user-local bin dirs.
|
||||
* Probe common install locations so the build works without manual PATH setup.
|
||||
*/
|
||||
private fun findBun(): String {
|
||||
// 1. Already on PATH?
|
||||
val which = runCatching {
|
||||
ProcessBuilder("which", "bun")
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
.inputStream.bufferedReader().readLine()?.trim()
|
||||
}.getOrNull()
|
||||
if (which != null && File(which).isFile) return which
|
||||
|
||||
// 2. Common install locations
|
||||
val home = System.getProperty("user.home")
|
||||
val candidates = listOf(
|
||||
"$home/.bun/bin/bun",
|
||||
"/opt/homebrew/bin/bun",
|
||||
"/usr/local/bin/bun",
|
||||
"$home/.nvm/current/bin/bun",
|
||||
)
|
||||
for (path in candidates) {
|
||||
val f = File(path)
|
||||
if (f.isFile && f.canExecute()) return f.absolutePath
|
||||
}
|
||||
|
||||
// 3. Fall back — let the OS resolve it (will fail with a clear message)
|
||||
return "bun"
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
|
||||
Reference in New Issue
Block a user