This commit is contained in:
DalHo Park 2016-11-05 15:39:08 +09:00
commit d46d6ca6df
6 changed files with 70 additions and 19 deletions

View File

@ -4,9 +4,21 @@
Features Features
* Determine global tool version even when used outside of home directory (#106)
##0.2.0
Features
* Improve plugin API for legacy file support (#87)
* Unify `asdf local` and `asdf global` version getters as `asdf current` (#83) * Unify `asdf local` and `asdf global` version getters as `asdf current` (#83)
* Rename `asdf which` to `asdf current` (#78) * Rename `asdf which` to `asdf current` (#78)
Fixed Bugs
* Fix bug that caused the `local` command to crash when the directory contains whitespace (#90)
* Misc typo corrections (#93, #99)
##0.1.0 ##0.1.0
* First tagged release * First tagged release

View File

@ -8,7 +8,7 @@ Supported languages include Ruby, Node.js, Elixir and more. Supporting a new lan
Copy-paste the following into command line: Copy-paste the following into command line:
```bash ```bash
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.1.0 git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.2.0
``` ```
@ -32,7 +32,7 @@ echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish
mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
``` ```
> For most plugins, it is good if you have installed the following packages OR their equivalent on you OS > For most plugins, it is good if you have installed the following packages OR their equivalent on your OS
> * **OS X**: Install these via homebrew `automake autoconf openssl libyaml readline libxslt libtool unixodbc` > * **OS X**: Install these via homebrew `automake autoconf openssl libyaml readline libxslt libtool unixodbc`
> * **Ubuntu**: `automake autoconf libreadline-dev libncurses-dev libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev` > * **Ubuntu**: `automake autoconf libreadline-dev libncurses-dev libssl-dev libyaml-dev libxslt-dev libffi-dev libtool unixodbc-dev`
@ -56,7 +56,9 @@ Plugins are how asdf understands how to handle different packages. Below is a li
| Go | [kennyp/asdf-golang](https://github.com/kennyp/asdf-golang) | [![Build Status](https://travis-ci.org/kennyp/asdf-golang.svg?branch=master)](https://travis-ci.org/kennyp/asdf-golang) | Go | [kennyp/asdf-golang](https://github.com/kennyp/asdf-golang) | [![Build Status](https://travis-ci.org/kennyp/asdf-golang.svg?branch=master)](https://travis-ci.org/kennyp/asdf-golang)
| Lua | [Stratus3D/asdf-lua](https://github.com/Stratus3D/asdf-lua) | [![Build Status](https://travis-ci.org/Stratus3D/asdf-lua.svg?branch=master)](https://travis-ci.org/Stratus3D/asdf-lua) | Lua | [Stratus3D/asdf-lua](https://github.com/Stratus3D/asdf-lua) | [![Build Status](https://travis-ci.org/Stratus3D/asdf-lua.svg?branch=master)](https://travis-ci.org/Stratus3D/asdf-lua)
| OpenResty | [smashedtoatoms/asdf-openresty](https://github.com/smashedtoatoms/asdf-openresty) | [![Build Status](https://travis-ci.org/smashedtoatoms/asdf-openresty.svg?branch=master)](https://travis-ci.org/smashedtoatoms/asdf-openresty) | OpenResty | [smashedtoatoms/asdf-openresty](https://github.com/smashedtoatoms/asdf-openresty) | [![Build Status](https://travis-ci.org/smashedtoatoms/asdf-openresty.svg?branch=master)](https://travis-ci.org/smashedtoatoms/asdf-openresty)
| MongoDB | [sylph01/asdf-mongodb](https://github.com/sylph01/asdf-mongodb) | [![Build Status](https://travis-ci.org/sylph01/asdf-mongodb.svg?branch=master)](https://travis-ci.org/sylph01/asdf-mongodb)
| Node.js | [asdf-vm/asdf-nodejs](https://github.com/asdf-vm/asdf-nodejs) | [![Build Status](https://travis-ci.org/asdf-vm/asdf-nodejs.svg?branch=master)](https://travis-ci.org/asdf-vm/asdf-nodejs) | Node.js | [asdf-vm/asdf-nodejs](https://github.com/asdf-vm/asdf-nodejs) | [![Build Status](https://travis-ci.org/asdf-vm/asdf-nodejs.svg?branch=master)](https://travis-ci.org/asdf-vm/asdf-nodejs)
| PHP | [odarriba/asdf-php](https://github.com/odarriba/asdf-php) | [![Build Status](https://travis-ci.org/odarriba/asdf-php.svg?branch=master)](https://travis-ci.org/odarriba/asdf-php)
| Postgres | [smashedtoatoms/asdf-postgres](https://github.com/smashedtoatoms/asdf-postgres) | [![Build Status](https://travis-ci.org/smashedtoatoms/asdf-postgres.svg?branch=master)](https://travis-ci.org/smashedtoatoms/asdf-postgres) | Postgres | [smashedtoatoms/asdf-postgres](https://github.com/smashedtoatoms/asdf-postgres) | [![Build Status](https://travis-ci.org/smashedtoatoms/asdf-postgres.svg?branch=master)](https://travis-ci.org/smashedtoatoms/asdf-postgres)
| Python | [tuvistavie/asdf-python](https://github.com/tuvistavie/asdf-python) | [![Build Status](https://travis-ci.org/tuvistavie/asdf-python.svg?branch=master)](https://travis-ci.org/tuvistavie/asdf-python) | Python | [tuvistavie/asdf-python](https://github.com/tuvistavie/asdf-python) | [![Build Status](https://travis-ci.org/tuvistavie/asdf-python.svg?branch=master)](https://travis-ci.org/tuvistavie/asdf-python)
| Redis | [smashedtoatoms/asdf-redis](https://github.com/smashedtoatoms/asdf-redis) | [![Build Status](https://travis-ci.org/smashedtoatoms/asdf-redis.svg?branch=master)](https://travis-ci.org/smashedtoatoms/asdf-redis) | Redis | [smashedtoatoms/asdf-redis](https://github.com/smashedtoatoms/asdf-redis) | [![Build Status](https://travis-ci.org/smashedtoatoms/asdf-redis.svg?branch=master)](https://travis-ci.org/smashedtoatoms/asdf-redis)

View File

@ -22,8 +22,8 @@ get_concurrency() {
} }
install_local_tool_versions() { install_local_tool_versions() {
if [ -f $(pwd)/.tool-versions ]; then if [ -f "$(pwd)/.tool-versions" ]; then
local asdf_versions_path=$(pwd)/.tool-versions local asdf_versions_path="$(pwd)/.tool-versions"
while read tool_line; do while read tool_line; do
IFS=' ' read -a tool_info <<< $tool_line IFS=' ' read -a tool_info <<< $tool_line
@ -33,7 +33,7 @@ install_local_tool_versions() {
if ! [[ -z "$tool_name" || -z "$tool_version" ]]; then if ! [[ -z "$tool_name" || -z "$tool_version" ]]; then
install_tool_version $tool_name $tool_version install_tool_version $tool_name $tool_version
fi fi
done < $asdf_versions_path done < "$asdf_versions_path"
else else
echo "Either specify a tool & version in the command" echo "Either specify a tool & version in the command"
echo "OR add .tool-versions file in this directory" echo "OR add .tool-versions file in this directory"

View File

@ -56,6 +56,28 @@ display_error() {
echo >&2 $1 echo >&2 $1
} }
get_version_in_dir() {
local plugin_name=$1
local search_path=$2
local legacy_filenames=$3
local asdf_version=$(parse_asdf_version_file "$search_path/.tool-versions" $plugin_name)
if [ -n "$asdf_version" ]; then
echo "$asdf_version:$search_path/.tool-versions"
return 0
fi
for filename in $legacy_filenames; do
local legacy_version=$(parse_legacy_version_file "$search_path/$filename" $plugin_name)
if [ -n "$legacy_version" ]; then
echo "$legacy_version:$search_path/$filename"
return 0
fi
done
}
find_version() { find_version() {
local plugin_name=$1 local plugin_name=$1
local search_path=$2 local search_path=$2
@ -70,24 +92,15 @@ find_version() {
fi fi
while [ "$search_path" != "/" ]; do while [ "$search_path" != "/" ]; do
local asdf_version=$(parse_asdf_version_file "$search_path/.tool-versions" $plugin_name) local version=$(get_version_in_dir "$plugin_name" "$search_path" "$legacy_filenames")
if [ -n "$version" ]; then
if [ -n "$asdf_version" ]; then echo "$version"
echo "$asdf_version:$search_path/.tool-versions"
return 0 return 0
fi fi
for filename in $legacy_filenames; do
local legacy_version=$(parse_legacy_version_file "$search_path/$filename" $plugin_name)
if [ -n "$legacy_version" ]; then
echo "$legacy_version:$search_path/$filename"
return 0
fi
done
search_path=$(dirname "$search_path") search_path=$(dirname "$search_path")
done done
get_version_in_dir "$plugin_name" "$HOME" "$legacy_filenames"
} }
parse_asdf_version_file() { parse_asdf_version_file() {

View File

@ -8,6 +8,9 @@ load test_helpers
setup() { setup() {
setup_asdf_dir setup_asdf_dir
install_dummy_plugin install_dummy_plugin
PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR
} }
teardown() { teardown() {
@ -27,3 +30,15 @@ teardown() {
run grep ASDF_CONCURRENCY $ASDF_DIR/installs/dummy/1.0/env run grep ASDF_CONCURRENCY $ASDF_DIR/installs/dummy/1.0/env
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "install_command should work in directory containing whitespace" {
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
mkdir -p "$WHITESPACE_DIR"
cd "$WHITESPACE_DIR"
echo 'dummy 1.2' >> "$WHITESPACE_DIR/.tool-versions"
run install_command
[ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
}

View File

@ -92,3 +92,12 @@ teardown() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "0.2.0" ] [ "$output" = "0.2.0" ]
} }
@test "get_preset_version_for returns the global version from home when project is outside of home" {
echo "dummy 0.1.0" > $HOME/.tool-versions
PROJECT_DIR=$BASE_DIR/project
mkdir -p $PROJECT_DIR
run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
[ "$output" = "0.1.0" ]
}