mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Merge pull request #137 from vic/set-path-version
Allow `asdf local` and `asdf global` to take path: versions
This commit is contained in:
commit
8709d197f1
@ -55,6 +55,12 @@ check_if_version_exists() {
|
||||
local plugin=$1
|
||||
local version=$2
|
||||
local version_dir=$(asdf_dir)/installs/$plugin/$version
|
||||
|
||||
# if version starts with path: use that directory
|
||||
if [ "${version/path:}" != "$version" ]; then
|
||||
version_dir=$(echo $version | cut -d: -f 2)
|
||||
fi
|
||||
|
||||
if [ ! -d $version_dir ]; then
|
||||
display_error "version $version is not installed for $plugin"
|
||||
exit 1
|
||||
|
@ -70,6 +70,19 @@ teardown() {
|
||||
[ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.1.0" ]
|
||||
}
|
||||
|
||||
@test "local should fail to set a path:dir if dir does not exists " {
|
||||
run local_command "dummy" "path:$PROJECT_DIR/local"
|
||||
[ "$output" = "version path:$PROJECT_DIR/local is not installed for dummy" ]
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "local should set a path:dir if dir exists " {
|
||||
mkdir -p $PROJECT_DIR/local
|
||||
run local_command "dummy" "path:$PROJECT_DIR/local"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy path:$PROJECT_DIR/local" ]
|
||||
}
|
||||
|
||||
@test "global should create a global .tool-versions file if it doesn't exist" {
|
||||
run global_command "dummy" "1.1.0"
|
||||
[ "$status" -eq 0 ]
|
||||
@ -88,3 +101,16 @@ teardown() {
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat $HOME/.tool-versions)" = "dummy 1.1.0" ]
|
||||
}
|
||||
|
||||
@test "global should fail to set a path:dir if dir does not exists " {
|
||||
run global_command "dummy" "path:$PROJECT_DIR/local"
|
||||
[ "$output" = "version path:$PROJECT_DIR/local is not installed for dummy" ]
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "global should set a path:dir if dir exists " {
|
||||
mkdir -p $PROJECT_DIR/local
|
||||
run global_command "dummy" "path:$PROJECT_DIR/local"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat $HOME/.tool-versions)" = "dummy path:$PROJECT_DIR/local" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user