Skip to content

Commit e625119

Browse files
committed
fixed self-update (fixes #54, fixes #44)
1 parent 8ff7798 commit e625119

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.gradle
22
build/
33
target/
4+
out/
45

56
# Ignore Gradle GUI config
67
gradle-app.setting

src/main/kotlin/kscript/app/Kscript.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,22 @@ fun main(args: Array<String>) {
7676
if (docopt.getBoolean(("self-update"))) {
7777
if (evalBash("which kscript | grep .sdkman").stdout.isNotBlank()) {
7878
info("Installing latest version of kscript...")
79-
println("sdkman_auto_answer=true && sdk install kscript")
79+
// println("sdkman_auto_answer=true && sdk install kscript")
80+
81+
// create update script
82+
val updateScript = File(KSCRIPT_CACHE_DIR, "self_update.sh").apply {
83+
writeText("""
84+
source ${"$"}{HOME}/.bash_profile
85+
sdk --help
86+
sdkman_auto_answer=true && sdk install kscript
87+
""".trimIndent())
88+
setExecutable(true)
89+
}
90+
91+
println(updateScript.absolutePath)
8092
} else {
8193
info("Self-update is currently just supported via sdkman.")
94+
info("Please download a new release from https://github.com/holgerbrandl/kscript")
8295
// todo port sdkman-indpendent self-update
8396
}
8497

0 commit comments

Comments
 (0)