Fix config command when using vscode (#926)

This commit is contained in:
Felipe Santos
2021-06-17 13:01:39 -03:00
committed by GitHub
parent 49b6b9cd63
commit b18d8aaacb
2 changed files with 10 additions and 5 deletions

View File

@@ -17,14 +17,14 @@
#
function __sdk_config() {
local -r editor=${EDITOR:=vi}
local -r editor=(${EDITOR:=vi})
if ! command -v "$editor" > /dev/null; then
if ! command -v "${editor[@]}" > /dev/null; then
__sdkman_echo_red "No default editor configured."
__sdkman_echo_yellow "Please set the default editor with the EDITOR environment variable."
return 1
fi
"$editor" "${SDKMAN_DIR}/etc/config"
"${editor[@]}" "${SDKMAN_DIR}/etc/config"
}

View File

@@ -23,11 +23,15 @@ class ConfigCommandSpec extends SdkmanEnvSpecification {
where:
setupEnv << [
{
it.execute('nano() { echo "nano was called with $1"; }')
it.execute('nano() { echo "nano was called with $*"; }')
it.execute("EDITOR=nano")
},
{
it.execute('vi() { echo "vi was called with $1"; }')
it.execute('code() { echo "code was called with $*"; }')
it.execute("EDITOR='code --wait'")
},
{
it.execute('vi() { echo "vi was called with $*"; }')
it.execute("unset EDITOR")
},
{
@@ -36,6 +40,7 @@ class ConfigCommandSpec extends SdkmanEnvSpecification {
]
verifyOutput << [
{ output, baseDirectory -> output.contains("nano was called with ${baseDirectory}/.sdkman/etc/config") },
{ output, baseDirectory -> output.contains("code was called with --wait ${baseDirectory}/.sdkman/etc/config") },
{ output, baseDirectory -> output.contains("vi was called with ${baseDirectory}/.sdkman/etc/config") },
{ output, _ -> output.contains("No default editor configured.") }
]