mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-05-19 14:06:45 -04:00
Fix config command when using vscode (#926)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
@@ -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.") }
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user