mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Merge branch 'master' into parallelize-plugin-updates
This commit is contained in:
commit
ebc52b150b
@ -2,7 +2,7 @@
|
||||
|
||||
## 0.8.1-dev
|
||||
|
||||
## 0.8.0-rc1
|
||||
## 0.8.0
|
||||
|
||||
Features
|
||||
|
||||
@ -11,9 +11,12 @@ Features
|
||||
* Improve introduction and install sections of documentation (#699, #740)
|
||||
* Add dependencies for openSUSE and ArchLinux to documentation (#714)
|
||||
* Add support for keeping downloaded tool source code (#74, #669)
|
||||
* Add `asdf info` command to print debug information (#786, #787)
|
||||
|
||||
Fixed Bugs
|
||||
|
||||
* Fix typo that caused plugin-test to erroneously fail (#780)
|
||||
* Make sure shims are only appended to `PATH` once in Fish shell (#767, #777, #778)
|
||||
* Print `.tool-versions` file path on shim error (#749, #750)
|
||||
* Add `column` and `sort -V` to list of banned commands for the asdf codebase (#661, #754, #755)
|
||||
* Use editorconfig for shell formatting (#751)
|
||||
|
13
README.md
13
README.md
@ -1,10 +1,10 @@
|
||||
# asdf-vm [![Main workflow](https://github.com/asdf-vm/asdf/workflows/Main%20workflow/badge.svg)](https://github.com/asdf-vm/asdf/actions)
|
||||
# asdf [![Main workflow](https://github.com/asdf-vm/asdf/workflows/Main%20workflow/badge.svg)](https://github.com/asdf-vm/asdf/actions)
|
||||
|
||||
**Manage multiple runtime versions with a single CLI tool, extendable via plugins** - [docs at asdf-vm.com](https://asdf-vm.github.io/asdf/)
|
||||
|
||||
asdf-vm is a CLI tool that can manage multiple language runtime versions on a per-project basis. It is like `gvm`, `nvm`, `rbenv` & `pyenv` (and more) all in one! Simply install your language's plugin!
|
||||
asdf is a CLI tool that can manage multiple language runtime versions on a per-project basis. It is like `gvm`, `nvm`, `rbenv` & `pyenv` (and more) all in one! Simply install your language's plugin!
|
||||
|
||||
## Why use asdf-vm?
|
||||
## Why use asdf?
|
||||
|
||||
- single CLI for multiple languages
|
||||
- consistent commands to manage all your languages
|
||||
@ -19,7 +19,7 @@ asdf-vm is a CLI tool that can manage multiple language runtime versions on a pe
|
||||
|
||||
[Please head over the documentation site for more information](https://asdf-vm.github.io/asdf/)!
|
||||
|
||||
- [Getting Started](https://asdf-vm.github.io/asdf/#/core-manage-asdf-vm)
|
||||
- [Getting Started](https://asdf-vm.github.io/asdf/#/core-manage-asdf)
|
||||
- [All Commands](https://asdf-vm.github.io/asdf/#/core-commands)
|
||||
- [All Plugins](https://asdf-vm.github.io/asdf/#/plugins-all)
|
||||
- [Create a Plugin](https://asdf-vm.github.io/asdf/#/plugins-create) with our [asdf-plugin-template](https://github.com/asdf-vm/asdf-plugin-template)
|
||||
@ -32,5 +32,6 @@ See [CONTRIBUTING.md in the repo](https://github.com/asdf-vm/asdf/blob/master/CO
|
||||
## Community & Questions
|
||||
|
||||
<!-- - [![GitHub Discussions](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github Discussions TBA](https://github.com/asdf-vm/asdf/discussions): our preferred method for community Q&A and interaction -->
|
||||
- [![Github Issues](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github Issues](https://github.com/asdf-vm/asdf/issues): report a bug or raise a feature request to the `asdf` core team
|
||||
- [![StackOverflow Tag](https://icongr.am/fontawesome/stack-overflow.svg?size=16&color=808080)StackOverflow Tag](https://stackoverflow.com/questions/tagged/asdf-vm): see existing Q&A for `asdf`. Some of the core team watch this tag in addition to our helpful community
|
||||
|
||||
- [![Github Issues](https://icongram.jgog.in/simple/github.svg?color=808080&size=16) Github Issues](https://github.com/asdf-vm/asdf/issues): report a bug or raise a feature request to the `asdf` core team
|
||||
- [![StackOverflow Tag](https://icongr.am/fontawesome/stack-overflow.svg?size=16&color=808080) StackOverflow Tag](https://stackoverflow.com/questions/tagged/asdf-vm): see existing Q&A for `asdf`. Some of the core team watch this tag in addition to our helpful community
|
||||
|
20
bin/asdf
20
bin/asdf
@ -9,16 +9,16 @@ find_cmd() {
|
||||
|
||||
local cmd_name
|
||||
local args_offset="$#"
|
||||
cmd_name="command-$(echo "${@:1:${args_offset}}" | tr ' ' '-').bash"
|
||||
cmd_name="command-$(tr ' ' '-' <<<"${@:1:${args_offset}}").bash"
|
||||
while [ ! -f "$cmd_dir/$cmd_name" ] && [ "$args_offset" -gt 0 ]; do
|
||||
args_offset=$((args_offset - 1))
|
||||
cmd_name="command-$(echo "${@:1:${args_offset}}" | tr ' ' '-').bash"
|
||||
cmd_name="command-$(tr ' ' '-' <<<"${@:1:${args_offset}}").bash"
|
||||
done
|
||||
|
||||
if [ -f "$cmd_dir/$cmd_name" ]; then
|
||||
echo "$cmd_dir/$cmd_name" "$((args_offset + 1))"
|
||||
printf "%s %s\\n" "$cmd_dir/$cmd_name" "$((args_offset + 1))"
|
||||
elif [ -f "$cmd_dir/command.bash" ]; then
|
||||
echo "$cmd_dir/command.bash" 1
|
||||
printf "%s %s\\n" "$cmd_dir/command.bash" 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -29,15 +29,15 @@ find_asdf_cmd() {
|
||||
'exec' | 'current' | 'env' | 'global' | 'install' | 'latest' | 'local' | \
|
||||
'reshim' | 'uninstall' | 'update' | 'where' | 'which' | \
|
||||
'export-shell-version')
|
||||
echo "$asdf_cmd_dir/command-$1.bash" 2
|
||||
printf "%s %s\\n" "$asdf_cmd_dir/command-$1.bash" 2
|
||||
;;
|
||||
|
||||
'' | '--help' | '-h' | 'help')
|
||||
echo "$asdf_cmd_dir/command-help.bash" 2
|
||||
printf "%s %s\\n" "$asdf_cmd_dir/command-help.bash" 2
|
||||
;;
|
||||
|
||||
'--version' | 'version')
|
||||
echo "$asdf_cmd_dir/command-version.bash" 2
|
||||
printf "%s %s\\n" "$asdf_cmd_dir/command-version.bash" 2
|
||||
;;
|
||||
|
||||
*)
|
||||
@ -52,7 +52,7 @@ find_plugin_cmd() {
|
||||
IFS=' ' read -r ASDF_CMD_FILE args_offset <<<"$(find_cmd "$(get_plugin_path "$1")/lib/commands" "${@:2}")"
|
||||
if [ -n "$ASDF_CMD_FILE" ]; then
|
||||
args_offset=$((args_offset + 1)) # since the first argument is the plugin name
|
||||
echo "$ASDF_CMD_FILE" "$args_offset"
|
||||
printf "%s %s\\n" "$ASDF_CMD_FILE" "$args_offset"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -61,7 +61,7 @@ asdf_cmd() {
|
||||
local ASDF_CMD_FILE args_offset
|
||||
|
||||
if [ "shell" == "$1" ]; then
|
||||
echo "Shell integration is not enabled. Please ensure you source asdf in your shell setup." >&2
|
||||
printf "Shell integration is not enabled. Please ensure you source asdf in your shell setup." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -78,7 +78,7 @@ asdf_cmd() {
|
||||
else
|
||||
local asdf_cmd_dir
|
||||
asdf_cmd_dir="$(asdf_dir)/lib/commands"
|
||||
echo "Unknown command: \`asdf ${*}\`" >&2
|
||||
printf "%s\\n" "Unknown command: \`asdf ${*}\`" >&2
|
||||
source "$asdf_cmd_dir/command-help.bash" >&2
|
||||
return 127
|
||||
fi
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# remove this asdf-exec file when releasing >=0.6.5
|
||||
echo "asdf is self upgrading shims to new asdf exec ..."
|
||||
printf "asdf is self upgrading shims to new asdf exec ...\\n"
|
||||
|
||||
asdf_dir="$(dirname "$(dirname "$(dirname "$0")")")"
|
||||
# shellcheck source=lib/utils.bash
|
||||
@ -10,6 +10,6 @@ rm "$(asdf_data_dir)"/shims/*
|
||||
"$asdf_dir"/bin/asdf reshim
|
||||
shim_name=$(basename "$2")
|
||||
|
||||
echo "asdf: now running $shim_name"
|
||||
printf "asdf: now running %s\\n" "$shim_name"
|
||||
|
||||
exec "$shim_name" "${@:3}"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!-- asdf-vm homepage -->
|
||||
<!-- asdf homepage -->
|
||||
|
||||
<!-- include the repo readme -->
|
||||
[](https://raw.githubusercontent.com/asdf-vm/asdf/master/README.md ':include')
|
||||
|
||||
<!-- include the ballad of asdf-vm -->
|
||||
<!-- include the ballad of asdf -->
|
||||
[](https://raw.githubusercontent.com/asdf-vm/asdf/master/ballad-of-asdf.md ':include')
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!-- ![logo](_media.asdf-vm-logo.svg) -->
|
||||
<!-- ![logo](_media.asdf-logo.svg) -->
|
||||
|
||||
# asdf-vm
|
||||
# asdf
|
||||
|
||||
> Manage multiple runtime versions with a single CLI tool
|
||||
|
||||
@ -11,4 +11,4 @@
|
||||
- Extend with a simple plugin system
|
||||
|
||||
[GitHub](https://github.com/asdf-vm/asdf)
|
||||
[Get Started](core-manage-asdf-vm)
|
||||
[Get Started](core-manage-asdf)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<!-- docs/_sidebar.md -->
|
||||
|
||||
- **Core**
|
||||
- [Manage asdf-vm](core-manage-asdf-vm)
|
||||
- [Manage asdf](core-manage-asdf)
|
||||
- [Manage Plugins](core-manage-plugins)
|
||||
- [Manage Versions](core-manage-versions)
|
||||
- [Configuration](core-configuration)
|
||||
@ -11,7 +11,7 @@
|
||||
- [Creating Plugins](plugins-create)
|
||||
- [All Plugins](plugins-all) <!-- pulls in asdf-vm/asdf-plugins readme -->
|
||||
- **Contributing**
|
||||
- [Core asdf vm](contributing-core-asdf-vm)
|
||||
- [Core asdf](contributing-core-asdf)
|
||||
- [Documentation Site](contributing-doc-site)
|
||||
- [Thanks](thanks)
|
||||
- **Community & Questions**
|
||||
|
@ -9,7 +9,7 @@ Here is a list of improvements we are looking at making to the documentation. If
|
||||
- change the typography
|
||||
- get a logo?
|
||||
- improve "edit on GitHub" button/link
|
||||
- add asdf-vm to awesome-docsify showcase
|
||||
- add asdf to awesome-docsify showcase
|
||||
|
||||
## Setup Your Environment
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
1. [Manage asdf-vm](/core-manage-asdf-vm): install `asdf` **and** add `asdf` to your shell
|
||||
1. [Manage asdf](/core-manage-asdf): install `asdf` **and** add `asdf` to your shell
|
||||
2. [Manage Plugins](/core-manage-plugins): add a plugin for your tool `asdf plugin add nodejs`
|
||||
3. [Manage Versions](/core-manage-versions): install a version of that tool `asdf install nodejs 13.14.0`
|
||||
4. [Configuration](/core-configuration): set global and project tool versions via `.tool-versions` config
|
||||
@ -62,7 +62,7 @@ No match for _Operating System_ and _Installation Method_ selections. Please try
|
||||
Clone only the latest branch:
|
||||
|
||||
```shell
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0-rc1
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.0
|
||||
```
|
||||
|
||||
Alternately, you can clone the whole repo and checkout the latest branch:
|
||||
@ -75,6 +75,8 @@ git checkout "$(git describe --abbrev=0 --tags)"
|
||||
|
||||
### --Homebrew--
|
||||
|
||||
!> See `asdf` and Homebrew compatibility [issues in #785](https://github.com/asdf-vm/asdf/issues/785) before continuing.
|
||||
|
||||
Install using the Homebrew package manager:
|
||||
|
||||
```shell
|
@ -1,6 +1,6 @@
|
||||
Plugins are how asdf-vm understands handling different packages.
|
||||
Plugins are how asdf understands handling different packages.
|
||||
|
||||
See [All plugins](plugins-all) for the plugins repository which lists all asdf-vm plugins we know.
|
||||
See [All plugins](plugins-all) for the plugins repository which lists all asdf plugins we know.
|
||||
|
||||
See [Creating Plugins](plugins-create) for the super-simple API for supporting more languages.
|
||||
|
||||
|
@ -106,13 +106,13 @@ asdf uninstall <name> <version>
|
||||
|
||||
## Shims
|
||||
|
||||
When asdf-vm installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims`). This directory being on the `$PATH` (by means of `asdf.sh` or `asdf.fish`) is how the installed programs are made available in the environment.
|
||||
When asdf installs a package it creates shims for every executable program in that package in a `$ASDF_DATA_DIR/shims` directory (default `~/.asdf/shims`). This directory being on the `$PATH` (by means of `asdf.sh` or `asdf.fish`) is how the installed programs are made available in the environment.
|
||||
|
||||
The shims themselves are really simple wrappers that `exec` a helper program `asdf exec` passing it the name of the plugin and path to the executable in the installed package that the shim is wrapping.
|
||||
|
||||
The `asdf exec` helper determines the version of the package to use (as specified in `.tool-versions` file, selected by `asdf local ...` or `asdf global ...`), the final path to the executable in the package installation directory (this can be manipulated by the `exec-path` callback in the plugin) and the environment to execute in (also provided by the plugin - `exec-env` script), and finally it executes it.
|
||||
|
||||
!> Note that because this system uses `exec` calls, any scripts in the package that are meant to be sourced by the shell instead of executed need to be accessed directly instead of via the shim wrapper. The two asdf-vm commands: `which` and `where` can help with this by returning the path to the installed package:
|
||||
!> Note that because this system uses `exec` calls, any scripts in the package that are meant to be sourced by the shell instead of executed need to be accessed directly instead of via the shim wrapper. The two asdf commands: `which` and `where` can help with this by returning the path to the installed package:
|
||||
|
||||
```shell
|
||||
# returns path to main executable in current version
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>asdf vm - An extendable version manager</title>
|
||||
<title>asdf - An extendable version manager</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="description" content="An extendable version manager" />
|
||||
<meta
|
||||
@ -27,7 +27,7 @@
|
||||
<script src="scripts/docsify-edit-on-github.js"></script>
|
||||
<script>
|
||||
window.$docsify = {
|
||||
name: "asdf-vm",
|
||||
name: "asdf",
|
||||
repo: "https://github.com/asdf-vm/asdf",
|
||||
el: "#app",
|
||||
coverpage: true,
|
||||
|
@ -55,6 +55,8 @@ The install script should exit with a status of `0` when the installation is suc
|
||||
|
||||
If possible the script should only place files in the `ASDF_INSTALL_PATH` directory once the build and installation of the tool is deemed successful by the install script. asdf [checks for the existence](https://github.com/asdf-vm/asdf/blob/242d132afbf710fe3c7ec23c68cec7bdd2c78ab5/lib/utils.sh#L44) of the `ASDF_INSTALL_PATH` directory in order to determine if that version of the tool is installed. If the `ASDF_INSTALL_PATH` directory is populated at the beginning of the installation process other asdf commands run in other terminals during the installation may consider that version of the tool installed, even when it is not fully installed.
|
||||
|
||||
If you want your plugin to work with asdf version 0.7.* and earlier and version 0.8.* and newer check for the presence of the `ASDF_DOWNLOAD_PATH` environment variable. If it is not set download the source code in the bin/install callback. If it is set assume the `bin/download` script already downloaded it.
|
||||
|
||||
## Optional Scripts
|
||||
|
||||
#### bin/help scripts
|
||||
|
@ -45,7 +45,7 @@ current_command() {
|
||||
local terminal_format="%-15s %-15s %-10s\\n"
|
||||
local exit_status=0
|
||||
|
||||
printf "$terminal_format" "PLUGIN" "VERSION" "SET BY CONFIG"
|
||||
# printf "$terminal_format" "PLUGIN" "VERSION" "SET BY CONFIG" # disbale this until we release headings across the board
|
||||
if [ $# -eq 0 ]; then
|
||||
for plugin in $(asdf plugin list); do
|
||||
plugin_current_command "$plugin" "$terminal_format"
|
||||
@ -71,10 +71,8 @@ check_for_deprecated_plugin() {
|
||||
local new_script="${plugin_path}/bin/list-legacy-filenames"
|
||||
|
||||
if [ "$legacy_config" = "yes" ] && [ -f "$deprecated_script" ] && [ ! -f "$new_script" ]; then
|
||||
echo "Heads up! It looks like your $plugin_name plugin is out of date. You can update it with:"
|
||||
echo ""
|
||||
echo " asdf plugin-update $plugin_name"
|
||||
echo ""
|
||||
printf "Heads up! It looks like your %s plugin is out of date. You can update it with:\\n\\n" "$plugin_name"
|
||||
printf " asdf plugin-update %s\\n\\n" "$plugin_name"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ shim_env_command() {
|
||||
local env_args=("${@:3}")
|
||||
|
||||
if [ -z "$shim_name" ]; then
|
||||
echo "usage: asdf env <command>"
|
||||
printf "usage: asdf env <command>\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -6,7 +6,7 @@ shim_exec_command() {
|
||||
local shim_args=("${@:2}")
|
||||
|
||||
if [ -z "$shim_name" ]; then
|
||||
echo "usage: asdf exec <command>"
|
||||
printf "usage: asdf exec <command>\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -16,7 +16,7 @@ shim_exec_command() {
|
||||
local executable_path="$3"
|
||||
|
||||
if [ ! -x "$executable_path" ]; then
|
||||
echo "No ${shim_name} executable found for ${plugin_name} ${version}" >&2
|
||||
printf "No %s executable found for %s %s\\n" "$shim_name" "$plugin_name" "$version" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
@ -6,8 +6,8 @@ shell_command() {
|
||||
shift
|
||||
|
||||
if [ "$#" -lt "2" ]; then
|
||||
echo "Usage: asdf shell <name> {<version>|--unset}" >&2
|
||||
echo 'false'
|
||||
printf "Usage: asdf shell <name> {<version>|--unset}\\n" >&2
|
||||
printf "false\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -15,32 +15,35 @@ shell_command() {
|
||||
local version=$2
|
||||
|
||||
local upcase_name
|
||||
upcase_name=$(echo "$plugin" | tr '[:lower:]-' '[:upper:]_')
|
||||
upcase_name=$(tr '[:lower:]-' '[:upper:]_' <<<"$plugin")
|
||||
local version_env_var="ASDF_${upcase_name}_VERSION"
|
||||
|
||||
if [ "$version" = "--unset" ]; then
|
||||
case "$asdf_shell" in
|
||||
fish)
|
||||
echo "set -e $version_env_var"
|
||||
printf "set -e %s\\n" "$version_env_var"
|
||||
;;
|
||||
*)
|
||||
echo "unset $version_env_var"
|
||||
printf "unset %s\\n" "$version_env_var"
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
if [ "$version" = "latest" ]; then
|
||||
version=$(asdf latest "$plugin")
|
||||
fi
|
||||
if ! (check_if_version_exists "$plugin" "$version"); then
|
||||
version_not_installed_text "$plugin" "$version" 1>&2
|
||||
echo 'false'
|
||||
printf "false\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$asdf_shell" in
|
||||
fish)
|
||||
echo "set -gx $version_env_var \"$version\""
|
||||
printf "set -gx %s \"%s\"\\n" "$version_env_var" "$version"
|
||||
;;
|
||||
*)
|
||||
echo "export $version_env_var=\"$version\""
|
||||
printf "export %s=\"%s\"\\n" "$version_env_var" "$version"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
# -*- sh -*-
|
||||
|
||||
asdf_help() {
|
||||
echo "version: $(asdf_version)"
|
||||
echo ""
|
||||
printf "version: %s\\n\\n" "$(asdf_version)"
|
||||
cat "$(asdf_dir)/help.txt"
|
||||
}
|
||||
|
||||
@ -22,10 +21,9 @@ asdf_extension_cmds() {
|
||||
ext_cmds="$(ls -1 "$plugins_path"/*/lib/commands/command*.bash 2>/dev/null |
|
||||
sed "s#^$plugins_path/##;s#lib/commands/command##;s/.bash//;s/^-//;s/-/ /g")"
|
||||
if test -n "$ext_cmds"; then
|
||||
echo "$ext_cmds" | cut -d'/' -f 1 | uniq | while read -r plugin; do
|
||||
echo
|
||||
echo "PLUGIN $plugin"
|
||||
echo "$ext_cmds" | grep "$plugin/" | sed "s#^$plugin/# asdf $plugin#" | sort
|
||||
cut -d'/' -f 1 <<<"$ext_cmds" | uniq | while read -r plugin; do
|
||||
printf "\\nPLUGIN %s\\n" "$plugin"
|
||||
grep "$plugin/" <<<"$ext_cmds" | sed "s#^$plugin/# asdf $plugin#" | sort
|
||||
done
|
||||
fi
|
||||
}
|
||||
@ -76,11 +74,11 @@ help_command() {
|
||||
(print_plugin_help "$plugin_path")
|
||||
fi
|
||||
else
|
||||
echo "No documentation for plugin $plugin_name" >&2
|
||||
printf "No documentation for plugin %s\\n" "$plugin_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "No plugin named $plugin_name" >&2
|
||||
printf "No plugin named %s\\n" "$plugin_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
|
@ -1,11 +1,11 @@
|
||||
# -*- sh -*-
|
||||
|
||||
info_command() {
|
||||
printf "%s:\n%s\n\n" "OS" "$(uname -a)"
|
||||
printf "%s:\n%s\n\n" "SHELL" "$($SHELL --version)"
|
||||
printf "%s:\n%s\n\n" "ASDF VERSION" "$(asdf_version)"
|
||||
printf "%s:\n%s\n\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")"
|
||||
printf "%s:\n%s\n\n" "ASDF INSTALLED PLUGINS" "$(asdf plugin list --urls)"
|
||||
printf "%s:\\n%s\\n\\n" "OS" "$(uname -a)"
|
||||
printf "%s:\\n%s\\n\\n" "SHELL" "$($SHELL --version)"
|
||||
printf "%s:\\n%s\\n\\n" "ASDF VERSION" "$(asdf_version)"
|
||||
printf "%s:\\n%s\\n\\n" "ASDF ENVIRONMENT VARIABLES" "$(env | grep -E "ASDF_DIR|ASDF_DATA_DIR|ASDF_CONFIG_FILE|ASDF_DEFAULT_TOOL_VERSIONS_FILENAME")"
|
||||
printf "%s:\\n%s\\n\\n" "ASDF INSTALLED PLUGINS" "$(asdf plugin list --urls)"
|
||||
}
|
||||
|
||||
info_command "$@"
|
||||
|
@ -8,7 +8,7 @@ handle_failure() {
|
||||
|
||||
handle_cancel() {
|
||||
local install_path="$1"
|
||||
echo -e "\\nreceived sigint, cleaning up"
|
||||
printf "\\nreceived sigint, cleaning up"
|
||||
handle_failure "$install_path"
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ get_concurrency() {
|
||||
elif [ -f /proc/cpuinfo ]; then
|
||||
grep -c processor /proc/cpuinfo
|
||||
else
|
||||
echo "1"
|
||||
printf "1\\n"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ install_one_local_tool() {
|
||||
install_tool_version "$plugin_name" "$plugin_version"
|
||||
done
|
||||
else
|
||||
echo "No versions specified for $plugin_name in config files or environment"
|
||||
printf "No versions specified for %s in config files or environment\\n" "$plugin_name"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -89,14 +89,14 @@ install_local_tool_versions() {
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "Install plugins first to be able to install tools"
|
||||
printf "Install plugins first to be able to install tools\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$some_tools_installed" ]; then
|
||||
echo "Either specify a tool & version in the command"
|
||||
echo "OR add .tool-versions file in this directory"
|
||||
echo "or in a parent directory"
|
||||
printf "Either specify a tool & version in the command\\n"
|
||||
printf "OR add .tool-versions file in this directory\\n"
|
||||
printf "or in a parent directory\\n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@ -152,7 +152,7 @@ install_tool_version() {
|
||||
trap 'handle_cancel $install_path' INT
|
||||
|
||||
if [ -d "$install_path" ]; then
|
||||
echo "$plugin_name $full_version is already installed"
|
||||
printf "%s %s is already installed\\n" "$plugin_name" "$full_version"
|
||||
else
|
||||
|
||||
if [ -f "${plugin_path}/bin/download" ]; then
|
||||
|
@ -11,8 +11,7 @@ list_all_command() {
|
||||
versions=$(bash "${plugin_path}/bin/list-all")
|
||||
|
||||
if [[ $query ]]; then
|
||||
versions=$(echo "$versions" |
|
||||
tr ' ' '\n' |
|
||||
versions=$(tr ' ' '\n' <<<"$versions" |
|
||||
grep -E "^\\s*$query" |
|
||||
tr '\n' ' ')
|
||||
fi
|
||||
@ -20,7 +19,7 @@ list_all_command() {
|
||||
IFS=' ' read -r -a versions_list <<<"$versions"
|
||||
|
||||
for version in "${versions_list[@]}"; do
|
||||
echo "${version}"
|
||||
printf "%s\\n" "${version}"
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ list_command() {
|
||||
if ls "$plugins_path" &>/dev/null; then
|
||||
for plugin_path in "$plugins_path"/*; do
|
||||
plugin_name=$(basename "$plugin_path")
|
||||
echo "$plugin_name"
|
||||
printf "%s\\n" "$plugin_name"
|
||||
display_installed_versions "$plugin_name"
|
||||
done
|
||||
else
|
||||
@ -28,7 +28,7 @@ display_installed_versions() {
|
||||
|
||||
if [ -n "${versions}" ]; then
|
||||
for version in $versions; do
|
||||
echo " $version"
|
||||
printf " %s\\n" "$version"
|
||||
done
|
||||
else
|
||||
display_error ' No versions installed'
|
||||
|
@ -4,14 +4,14 @@ plugin_push_command() {
|
||||
local plugin_name=$1
|
||||
if [ "$plugin_name" = "--all" ]; then
|
||||
for dir in "$(asdf_data_dir)"/plugins/*; do
|
||||
echo "Pushing $(basename "$dir")..."
|
||||
printf "Pushing %s...\\n" "$(basename "$dir")"
|
||||
(cd "$dir" && git push)
|
||||
done
|
||||
else
|
||||
local plugin_path
|
||||
plugin_path=$(get_plugin_path "$plugin_name")
|
||||
check_if_plugin_exists "$plugin_name"
|
||||
echo "Pushing $plugin_name..."
|
||||
printf "Pushing %s...\\n" "$plugin_name"
|
||||
(cd "$plugin_path" && git push)
|
||||
fi
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ plugin_test_command() {
|
||||
local TEST_DIR
|
||||
|
||||
fail_test() {
|
||||
echo "FAILED: $1"
|
||||
printf "FAILED: %s\\n" "$1"
|
||||
rm -rf "$TEST_DIR"
|
||||
exit 1
|
||||
}
|
||||
@ -74,23 +74,20 @@ plugin_test_command() {
|
||||
local list_all="$plugin_path/bin/list-all"
|
||||
if grep api.github.com "$list_all" >/dev/null; then
|
||||
if ! grep Authorization "$list_all" >/dev/null; then
|
||||
echo
|
||||
echo "Looks like ${plugin_name}/bin/list-all relies on GitHub releases"
|
||||
echo "but it does not properly sets an Authorization header to prevent"
|
||||
echo "GitHub API rate limiting."
|
||||
echo
|
||||
echo "See https://github.com/asdf-vm/asdf/blob/master/docs/creating-plugins.md#github-api-rate-limiting"
|
||||
printf "\\nLooks like %s/bin/list-all relies on GitHub releases\\n" "$plugin_name"
|
||||
printf "but it does not properly sets an Authorization header to prevent\\n"
|
||||
printf "GitHub API rate limiting.\\n\\n"
|
||||
printf "See https://github.com/asdf-vm/asdf/blob/master/docs/creating-plugins.md#github-api-rate-limiting\\n"
|
||||
|
||||
fail_test "$plugin_name/bin/list-all does not set GitHub Authorization token"
|
||||
fi
|
||||
|
||||
# test for most common token names we have on plugins. If both are empty show this warning
|
||||
if [ -z "$OAUTH_TOKEN" ] && [ -z "$GITHUB_API_TOKEN" ]; then
|
||||
echo "$plugin_name/bin/list-all is using GitHub API, just be sure you provide an API Authorization token"
|
||||
echo "via your CI env GITHUB_API_TOKEN. This is the current rate_limit:"
|
||||
echo
|
||||
printf "%s/bin/list-all is using GitHub API, just be sure you provide an API Authorization token\\n" "$plugin_name"
|
||||
printf "via your CI env GITHUB_API_TOKEN. This is the current rate_limit:\\n\\n"
|
||||
curl -s https://api.github.com/rate_limit
|
||||
echo
|
||||
printf "\\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -109,7 +106,7 @@ plugin_test_command() {
|
||||
# Use the version passed in if it was set. Otherwise grab the latest
|
||||
# version from the versions list
|
||||
if [ -z "$tool_version" ] || [[ "$tool_version" == *"latest"* ]]; then
|
||||
version="$(asdf latest "$plugin_name" "$(echo "$tool_version" | sed -e 's#latest##;s#^:##')")"
|
||||
version="$(asdf latest "$plugin_name" "$(sed -e 's#latest##;s#^:##' <<<"$tool_version")")"
|
||||
if [ -z "$version" ]; then
|
||||
fail_test "could not get latest version"
|
||||
fi
|
||||
|
@ -9,12 +9,14 @@ plugin_update_command() {
|
||||
local plugin_name="$1"
|
||||
local gitref="${2:-master}"
|
||||
if [ "$plugin_name" = "--all" ]; then
|
||||
for dir in "$(asdf_data_dir)"/plugins/*; do
|
||||
local plugin_name
|
||||
plugin_name=$(basename "$dir")
|
||||
update_plugin "$plugin_name" "$dir" "$gitref" &
|
||||
done
|
||||
wait
|
||||
if [ -d "$(asdf_data_dir)"/plugins ]; then
|
||||
while IFS= read -r -d '' dir; do
|
||||
local plugin_name
|
||||
plugin_name=$(basename "$dir")
|
||||
update_plugin "$plugin_name" "$dir" "$gitref" &
|
||||
done < <(find "$(asdf_data_dir)"/plugins -type d -mindepth 1 -maxdepth 1)
|
||||
wait
|
||||
fi
|
||||
else
|
||||
local plugin_path
|
||||
plugin_path="$(get_plugin_path "$plugin_name")"
|
||||
@ -29,7 +31,7 @@ update_plugin() {
|
||||
local gitref=$3
|
||||
logfile=$(mktemp)
|
||||
{
|
||||
echo "Updating $plugin_name..."
|
||||
printf "Updating %s...\\n" "$plugin_name"
|
||||
(cd "$plugin_path" && git fetch -p -u origin "$gitref:$gitref" && git checkout -f "$gitref")
|
||||
} >"$logfile" 2>&1
|
||||
cat "$logfile"
|
||||
|
@ -119,7 +119,7 @@ remove_obsolete_shims() {
|
||||
exec_names=$(plugin_executables "$plugin_name" "$full_version" | xargs -IX basename X | sort)
|
||||
|
||||
local obsolete_shims
|
||||
obsolete_shims=$(comm -23 <(echo "$shims") <(echo "$exec_names"))
|
||||
obsolete_shims=$(comm -23 <(printf "%s\\n" "$shims") <(printf "%s\\n" "$exec_names"))
|
||||
|
||||
for shim_name in $obsolete_shims; do
|
||||
remove_shim_for_version "$plugin_name" "$full_version" "$shim_name"
|
||||
|
@ -7,7 +7,7 @@ update_command() {
|
||||
cd "$(asdf_dir)" || exit 1
|
||||
|
||||
if [ -f asdf_updates_disabled ] || ! git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
echo "Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf."
|
||||
printf "Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.\\n"
|
||||
exit 42
|
||||
else
|
||||
do_update "$update_to_head"
|
||||
@ -23,7 +23,7 @@ do_update() {
|
||||
git fetch origin master
|
||||
git checkout master
|
||||
git reset --hard origin/master
|
||||
echo "Updated asdf to latest on the master branch"
|
||||
printf "Updated asdf to latest on the master branch\\n"
|
||||
else
|
||||
# Update to latest release
|
||||
git fetch origin --tags || exit 1
|
||||
@ -38,7 +38,7 @@ do_update() {
|
||||
|
||||
# Update
|
||||
git checkout "$tag" || exit 1
|
||||
echo "Updated asdf to release $tag"
|
||||
printf "Updated asdf to release %s\\n" "$tag"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -34,14 +34,14 @@ where_command() {
|
||||
install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
|
||||
|
||||
if [ -d "$install_path" ]; then
|
||||
echo "$install_path"
|
||||
printf "%s\\n" "$install_path"
|
||||
exit 0
|
||||
else
|
||||
if [ "$version" = "system" ]; then
|
||||
echo "System version is selected"
|
||||
printf "System version is selected\\n"
|
||||
exit 1
|
||||
else
|
||||
echo "Version not installed"
|
||||
printf "Version not installed\\n"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
@ -5,7 +5,7 @@ which_command() {
|
||||
shim_name=$(basename "$1")
|
||||
|
||||
if [ -z "$shim_name" ]; then
|
||||
echo "usage: asdf which <command>"
|
||||
printf "usage: asdf which <command>\\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -15,11 +15,11 @@ which_command() {
|
||||
local executable_path="$3"
|
||||
|
||||
if [ ! -x "$executable_path" ]; then
|
||||
echo "No ${shim_name} executable found for ${plugin_name} ${version}" >&2
|
||||
printf "No %s executable found for %s %s\\n" "$shim_name" "$plugin_name" "$version" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$executable_path"
|
||||
printf "%s\\n" "$executable_path"
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
@ -6,9 +6,9 @@ version_command() {
|
||||
|
||||
if [ "$#" -lt "3" ]; then
|
||||
if [ "$cmd" = "global" ]; then
|
||||
echo "Usage: asdf global <name> <version>"
|
||||
printf "Usage: asdf global <name> <version>\\n"
|
||||
else
|
||||
echo "Usage: asdf local <name> <version>"
|
||||
printf "Usage: asdf local <name> <version>\\n"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
@ -32,18 +32,23 @@ version_command() {
|
||||
|
||||
check_if_plugin_exists "$plugin_name"
|
||||
|
||||
declare -a resolved_versions
|
||||
local version
|
||||
for version in "${versions[@]}"; do
|
||||
if [ "$version" = "latest" ]; then
|
||||
version=$(asdf latest "$plugin_name")
|
||||
fi
|
||||
if ! (check_if_version_exists "$plugin_name" "$version"); then
|
||||
version_not_installed_text "$plugin_name" "$version" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
resolved_versions+=("$version")
|
||||
done
|
||||
|
||||
if [ -f "$file" ] && grep "^$plugin_name " "$file" >/dev/null; then
|
||||
sed -i.bak -e "s|^$plugin_name .*$|$plugin_name ${versions[*]}|" "$file"
|
||||
sed -i.bak -e "s|^$plugin_name .*$|$plugin_name ${resolved_versions[*]}|" "$file"
|
||||
rm "$file".bak
|
||||
else
|
||||
echo "$plugin_name ${versions[*]}" >>"$file"
|
||||
printf "%s %s\\n" "$plugin_name" "${resolved_versions[*]}" >>"$file"
|
||||
fi
|
||||
}
|
||||
|
102
lib/utils.bash
102
lib/utils.bash
@ -13,9 +13,9 @@ asdf_version() {
|
||||
version="$(cat "$(asdf_dir)/VERSION")"
|
||||
if [ -d "$(asdf_dir)/.git" ]; then
|
||||
git_rev="$(git --git-dir "$(asdf_dir)/.git" rev-parse --short HEAD)"
|
||||
echo "${version}-${git_rev}"
|
||||
printf "%s-%s\\n" "$version" "$git_rev"
|
||||
else
|
||||
echo "${version}"
|
||||
printf "%s\\n" "$version"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -29,11 +29,11 @@ asdf_dir() {
|
||||
)
|
||||
fi
|
||||
|
||||
echo "$ASDF_DIR"
|
||||
printf "%s\\n" "$ASDF_DIR"
|
||||
}
|
||||
|
||||
asdf_repository_url() {
|
||||
echo "https://github.com/asdf-vm/asdf-plugins.git"
|
||||
printf "https://github.com/asdf-vm/asdf-plugins.git\\n"
|
||||
}
|
||||
|
||||
asdf_data_dir() {
|
||||
@ -45,7 +45,7 @@ asdf_data_dir() {
|
||||
data_dir="$HOME/.asdf"
|
||||
fi
|
||||
|
||||
echo "$data_dir"
|
||||
printf "%s\\n" "$data_dir"
|
||||
}
|
||||
|
||||
get_install_path() {
|
||||
@ -59,11 +59,11 @@ get_install_path() {
|
||||
mkdir -p "${install_dir}/${plugin}"
|
||||
|
||||
if [ "$install_type" = "version" ]; then
|
||||
echo "${install_dir}/${plugin}/${version}"
|
||||
printf "%s/%s/%s\\n" "$install_dir" "$plugin" "$version"
|
||||
elif [ "$install_type" = "path" ]; then
|
||||
echo "$version"
|
||||
printf "%s\\n" "$version"
|
||||
else
|
||||
echo "${install_dir}/${plugin}/${install_type}-${version}"
|
||||
printf "%s/%s/%s-%s\\n" "$install_dir" "$plugin" "$install_type" "$version"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -78,11 +78,11 @@ get_download_path() {
|
||||
mkdir -p "${download_dir}/${plugin}"
|
||||
|
||||
if [ "$install_type" = "version" ]; then
|
||||
echo "${download_dir}/${plugin}/${version}"
|
||||
printf "%s/%s/%s\\n" "$download_dir" "$plugin" "$version"
|
||||
elif [ "$install_type" = "path" ]; then
|
||||
return
|
||||
else
|
||||
echo "${download_dir}/${plugin}/${install_type}-${version}"
|
||||
printf "%s/%s/%s-%s\\n" "$download_dir" "$plugin" "$install_type" "$version"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -140,14 +140,14 @@ version_not_installed_text() {
|
||||
|
||||
get_plugin_path() {
|
||||
if test -n "$1"; then
|
||||
echo "$(asdf_data_dir)/plugins/$1"
|
||||
printf "%s\\n" "$(asdf_data_dir)/plugins/$1"
|
||||
else
|
||||
echo "$(asdf_data_dir)/plugins"
|
||||
printf "%s\\n" "$(asdf_data_dir)/plugins"
|
||||
fi
|
||||
}
|
||||
|
||||
display_error() {
|
||||
echo >&2 "$1"
|
||||
printf "%s\\n" "$1" >&2
|
||||
}
|
||||
|
||||
get_version_in_dir() {
|
||||
@ -159,7 +159,7 @@ get_version_in_dir() {
|
||||
asdf_version=$(parse_asdf_version_file "$search_path/.tool-versions" "$plugin_name")
|
||||
|
||||
if [ -n "$asdf_version" ]; then
|
||||
echo "$asdf_version|$search_path/.tool-versions"
|
||||
printf "%s\\n" "$asdf_version|$search_path/.tool-versions"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -168,7 +168,7 @@ get_version_in_dir() {
|
||||
legacy_version=$(parse_legacy_version_file "$search_path/$filename" "$plugin_name")
|
||||
|
||||
if [ -n "$legacy_version" ]; then
|
||||
echo "$legacy_version|$search_path/$filename"
|
||||
printf "%s\\n" "$legacy_version|$search_path/$filename"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
@ -182,10 +182,10 @@ find_versions() {
|
||||
version=$(get_version_from_env "$plugin_name")
|
||||
if [ -n "$version" ]; then
|
||||
local upcase_name
|
||||
upcase_name=$(echo "$plugin_name" | tr '[:lower:]-' '[:upper:]_')
|
||||
upcase_name=$(printf "%s\\n" "$plugin_name" | tr '[:lower:]-' '[:upper:]_')
|
||||
local version_env_var="ASDF_${upcase_name}_VERSION"
|
||||
|
||||
echo "$version|$version_env_var environment variable"
|
||||
printf "%s\\n" "$version|$version_env_var environment variable"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -204,7 +204,7 @@ find_versions() {
|
||||
while [ "$search_path" != "/" ]; do
|
||||
version=$(get_version_in_dir "$plugin_name" "$search_path" "$legacy_filenames")
|
||||
if [ -n "$version" ]; then
|
||||
echo "$version"
|
||||
printf "%s\\n" "$version"
|
||||
return 0
|
||||
fi
|
||||
search_path=$(dirname "$search_path")
|
||||
@ -215,7 +215,7 @@ find_versions() {
|
||||
if [ -f "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" ]; then
|
||||
versions=$(parse_asdf_version_file "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" "$plugin_name")
|
||||
if [ -n "$versions" ]; then
|
||||
echo "$versions|$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME"
|
||||
printf "%s\\n" "$versions|$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@ -223,16 +223,16 @@ find_versions() {
|
||||
|
||||
display_no_version_set() {
|
||||
local plugin_name=$1
|
||||
echo "No version set for ${plugin_name}; please run \`asdf <global | shell | local> ${plugin_name} <version>\`"
|
||||
printf "No version set for %s; please run \`asdf <global | shell | local> %s <version>\`\\n" "$plugin_name" "$plugin_name"
|
||||
}
|
||||
|
||||
get_version_from_env() {
|
||||
local plugin_name=$1
|
||||
local upcase_name
|
||||
upcase_name=$(echo "$plugin_name" | tr '[:lower:]-' '[:upper:]_')
|
||||
upcase_name=$(printf "%s\\n" "$plugin_name" | tr '[:lower:]-' '[:upper:]_')
|
||||
local version_env_var="ASDF_${upcase_name}_VERSION"
|
||||
local version=${!version_env_var:-}
|
||||
echo "$version"
|
||||
printf "%s\\n" "$version"
|
||||
}
|
||||
|
||||
find_install_path() {
|
||||
@ -243,7 +243,7 @@ find_install_path() {
|
||||
IFS=':' read -a version_info <<<"$version"
|
||||
|
||||
if [ "$version" = "system" ]; then
|
||||
echo ""
|
||||
printf "\\n"
|
||||
elif [ "${version_info[0]}" = "ref" ]; then
|
||||
local install_type="${version_info[0]}"
|
||||
local version="${version_info[1]}"
|
||||
@ -255,7 +255,7 @@ find_install_path() {
|
||||
# And then use the binaries there
|
||||
local install_type="path"
|
||||
local version="path"
|
||||
echo "${version_info[1]}"
|
||||
printf "%s\\n" "${version_info[1]}"
|
||||
else
|
||||
local install_type="version"
|
||||
local version="${version_info[0]}"
|
||||
@ -273,12 +273,12 @@ get_custom_executable_path() {
|
||||
cmd=$(basename "$executable_path")
|
||||
local relative_path
|
||||
# shellcheck disable=SC2001
|
||||
relative_path=$(echo "$executable_path" | sed -e "s|${install_path}/||")
|
||||
relative_path=$(printf "%s\\n" "$executable_path" | sed -e "s|${install_path}/||")
|
||||
relative_path="$("${plugin_path}/bin/exec-path" "$install_path" "$cmd" "$relative_path")"
|
||||
executable_path="$install_path/$relative_path"
|
||||
fi
|
||||
|
||||
echo "$executable_path"
|
||||
printf "%s\\n" "$executable_path"
|
||||
}
|
||||
|
||||
get_executable_path() {
|
||||
@ -289,18 +289,18 @@ get_executable_path() {
|
||||
check_if_version_exists "$plugin_name" "$version"
|
||||
|
||||
if [ "$version" = "system" ]; then
|
||||
path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
|
||||
path=$(sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g" <<<"$PATH")
|
||||
cmd=$(basename "$executable_path")
|
||||
cmd_path=$(PATH=$path command -v "$cmd" 2>&1)
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
echo "$cmd_path"
|
||||
printf "%s\\n" "$cmd_path"
|
||||
else
|
||||
local install_path
|
||||
install_path=$(find_install_path "$plugin_name" "$version")
|
||||
echo "${install_path}"/"${executable_path}"
|
||||
printf "%s\\n" "${install_path}"/"${executable_path}"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ parse_asdf_version_file() {
|
||||
local version
|
||||
version=$(strip_tool_version_comments "$file_path" | grep "^${plugin_name} " | sed -e "s/^${plugin_name} //")
|
||||
if [ -n "$version" ]; then
|
||||
echo "$version"
|
||||
printf "%s\\n" "$version"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
@ -345,7 +345,7 @@ get_preset_version_for() {
|
||||
local version
|
||||
version=$(cut -d '|' -f 1 <<<"$version_and_path")
|
||||
|
||||
echo "$version"
|
||||
printf "%s\\n" "$version"
|
||||
}
|
||||
|
||||
get_asdf_config_value_from_file() {
|
||||
@ -359,7 +359,7 @@ get_asdf_config_value_from_file() {
|
||||
local result
|
||||
result=$(grep -E "^\\s*$key\\s*=\\s*" "$config_path" | head | awk -F '=' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||
if [ -n "$result" ]; then
|
||||
echo "$result"
|
||||
printf "%s\\n" "$result"
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -398,10 +398,10 @@ initialize_or_update_repository() {
|
||||
repository_path=$(asdf_data_dir)/repository
|
||||
|
||||
if [ ! -d "$repository_path" ]; then
|
||||
echo "initializing plugin repository..."
|
||||
printf "initializing plugin repository..."
|
||||
git clone "$repository_url" "$repository_path"
|
||||
elif repository_needs_update; then
|
||||
echo "updating plugin repository..."
|
||||
printf "updating plugin repository..."
|
||||
(cd "$repository_path" && git fetch && git reset --hard origin/master)
|
||||
fi
|
||||
|
||||
@ -430,7 +430,7 @@ find_file_upwards() {
|
||||
search_path=$(pwd)
|
||||
while [ "$search_path" != "/" ]; do
|
||||
if [ -f "$search_path/$name" ]; then
|
||||
echo "${search_path}/$name"
|
||||
printf "%s\\n" "${search_path}/$name"
|
||||
return 0
|
||||
fi
|
||||
search_path=$(dirname "$search_path")
|
||||
@ -451,10 +451,10 @@ resolve_symlink() {
|
||||
# as relative
|
||||
case $resolved_path in
|
||||
/*)
|
||||
echo "$resolved_path"
|
||||
printf "%s\\n" "$resolved_path"
|
||||
;;
|
||||
*)
|
||||
echo "$PWD/$resolved_path"
|
||||
printf "%s\\n" "$PWD/$resolved_path"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@ -481,7 +481,7 @@ list_plugin_bin_paths() {
|
||||
else
|
||||
local space_separated_list_of_bin_paths="bin"
|
||||
fi
|
||||
echo "$space_separated_list_of_bin_paths"
|
||||
printf "%s\\n" "$space_separated_list_of_bin_paths"
|
||||
}
|
||||
|
||||
list_plugin_exec_paths() {
|
||||
@ -504,7 +504,7 @@ list_plugin_exec_paths() {
|
||||
local plugin_shims_path
|
||||
plugin_shims_path=$(get_plugin_path "$plugin_name")/shims
|
||||
if [ -d "$plugin_shims_path" ]; then
|
||||
echo "$plugin_shims_path"
|
||||
printf "%s\\n" "$plugin_shims_path"
|
||||
fi
|
||||
|
||||
space_separated_list_of_bin_paths="$(list_plugin_bin_paths "$plugin_name" "$version" "$install_type")"
|
||||
@ -514,7 +514,7 @@ list_plugin_exec_paths() {
|
||||
install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
|
||||
|
||||
for bin_path in "${all_bin_paths[@]}"; do
|
||||
echo "$install_path/$bin_path"
|
||||
printf "%s\\n" "$install_path/$bin_path"
|
||||
done
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@ with_plugin_env() {
|
||||
|
||||
# exec_paths contains a trailing newline which is converted to a colon, so no
|
||||
# colon is needed between the subshell and the PATH variable in this string
|
||||
path="$(echo "$exec_paths" | tr '\n' ':')$PATH"
|
||||
path="$(tr '\n' ':' <<<"$exec_paths")$PATH"
|
||||
|
||||
# If no custom exec-env transform, just execute callback
|
||||
if [ ! -f "${plugin_path}/bin/exec-env" ]; then
|
||||
@ -574,7 +574,7 @@ plugin_executables() {
|
||||
for bin_path in $(list_plugin_exec_paths "$plugin_name" "$full_version"); do
|
||||
for executable_file in "$bin_path"/*; do
|
||||
if is_executable "$executable_file"; then
|
||||
echo "$executable_file"
|
||||
printf "%s\\n" "$executable_file"
|
||||
fi
|
||||
done
|
||||
done
|
||||
@ -602,7 +602,7 @@ shim_plugin_versions() {
|
||||
if [ -x "$shim_path" ]; then
|
||||
grep "# asdf-plugin: " "$shim_path" 2>/dev/null | sed -e "s/# asdf-plugin: //" | uniq
|
||||
else
|
||||
echo "asdf: unknown shim $executable_name"
|
||||
printf "asdf: unknown shim %s\\n" "$executable_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@ -615,7 +615,7 @@ shim_plugins() {
|
||||
if [ -x "$shim_path" ]; then
|
||||
grep "# asdf-plugin: " "$shim_path" 2>/dev/null | sed -e "s/# asdf-plugin: //" | cut -d' ' -f 1 | uniq
|
||||
else
|
||||
echo "asdf: unknown shim $executable_name"
|
||||
printf "asdf: unknown shim %s\\n" "$executable_name"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@ -625,11 +625,11 @@ strip_tool_version_comments() {
|
||||
|
||||
while IFS= read -r tool_line || [ -n "$tool_line" ]; do
|
||||
# Remove whitespace before pound sign, the pound sign, and everything after it
|
||||
new_line="$(echo "$tool_line" | cut -f1 -d"#" | sed -e 's/[[:space:]]*$//')"
|
||||
new_line="$(cut -f1 -d"#" <<<"$tool_line" | sed -e 's/[[:space:]]*$//')"
|
||||
|
||||
# Only print the line if it is not empty
|
||||
if [[ -n "$new_line" ]]; then
|
||||
echo "$new_line"
|
||||
printf "%s\\n" "$new_line"
|
||||
fi
|
||||
done <"$tool_version_path"
|
||||
}
|
||||
@ -655,12 +655,12 @@ get_shim_versions() {
|
||||
|
||||
preset_versions() {
|
||||
shim_name=$1
|
||||
shim_plugin_versions "${shim_name}" | cut -d' ' -f 1 | uniq | xargs -IPLUGIN bash -c "source $(asdf_dir)/lib/utils.bash; echo PLUGIN \$(get_preset_version_for PLUGIN)"
|
||||
shim_plugin_versions "${shim_name}" | cut -d' ' -f 1 | uniq | xargs -IPLUGIN bash -c "source $(asdf_dir)/lib/utils.bash; printf \"%s %s\\n\" PLUGIN \$(get_preset_version_for PLUGIN)"
|
||||
}
|
||||
|
||||
select_from_preset_version() {
|
||||
shim_name=$1
|
||||
grep -f <(get_shim_versions "$shim_name") <(preset_versions "$shim_name") | head -n 1 | xargs echo
|
||||
grep -f <(get_shim_versions "$shim_name") <(preset_versions "$shim_name") | head -n 1 | xargs -IVERSION printf "%s\\n" VERSION
|
||||
}
|
||||
|
||||
select_version() {
|
||||
@ -694,10 +694,10 @@ select_version() {
|
||||
IFS=' ' read -r plugin_shim_name plugin_shim_version <<<"$plugin_and_version"
|
||||
if [[ "$plugin_name" == "$plugin_shim_name" ]]; then
|
||||
if [[ "$plugin_version" == "$plugin_shim_version" ]]; then
|
||||
echo "$plugin_name $plugin_version"
|
||||
printf "%s\\n" "$plugin_name $plugin_version"
|
||||
return
|
||||
elif [[ "$plugin_version" == "path:"* ]]; then
|
||||
echo "$plugin_name $plugin_version"
|
||||
printf "%s\\n" "$plugin_name $plugin_version"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@ -733,7 +733,7 @@ with_shim_executable() {
|
||||
|
||||
run_within_env() {
|
||||
local path
|
||||
path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
|
||||
path=$(sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g" <<<"$PATH")
|
||||
|
||||
executable_path=$(PATH=$path command -v "$shim_name")
|
||||
|
||||
|
@ -61,7 +61,7 @@ if ! [[ "${new_version:0:1}" =~ ^[0-9]+$ ]]; then
|
||||
fi
|
||||
|
||||
# Make sure the version the user provided hasn't already been tagged
|
||||
if git tag | grep "$new_tag_name" >/dev/null; then
|
||||
if git tag | grep "^$new_tag_name$" >/dev/null; then
|
||||
echo >&2 "ERROR: git tag with that version already exists"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -16,6 +16,9 @@ banned_commands=(
|
||||
"grep.* -y"
|
||||
# sort -V isn't supported everywhere
|
||||
"sort.*-V"
|
||||
# echo isn't consistent across operating systems, and sometimes output can
|
||||
# be confused with echo flags. printf does everything echo does and more.
|
||||
echo
|
||||
)
|
||||
|
||||
setup() {
|
||||
|
@ -20,8 +20,7 @@ teardown() {
|
||||
@test "current should derive from the current .tool-versions" {
|
||||
cd $PROJECT_DIR
|
||||
echo 'dummy 1.1.0' >> $PROJECT_DIR/.tool-versions
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy 1.1.0 $PROJECT_DIR/.tool-versions"
|
||||
expected="dummy 1.1.0 $PROJECT_DIR/.tool-versions"
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
@ -31,8 +30,7 @@ dummy 1.1.0 $PROJECT_DIR/.tool-versions"
|
||||
@test "current should handle long version name" {
|
||||
cd $PROJECT_DIR
|
||||
echo "dummy nightly-2000-01-01" >> $PROJECT_DIR/.tool-versions
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy nightly-2000-01-01 $PROJECT_DIR/.tool-versions"
|
||||
expected="dummy nightly-2000-01-01 $PROJECT_DIR/.tool-versions"
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
@ -42,8 +40,7 @@ dummy nightly-2000-01-01 $PROJECT_DIR/.tool-versions"
|
||||
@test "current should handle multiple versions" {
|
||||
cd $PROJECT_DIR
|
||||
echo "dummy 1.2.0 1.1.0" >> $PROJECT_DIR/.tool-versions
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy 1.2.0 1.1.0 $PROJECT_DIR/.tool-versions"
|
||||
expected="dummy 1.2.0 1.1.0 $PROJECT_DIR/.tool-versions"
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
@ -55,8 +52,7 @@ dummy 1.2.0 1.1.0 $PROJECT_DIR/.tool-versions"
|
||||
cd $PROJECT_DIR
|
||||
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
||||
echo '1.2.0' >> $PROJECT_DIR/.dummy-version
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy 1.2.0 $PROJECT_DIR/.dummy-version"
|
||||
expected="dummy 1.2.0 $PROJECT_DIR/.dummy-version"
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
@ -65,8 +61,7 @@ dummy 1.2.0 $PROJECT_DIR/.dummy-version"
|
||||
|
||||
# TODO: Need to fix plugin error as well
|
||||
@test "current should error when the plugin doesn't exist" {
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
No such plugin: foobar"
|
||||
expected="No such plugin: foobar"
|
||||
|
||||
run asdf current "foobar"
|
||||
[ "$status" -eq 1 ]
|
||||
@ -75,8 +70,7 @@ No such plugin: foobar"
|
||||
|
||||
@test "current should error when no version is set" {
|
||||
cd $PROJECT_DIR
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy ______ No version set. Run \"asdf <global|shell|local> dummy <version>\""
|
||||
expected="dummy ______ No version set. Run \"asdf <global|shell|local> dummy <version>\""
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 126 ]
|
||||
@ -86,8 +80,7 @@ dummy ______ No version set. Run \"asdf <global|shell|local>
|
||||
@test "current should error when a version is set that isn't installed" {
|
||||
cd $PROJECT_DIR
|
||||
echo 'dummy 9.9.9' >> $PROJECT_DIR/.tool-versions
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy 9.9.9 Not installed. Run \"asdf install dummy 9.9.9\""
|
||||
expected="dummy 9.9.9 Not installed. Run \"asdf install dummy 9.9.9\""
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 1 ]
|
||||
@ -109,8 +102,7 @@ dummy 9.9.9 Not installed. Run \"asdf install dummy 9.9.9\""
|
||||
echo 'foobar 1.0.0' >> $PROJECT_DIR/.tool-versions
|
||||
|
||||
run asdf current
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
baz ______ No version set. Run \"asdf <global|shell|local> baz <version>\"
|
||||
expected="baz ______ No version set. Run \"asdf <global|shell|local> baz <version>\"
|
||||
dummy 1.1.0 $PROJECT_DIR/.tool-versions
|
||||
foobar 1.0.0 $PROJECT_DIR/.tool-versions"
|
||||
|
||||
@ -135,8 +127,7 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"
|
||||
|
||||
@test "with no plugins prints an error" {
|
||||
clean_asdf_dir
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
Oohes nooes ~! No plugins installed"
|
||||
expected="Oohes nooes ~! No plugins installed"
|
||||
|
||||
run asdf current
|
||||
[ "$status" -eq 0 ]
|
||||
@ -146,8 +137,7 @@ Oohes nooes ~! No plugins installed"
|
||||
@test "current should handle comments" {
|
||||
cd $PROJECT_DIR
|
||||
echo "dummy 1.2.0 # this is a comment" >> $PROJECT_DIR/.tool-versions
|
||||
expected="PLUGIN VERSION SET BY CONFIG
|
||||
dummy 1.2.0 $PROJECT_DIR/.tool-versions"
|
||||
expected="dummy 1.2.0 $PROJECT_DIR/.tool-versions"
|
||||
|
||||
run asdf current "dummy"
|
||||
[ "$status" -eq 0 ]
|
||||
|
2
test/fixtures/dummy_plugin/bin/list-all
vendored
2
test/fixtures/dummy_plugin/bin/list-all
vendored
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
versions_list=(1.0 1.1 2.0)
|
||||
versions_list=(1.0.0 1.1.0 2.0.0)
|
||||
echo "${versions_list[@]}"
|
||||
|
@ -16,38 +16,38 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "install_command installs the correct version" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
}
|
||||
|
||||
@test "install_command installs the correct version for plugins without download script" {
|
||||
run asdf install legacy-dummy 1.1
|
||||
run asdf install legacy-dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/legacy-dummy/1.1/version) = "1.1" ]
|
||||
[ $(cat $ASDF_DIR/installs/legacy-dummy/1.1.0/version) = "1.1.0" ]
|
||||
}
|
||||
|
||||
@test "install_command without arguments installs even if the user is terrible and does not use newlines" {
|
||||
cd $PROJECT_DIR
|
||||
echo -n 'dummy 1.2' > ".tool-versions"
|
||||
echo -n 'dummy 1.2.0' > ".tool-versions"
|
||||
run asdf install
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ]
|
||||
}
|
||||
|
||||
@test "install_command with only name installs the version in .tool-versions" {
|
||||
cd $PROJECT_DIR
|
||||
echo -n 'dummy 1.2' > ".tool-versions"
|
||||
echo -n 'dummy 1.2.0' > ".tool-versions"
|
||||
run asdf install dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ]
|
||||
}
|
||||
|
||||
@test "install_command set ASDF_CONCURRENCY" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.0.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0/env ]
|
||||
run grep ASDF_CONCURRENCY $ASDF_DIR/installs/dummy/1.0/env
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0.0/env ]
|
||||
run grep ASDF_CONCURRENCY $ASDF_DIR/installs/dummy/1.0.0/env
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@ -55,55 +55,55 @@ teardown() {
|
||||
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
|
||||
mkdir -p "$WHITESPACE_DIR"
|
||||
cd "$WHITESPACE_DIR"
|
||||
echo 'dummy 1.2' >> "$WHITESPACE_DIR/.tool-versions"
|
||||
echo 'dummy 1.2.0' >> "$WHITESPACE_DIR/.tool-versions"
|
||||
|
||||
run asdf install
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ]
|
||||
}
|
||||
|
||||
@test "install_command should create a shim with asdf-plugin metadata" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.0.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0/env ]
|
||||
run grep "asdf-plugin: dummy 1.0" $ASDF_DIR/shims/dummy
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0.0/env ]
|
||||
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "install_command should create a shim with asdf-plugin metadata for plugins without download script" {
|
||||
run asdf install legacy-dummy 1.0
|
||||
run asdf install legacy-dummy 1.0.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/legacy-dummy/1.0/env ]
|
||||
run grep "asdf-plugin: legacy-dummy 1.0" $ASDF_DIR/shims/dummy
|
||||
[ -f $ASDF_DIR/installs/legacy-dummy/1.0.0/env ]
|
||||
run grep "asdf-plugin: legacy-dummy 1.0.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "install_command on two versions should create a shim with asdf-plugin metadata" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
run grep "asdf-plugin: dummy 1.1" $ASDF_DIR/shims/dummy
|
||||
run grep "asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
run grep "asdf-plugin: dummy 1.0" $ASDF_DIR/shims/dummy
|
||||
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 1 ]
|
||||
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.0.0
|
||||
[ "$status" -eq 0 ]
|
||||
run grep "asdf-plugin: dummy 1.0" $ASDF_DIR/shims/dummy
|
||||
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
run grep "# asdf-plugin: dummy 1.0"$'\n'"# asdf-plugin: dummy 1.1" $ASDF_DIR/shims/dummy
|
||||
run grep "# asdf-plugin: dummy 1.0.0"$'\n'"# asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
lines_count=$(grep "asdf-plugin: dummy 1.1" $ASDF_DIR/shims/dummy | wc -l)
|
||||
lines_count=$(grep "asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy | wc -l)
|
||||
[ "$lines_count" -eq "1" ]
|
||||
}
|
||||
|
||||
@test "install_command without arguments should not generate shim for subdir" {
|
||||
cd $PROJECT_DIR
|
||||
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
|
||||
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions
|
||||
|
||||
run asdf install
|
||||
[ "$status" -eq 0 ]
|
||||
@ -116,44 +116,44 @@ teardown() {
|
||||
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
||||
|
||||
cd $PROJECT_DIR
|
||||
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
|
||||
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions
|
||||
run asdf install
|
||||
|
||||
# execute the generated shim
|
||||
run $ASDF_DIR/shims/dummy world hello
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" == "This is Dummy 1.0! hello world" ]
|
||||
[ "$output" == "This is Dummy 1.0.0! hello world" ]
|
||||
}
|
||||
|
||||
@test "install_command fails when tool is specified but no version of the tool is configured" {
|
||||
run asdf install dummy
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "No versions specified for dummy in config files or environment" ]
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.1.0/version ]
|
||||
}
|
||||
|
||||
@test "install_command fails when tool is specified but no version of the tool is configured in config file" {
|
||||
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
|
||||
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions
|
||||
run asdf install other-dummy
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "No versions specified for other-dummy in config files or environment" ]
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.0/version ]
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.0.0/version ]
|
||||
}
|
||||
|
||||
@test "install_command fails when two tools are specified with no versions" {
|
||||
printf 'dummy 1.0\nother-dummy 2.0' > $PROJECT_DIR/.tool-versions
|
||||
printf 'dummy 1.0.0\nother-dummy 2.0.0' > $PROJECT_DIR/.tool-versions
|
||||
run asdf install dummy other-dummy
|
||||
[ "$status" -eq 1 ]
|
||||
[ "$output" = "Dummy couldn't install version: other-dummy (on purpose)" ]
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.0/version ]
|
||||
[ ! -f $ASDF_DIR/installs/other-dummy/2.0/version ]
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.0.0/version ]
|
||||
[ ! -f $ASDF_DIR/installs/other-dummy/2.0.0/version ]
|
||||
}
|
||||
|
||||
@test "install_command without arguments uses a parent directory .tool-versions file if present" {
|
||||
# asdf lib needed to run generated shims
|
||||
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
|
||||
|
||||
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions
|
||||
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions
|
||||
mkdir -p $PROJECT_DIR/child
|
||||
|
||||
cd $PROJECT_DIR/child
|
||||
@ -161,20 +161,20 @@ teardown() {
|
||||
run asdf install
|
||||
|
||||
# execute the generated shim
|
||||
[ "$($ASDF_DIR/shims/dummy world hello)" == "This is Dummy 1.0! hello world" ]
|
||||
[ "$($ASDF_DIR/shims/dummy world hello)" == "This is Dummy 1.0.0! hello world" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "install_command installs multiple tool versions when they are specified in a .tool-versions file" {
|
||||
echo 'dummy 1.0 1.2' > $PROJECT_DIR/.tool-versions
|
||||
echo 'dummy 1.0.0 1.2.0' > $PROJECT_DIR/.tool-versions
|
||||
cd $PROJECT_DIR
|
||||
|
||||
run asdf install
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.0/version) = "1.0" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.0.0/version) = "1.0.0" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ]
|
||||
}
|
||||
|
||||
@test "install_command doesn't install system version" {
|
||||
@ -188,8 +188,8 @@ teardown() {
|
||||
pre_asdf_install_dummy = echo will install dummy $1
|
||||
EOM
|
||||
|
||||
run asdf install dummy 1.0
|
||||
[ "$output" == "will install dummy 1.0" ]
|
||||
run asdf install dummy 1.0.0
|
||||
[ "$output" == "will install dummy 1.0.0" ]
|
||||
}
|
||||
|
||||
@test "install command executes configured post plugin install hook" {
|
||||
@ -197,23 +197,23 @@ EOM
|
||||
post_asdf_install_dummy = echo HEY $version FROM $plugin_name
|
||||
EOM
|
||||
|
||||
run asdf install dummy 1.0
|
||||
[ "$output" == "HEY 1.0 FROM dummy" ]
|
||||
run asdf install dummy 1.0.0
|
||||
[ "$output" == "HEY 1.0.0 FROM dummy" ]
|
||||
}
|
||||
|
||||
@test "install command without arguments installs versions from legacy files" {
|
||||
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
||||
echo '1.2' >> $PROJECT_DIR/.dummy-version
|
||||
echo '1.2.0' >> $PROJECT_DIR/.dummy-version
|
||||
cd $PROJECT_DIR
|
||||
run asdf install
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" == "" ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.2/version ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.2.0/version ]
|
||||
}
|
||||
|
||||
@test "install command without arguments installs versions from legacy files in parent directories" {
|
||||
echo 'legacy_version_file = yes' > $HOME/.asdfrc
|
||||
echo '1.2' >> $PROJECT_DIR/.dummy-version
|
||||
echo '1.2.0' >> $PROJECT_DIR/.dummy-version
|
||||
|
||||
mkdir -p $PROJECT_DIR/child
|
||||
cd $PROJECT_DIR/child
|
||||
@ -221,40 +221,40 @@ EOM
|
||||
run asdf install
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" == "" ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.2/version ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.2.0/version ]
|
||||
}
|
||||
|
||||
@test "install_command latest installs latest stable version" {
|
||||
run asdf install dummy latest
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/2.0/version) = "2.0" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/2.0.0/version) = "2.0.0" ]
|
||||
}
|
||||
|
||||
@test "install_command latest:version installs latest stable version that matches the given string" {
|
||||
run asdf install dummy latest:1
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
}
|
||||
|
||||
@test "install_command deletes the download directory" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -d $ASDF_DIR/downloads/dummy/1.1 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
[ ! -d $ASDF_DIR/downloads/dummy/1.1.0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
}
|
||||
|
||||
@test "install_command keeps the download directory when --keep-download flag is provided" {
|
||||
run asdf install dummy 1.1 --keep-download
|
||||
run asdf install dummy 1.1.0 --keep-download
|
||||
[ "$status" -eq 0 ]
|
||||
[ -d $ASDF_DIR/downloads/dummy/1.1 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
[ -d $ASDF_DIR/downloads/dummy/1.1.0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
}
|
||||
|
||||
@test "install_command keeps the download directory when always_keep_download setting is true" {
|
||||
echo 'always_keep_download = yes' > $HOME/.asdfrc
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
echo $output
|
||||
[ "$status" -eq 0 ]
|
||||
[ -d $ASDF_DIR/downloads/dummy/1.1 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
[ -d $ASDF_DIR/downloads/dummy/1.1.0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ teardown() {
|
||||
|
||||
@test "latest_command shows latest stable version" {
|
||||
run asdf latest dummy
|
||||
[ "$(echo -e "2.0")" == "$output" ]
|
||||
[ "$(echo -e "2.0.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "latest_command with version shows latest stable version that matches the given string" {
|
||||
run asdf latest dummy 1
|
||||
[ "$(echo -e "1.1")" == "$output" ]
|
||||
[ "$(echo -e "1.1.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "list_command should list plugins with installed versions" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.0.0
|
||||
run asdf install dummy 1.1.0
|
||||
run asdf list
|
||||
[ "$(echo -e "dummy\n 1.0\n 1.1")" == "$output" ]
|
||||
[ "$(echo -e "dummy\n 1.0.0\n 1.1.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@ -23,29 +23,29 @@ teardown() {
|
||||
run install_mock_plugin "dummy"
|
||||
run install_mock_plugin "mummy"
|
||||
run install_mock_plugin "tummy"
|
||||
run asdf install dummy 1.0
|
||||
run asdf install tummy 2.0
|
||||
run asdf install dummy 1.0.0
|
||||
run asdf install tummy 2.0.0
|
||||
run asdf list
|
||||
[ "$(echo -e "dummy\n 1.0\nmummy\n No versions installed\ntummy\n 2.0")" == "$output" ]
|
||||
[ "$(echo -e "dummy\n 1.0.0\nmummy\n No versions installed\ntummy\n 2.0.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "list_command with plugin should list installed versions" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.0.0
|
||||
run asdf install dummy 1.1.0
|
||||
run asdf list dummy
|
||||
[ "$(echo -e " 1.0\n 1.1")" == "$output" ]
|
||||
[ "$(echo -e " 1.0.0\n 1.1.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "list_all_command lists available versions" {
|
||||
run asdf list-all dummy
|
||||
[ "$(echo -e "1.0\n1.1\n2.0")" == "$output" ]
|
||||
[ "$(echo -e "1.0.0\n1.1.0\n2.0.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "list_all_command with version filters available versions" {
|
||||
run asdf list-all dummy 1
|
||||
[ "$(echo -e "1.0\n1.1")" == "$output" ]
|
||||
[ "$(echo -e "1.0.0\n1.1.0")" == "$output" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
65
test/plugin_update_command.bats
Normal file
65
test/plugin_update_command.bats
Normal file
@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load test_helpers
|
||||
|
||||
setup() {
|
||||
BASE_DIR=$(mktemp -dt asdf.XXXX)
|
||||
HOME=$BASE_DIR/home
|
||||
ASDF_DIR=$HOME/.asdf
|
||||
git clone -o local "$(dirname "$BATS_TEST_DIRNAME")" "$ASDF_DIR"
|
||||
git --git-dir "$ASDF_DIR/.git" remote add origin https://github.com/asdf-vm/asdf.git
|
||||
mkdir -p "$ASDF_DIR/plugins"
|
||||
ASDF_BIN="$ASDF_DIR/bin"
|
||||
|
||||
# shellcheck disable=SC2031
|
||||
PATH=$ASDF_BIN:$ASDF_DIR/shims:$PATH
|
||||
install_dummy_plugin
|
||||
|
||||
PROJECT_DIR=$HOME/project
|
||||
mkdir $PROJECT_DIR
|
||||
}
|
||||
|
||||
teardown() {
|
||||
clean_asdf_dir
|
||||
}
|
||||
|
||||
@test "asdf plugin-update should pull latest master branch for plugin" {
|
||||
run asdf plugin-update dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" =~ "Updating dummy..."* ]]
|
||||
cd $ASDF_DIR/plugins/dummy
|
||||
[ $(git rev-parse --abbrev-ref HEAD) = "master" ]
|
||||
}
|
||||
|
||||
@test "asdf plugin-update should not remove plugin versions" {
|
||||
run asdf install dummy 1.1
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
run asdf plugin-update dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||
run asdf plugin-update --all
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||
}
|
||||
|
||||
@test "asdf plugin-update should not remove plugins" {
|
||||
# dummy plugin is already installed
|
||||
run asdf plugin-update dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ -d $ASDF_DIR/plugins/dummy ]
|
||||
run asdf plugin-update --all
|
||||
[ "$status" -eq 0 ]
|
||||
[ -d $ASDF_DIR/plugins/dummy ]
|
||||
}
|
||||
|
||||
@test "asdf plugin-update should not remove shims" {
|
||||
run asdf install dummy 1.1
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
run asdf plugin-update dummy
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
run asdf plugin-update --all
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
}
|
@ -82,7 +82,7 @@ teardown() {
|
||||
|
||||
@test "shim exec should suggest which plugin to use when no version is selected" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
|
||||
touch $PROJECT_DIR/.tool-versions
|
||||
|
||||
@ -92,7 +92,7 @@ teardown() {
|
||||
echo "$output" | grep -q "No version set for command dummy" 2>/dev/null
|
||||
echo "$output" | grep -q "Consider adding one of the following versions in your config file at $PROJECT_DIR/.tool-versions" 2>/dev/null
|
||||
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
|
||||
echo "$output" | grep -q "dummy 2.0" 2>/dev/null
|
||||
echo "$output" | grep -q "dummy 2.0.0" 2>/dev/null
|
||||
}
|
||||
|
||||
@test "shim exec should suggest different plugins providing same tool when no version is selected" {
|
||||
@ -116,23 +116,23 @@ teardown() {
|
||||
@test "shim exec should suggest to install missing version" {
|
||||
run asdf install dummy 1.0
|
||||
|
||||
echo "dummy 2.0 1.3" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0 1.3" > $PROJECT_DIR/.tool-versions
|
||||
|
||||
run $ASDF_DIR/shims/dummy world hello
|
||||
[ "$status" -eq 126 ]
|
||||
echo "$output" | grep -q "No preset version installed for command dummy" 2>/dev/null
|
||||
echo "$output" | grep -q "Please install a version by running one of the following:" 2>/dev/null
|
||||
echo "$output" | grep -q "asdf install dummy 2.0" 2>/dev/null
|
||||
echo "$output" | grep -q "asdf install dummy 2.0.0" 2>/dev/null
|
||||
echo "$output" | grep -q "asdf install dummy 1.3" 2>/dev/null
|
||||
echo "$output" | grep -q "or add one of the following versions in your config file at $PROJECT_DIR/.tool-versions" 2>/dev/null
|
||||
echo "$output" | grep -q "dummy 1.0" 2>/dev/null
|
||||
}
|
||||
|
||||
@test "shim exec should execute first plugin that is installed and set" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
run asdf install dummy 3.0
|
||||
|
||||
echo "dummy 1.0 3.0 2.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 1.0 3.0 2.0.0" > $PROJECT_DIR/.tool-versions
|
||||
|
||||
run $ASDF_DIR/shims/dummy world hello
|
||||
[ "$status" -eq 0 ]
|
||||
@ -183,7 +183,7 @@ teardown() {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install mummy 3.0
|
||||
|
||||
echo "dummy 2.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "mummy 3.0" >> $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 1.0" >> $PROJECT_DIR/.tool-versions
|
||||
|
||||
@ -221,10 +221,10 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "shim exec should execute system if set first" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
|
||||
echo "dummy system" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0" >> $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0" >> $PROJECT_DIR/.tool-versions
|
||||
|
||||
mkdir $PROJECT_DIR/foo/
|
||||
echo "echo System" > $PROJECT_DIR/foo/dummy
|
||||
@ -235,38 +235,38 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "shim exec should use custom exec-env for tool" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
echo "export FOO=sourced" > $ASDF_DIR/plugins/dummy/bin/exec-env
|
||||
mkdir $ASDF_DIR/plugins/dummy/shims
|
||||
echo 'echo $FOO custom' > $ASDF_DIR/plugins/dummy/shims/foo
|
||||
chmod +x $ASDF_DIR/plugins/dummy/shims/foo
|
||||
run asdf reshim dummy 2.0
|
||||
run asdf reshim dummy 2.0.0
|
||||
|
||||
echo "dummy 2.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0" > $PROJECT_DIR/.tool-versions
|
||||
run $ASDF_DIR/shims/foo
|
||||
[ "$output" == "sourced custom" ]
|
||||
}
|
||||
|
||||
@test "shim exec with custom exec-env using ASDF_INSTALL_PATH" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
echo 'export FOO=$ASDF_INSTALL_PATH/foo' > $ASDF_DIR/plugins/dummy/bin/exec-env
|
||||
mkdir $ASDF_DIR/plugins/dummy/shims
|
||||
echo 'echo $FOO custom' > $ASDF_DIR/plugins/dummy/shims/foo
|
||||
chmod +x $ASDF_DIR/plugins/dummy/shims/foo
|
||||
run asdf reshim dummy 2.0
|
||||
run asdf reshim dummy 2.0.0
|
||||
|
||||
echo "dummy 2.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0" > $PROJECT_DIR/.tool-versions
|
||||
run $ASDF_DIR/shims/foo
|
||||
[ "$output" == "$ASDF_DIR/installs/dummy/2.0/foo custom" ]
|
||||
[ "$output" == "$ASDF_DIR/installs/dummy/2.0.0/foo custom" ]
|
||||
}
|
||||
|
||||
@test "shim exec doest not use custom exec-env for system version" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
echo "export FOO=sourced" > $ASDF_DIR/plugins/dummy/bin/exec-env
|
||||
mkdir $ASDF_DIR/plugins/dummy/shims
|
||||
echo 'echo $FOO custom' > $ASDF_DIR/plugins/dummy/shims/foo
|
||||
chmod +x $ASDF_DIR/plugins/dummy/shims/foo
|
||||
run asdf reshim dummy 2.0
|
||||
run asdf reshim dummy 2.0.0
|
||||
|
||||
echo "dummy system" > $PROJECT_DIR/.tool-versions
|
||||
|
||||
@ -279,24 +279,24 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "shim exec should prepend the plugin paths on execution" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
|
||||
mkdir $ASDF_DIR/plugins/dummy/shims
|
||||
echo 'which dummy' > $ASDF_DIR/plugins/dummy/shims/foo
|
||||
chmod +x $ASDF_DIR/plugins/dummy/shims/foo
|
||||
run asdf reshim dummy 2.0
|
||||
run asdf reshim dummy 2.0.0
|
||||
|
||||
echo "dummy 2.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0" > $PROJECT_DIR/.tool-versions
|
||||
|
||||
run $ASDF_DIR/shims/foo
|
||||
[ "$output" == "$ASDF_DIR/installs/dummy/2.0/bin/dummy" ]
|
||||
[ "$output" == "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ]
|
||||
}
|
||||
|
||||
@test "shim exec should be able to find other shims in path" {
|
||||
cp -rf $ASDF_DIR/plugins/dummy $ASDF_DIR/plugins/gummy
|
||||
|
||||
echo "dummy 2.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "gummy 2.0" >> $PROJECT_DIR/.tool-versions
|
||||
echo "dummy 2.0.0" > $PROJECT_DIR/.tool-versions
|
||||
echo "gummy 2.0.0" >> $PROJECT_DIR/.tool-versions
|
||||
|
||||
run asdf install
|
||||
|
||||
@ -314,14 +314,14 @@ teardown() {
|
||||
run asdf reshim
|
||||
|
||||
run $ASDF_DIR/shims/foo
|
||||
[ "$output" == "$ASDF_DIR/installs/dummy/2.0/bin/dummy" ]
|
||||
[ "$output" == "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ]
|
||||
|
||||
run $ASDF_DIR/shims/bar
|
||||
[ "$output" == "$ASDF_DIR/shims/gummy" ]
|
||||
}
|
||||
|
||||
@test "shim exec should remove shim_path from path on system version execution" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
|
||||
echo "dummy system" > $PROJECT_DIR/.tool-versions
|
||||
|
||||
@ -336,19 +336,19 @@ teardown() {
|
||||
|
||||
|
||||
@test "shim exec can take version from legacy file if configured" {
|
||||
run asdf install dummy 2.0
|
||||
run asdf install dummy 2.0.0
|
||||
|
||||
echo "legacy_version_file = yes" > $HOME/.asdfrc
|
||||
echo "2.0" > $PROJECT_DIR/.dummy-version
|
||||
echo "2.0.0" > $PROJECT_DIR/.dummy-version
|
||||
|
||||
run $ASDF_DIR/shims/dummy world hello
|
||||
[ "$output" == "This is Dummy 2.0! hello world" ]
|
||||
[ "$output" == "This is Dummy 2.0.0! hello world" ]
|
||||
}
|
||||
|
||||
@test "shim exec can take version from environment variable" {
|
||||
run asdf install dummy 2.0
|
||||
run env ASDF_DUMMY_VERSION=2.0 $ASDF_DIR/shims/dummy world hello
|
||||
[ "$output" == "This is Dummy 2.0! hello world" ]
|
||||
run asdf install dummy 2.0.0
|
||||
run env ASDF_DUMMY_VERSION=2.0.0 $ASDF_DIR/shims/dummy world hello
|
||||
[ "$output" == "This is Dummy 2.0.0! hello world" ]
|
||||
}
|
||||
|
||||
@test "shim exec uses plugin list-bin-paths" {
|
||||
|
@ -21,65 +21,65 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "uninstall_command should remove the plugin with that version from asdf" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
run asdf uninstall dummy 1.1
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
run asdf uninstall dummy 1.1.0
|
||||
[ ! -f $ASDF_DIR/installs/dummy/1.1.0/version ]
|
||||
}
|
||||
|
||||
@test "uninstall_command should invoke the plugin bin/uninstall if available" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
mkdir -p $ASDF_DIR/plugins/dummy/bin
|
||||
echo "echo custom uninstall" > $ASDF_DIR/plugins/dummy/bin/uninstall
|
||||
chmod 755 $ASDF_DIR/plugins/dummy/bin/uninstall
|
||||
run asdf uninstall dummy 1.1
|
||||
run asdf uninstall dummy 1.1.0
|
||||
[ "$output" == "custom uninstall" ]
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "uninstall_command should remove the plugin shims if no other version is installed" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
run asdf uninstall dummy 1.1
|
||||
run asdf uninstall dummy 1.1.0
|
||||
[ ! -f $ASDF_DIR/shims/dummy ]
|
||||
}
|
||||
|
||||
@test "uninstall_command should leave the plugin shims if other version is installed" {
|
||||
run asdf install dummy 1.0
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0/bin/dummy ]
|
||||
run asdf install dummy 1.0.0
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0.0/bin/dummy ]
|
||||
|
||||
run asdf install dummy 1.1
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1/bin/dummy ]
|
||||
run asdf install dummy 1.1.0
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1.0/bin/dummy ]
|
||||
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
run asdf uninstall dummy 1.0
|
||||
run asdf uninstall dummy 1.0.0
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
}
|
||||
|
||||
@test "uninstall_command should remove relevant asdf-plugin metadata" {
|
||||
run asdf install dummy 1.0
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0/bin/dummy ]
|
||||
run asdf install dummy 1.0.0
|
||||
[ -f $ASDF_DIR/installs/dummy/1.0.0/bin/dummy ]
|
||||
|
||||
run asdf install dummy 1.1
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1/bin/dummy ]
|
||||
run asdf install dummy 1.1.0
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1.0/bin/dummy ]
|
||||
|
||||
run asdf uninstall dummy 1.0
|
||||
run grep "asdf-plugin: dummy 1.1" $ASDF_DIR/shims/dummy
|
||||
run asdf uninstall dummy 1.0.0
|
||||
run grep "asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 0 ]
|
||||
run grep "asdf-plugin: dummy 1.0" $ASDF_DIR/shims/dummy
|
||||
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "uninstall_command should not remove other unrelated shims" {
|
||||
run asdf install dummy 1.0
|
||||
run asdf install dummy 1.0.0
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
|
||||
touch $ASDF_DIR/shims/gummy
|
||||
[ -f $ASDF_DIR/shims/gummy ]
|
||||
|
||||
run asdf uninstall dummy 1.0
|
||||
run asdf uninstall dummy 1.0.0
|
||||
[ -f $ASDF_DIR/shims/gummy ]
|
||||
}
|
||||
|
||||
@ -88,9 +88,9 @@ teardown() {
|
||||
pre_asdf_uninstall_dummy = echo will uninstall dummy $1
|
||||
EOM
|
||||
|
||||
run asdf install dummy 1.0
|
||||
run asdf uninstall dummy 1.0
|
||||
[ "$output" == "will uninstall dummy 1.0" ]
|
||||
run asdf install dummy 1.0.0
|
||||
run asdf uninstall dummy 1.0.0
|
||||
[ "$output" == "will uninstall dummy 1.0.0" ]
|
||||
}
|
||||
|
||||
@test "uninstall command executes configured post hook" {
|
||||
@ -98,8 +98,8 @@ EOM
|
||||
post_asdf_uninstall_dummy = echo removed dummy $1
|
||||
EOM
|
||||
|
||||
run asdf install dummy 1.0
|
||||
run asdf uninstall dummy 1.0
|
||||
run asdf install dummy 1.0.0
|
||||
run asdf uninstall dummy 1.0.0
|
||||
echo $output
|
||||
[ "$output" == "removed dummy 1.0" ]
|
||||
[ "$output" == "removed dummy 1.0.0" ]
|
||||
}
|
||||
|
@ -74,15 +74,15 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "asdf update should not remove plugin versions" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ "$status" -eq 0 ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1/version) = "1.1" ]
|
||||
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
|
||||
run asdf update
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1.0/version ]
|
||||
run asdf update --head
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
|
||||
[ -f $ASDF_DIR/installs/dummy/1.1.0/version ]
|
||||
}
|
||||
|
||||
@test "asdf update should not remove plugins" {
|
||||
@ -96,7 +96,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "asdf update should not remove shims" {
|
||||
run asdf install dummy 1.1
|
||||
run asdf install dummy 1.1.0
|
||||
[ -f $ASDF_DIR/shims/dummy ]
|
||||
run asdf update
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -7,6 +7,7 @@ setup() {
|
||||
install_dummy_plugin
|
||||
install_dummy_version "1.0.0"
|
||||
install_dummy_version "1.1.0"
|
||||
install_dummy_version "2.0.0"
|
||||
|
||||
PROJECT_DIR=$HOME/project
|
||||
mkdir -p $PROJECT_DIR
|
||||
@ -303,3 +304,24 @@ false"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$output" = "set -e ASDF_DUMMY_VERSION" ]
|
||||
}
|
||||
|
||||
@test "shell wrapper function should support latest" {
|
||||
source $(dirname "$BATS_TEST_DIRNAME")/asdf.sh
|
||||
asdf shell "dummy" "latest"
|
||||
[ $(echo $ASDF_DUMMY_VERSION) = "2.0.0" ]
|
||||
unset ASDF_DUMMY_VERSION
|
||||
}
|
||||
|
||||
@test "global should support latest" {
|
||||
echo 'dummy 1.0.0' >> $HOME/.tool-versions
|
||||
run asdf global "dummy" "1.0.0" "latest"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat $HOME/.tool-versions)" = "dummy 1.0.0 2.0.0" ]
|
||||
}
|
||||
|
||||
@test "local should support latest" {
|
||||
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions
|
||||
run asdf local "dummy" "1.0.0" "latest"
|
||||
[ "$status" -eq 0 ]
|
||||
[ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.0.0 2.0.0" ]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user