-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Can now be installed for bash and zsh
- Loading branch information
1 parent
742c7b2
commit 5905cfe
Showing
8 changed files
with
124 additions
and
35 deletions.
There are no files selected for viewing
54 changes: 41 additions & 13 deletions
54
sdkman-ui/src/main/java/io/github/jagodevreede/sdkmanui/install/ShellInstaller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
#!/usr/bin/env bash | ||
if not exist "%homedrive%%homepath%\.sdkman" mkdir %homedrive%%homepath%\.sdkman | ||
if not exist "%homedrive%%homepath%\.sdkman\tmp" mkdir %homedrive%%homepath%\.sdkman\tmp | ||
if exist "%homedrive%%homepath%\.sdkman\tmp\exit-script.cmd" del %homedrive%%homepath%\.sdkman\tmp\exit-script.cmd | ||
mkdir -p ~/.sdkman/tmp | ||
rm -f ~/.sdkman/tmp/exit-script.cmd | ||
|
||
sdkman-ui.exe | ||
~/.sdkman/ui/sdkman-ui 2> /dev/null | ||
|
||
:waitloop | ||
IF EXIST "%homedrive%%homepath%\.sdkman\tmp\exit-script.cmd" GOTO waitloopend | ||
timeout /t 1 /nobreak > nul | ||
goto waitloop | ||
:waitloopend | ||
call %homedrive%%homepath%\.sdkman\tmp\exit-script.cmd | ||
if [ -f ~/.sdkman/tmp/exit-script.cmd ]; then | ||
source ~/.sdkman/tmp/exit-script.cmd | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function sdkui { | ||
source ~/.sdkman/ui/sdkui.sh | ||
} |
Empty file.
55 changes: 55 additions & 0 deletions
55
sdkman-ui/src/test/java/io/github/jagodevreede/sdkmanui/install/ShellInstallerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package io.github.jagodevreede.sdkmanui.install; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import static io.github.jagodevreede.sdkmanui.install.ShellInstaller.BEGIN_MARKER; | ||
import static io.github.jagodevreede.sdkmanui.install.ShellInstaller.END_MARKER; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ShellInstallerTest { | ||
@TempDir | ||
Path tempDir; | ||
Path tempFile; | ||
|
||
ShellInstaller subject = new ShellInstaller(); | ||
|
||
@BeforeEach | ||
void createTempFile() throws IOException { | ||
tempFile = tempDir.resolve("test.txt"); | ||
Files.writeString(tempFile, "Start of file\n"); | ||
} | ||
|
||
@Test | ||
void checkWithCleanFile() throws IOException { | ||
subject.addToRcFile(tempFile.toFile()); | ||
|
||
String fileContent = Files.readString(tempFile); | ||
|
||
assertThat(fileContent) | ||
.containsOnlyOnce("Start of file") | ||
.containsOnlyOnce(BEGIN_MARKER) | ||
.containsOnlyOnce("function") | ||
.containsOnlyOnce(END_MARKER); | ||
} | ||
|
||
@Test | ||
void checkUpdate() throws IOException { | ||
Files.writeString(tempFile, "Start of file\n" + BEGIN_MARKER + "\n" + "old stuff to be overwritten\n" + END_MARKER); | ||
|
||
subject.addToRcFile(tempFile.toFile()); | ||
|
||
String fileContent = Files.readString(tempFile); | ||
|
||
assertThat(fileContent) | ||
.containsOnlyOnce("Start of file") | ||
.containsOnlyOnce(BEGIN_MARKER) | ||
.containsOnlyOnce("function") | ||
.containsOnlyOnce(END_MARKER); | ||
} | ||
} |