Commit Graph

127 Commits

Author SHA1 Message Date
Victor Hugo Borja
4b40e80776 Test that command being executed can see other tools shims on path 2019-01-23 22:18:18 -06:00
Victor Hugo Borja
0260c442cc Test to ensure asdf exec and asdf env use plugin custom exec-env 2019-01-21 01:33:52 -06:00
Victor Hugo Borja
ab59e5618f Move common functionality to utils.sh
- Make shim-exec, shim-env, and which use the same logic to look for commands
- Make sure shim-exec and which use a plugin exec-path hook as documented
  (the hook takes a relative path to the executable and returns also
   a relative path, possibly modified)
- Fix shellchecks
2019-01-20 14:02:22 -06:00
Victor Hugo Borja
9cac0ac50a Faster exec times. Load commands only when nedded.
When testing, use `run asdf` to actually test the command
as the user would invoke it, so that we might catch possible
errors on `bin/asdf`.
2019-01-20 02:13:20 -06:00
Victor Hugo Borja
8927a4a09f Add asdf env command 2019-01-19 20:59:27 -06:00
Victor Hugo Borja
6da747b6ce Test that asdf exec works even if asdf shims are not in PATH. 2019-01-19 20:09:53 -06:00
Victor Hugo Borja
e51f778b61 Move bin/private/asdf-tool-exec to be asdf exec command
This way the code for executing shims can also be invoked via
`asdf exec <tool> [args..]` and can be linted.
2019-01-19 20:02:14 -06:00
Victor Hugo Borja
a46eaf3b4a Merge remote-tracking branch 'origin/shim-versions-command' into 0.6.4-dev 2019-01-19 13:56:56 -06:00
Victor Hugo Borja
9420ca1aec Add hooks for plugin uninstall 2019-01-19 13:48:21 -06:00
Victor Hugo Borja
dcc3727cab Add pre-install and pre-reshim hooks 2019-01-19 13:32:07 -06:00
Victor Hugo Borja
9a79ac9526 user configurable pre-post command hooks
Suppose a `foo` plugin is installed and provides a `bar` executable.
The following hooks will be executed when set in `.asdfrc`:

```shell
post_asdf_install_foo = echo installed foo version ${1}
post_asdf_reshim_foo = echo reshimmed foo version ${1}

pre_foo_bar = echo about to execute command bar from foo with args: ${@}
post_foo_bar = echo just executed command bar from foo with args: ${@}
```
2019-01-19 13:32:07 -06:00
Victor Hugo Borja
7fda291df0 Add asdf shim-versions command (#380)
For example `asdf shim-versions npm` will list the plugins and their
versions on which the `npm` command is available.

Based on #432
2019-01-19 13:31:26 -06:00
Victor Hugo Borja
9b27848d07 New shim metadata to allow many plugins with same executable names
Features

* New shim version meta-data allows shims to not depend on a particular plugin
  nor on its relative executable path (#431)
  Upgrading requires shim re-generation and should happen automatically
  by `asdf-exec`:
    `rm -rf ~/.asdf/shims/` followed by `asdf reshim`
* Added lots of tests for shim execution.
  We now make sure that shim execution obeys plugins hooks like
  `list-bin-paths` and `exec-path`.
* Shim exec is now performed by a new `bin/private/asdf-tool-exec` that might
  be faster for most common use case: (versions on local .tool-versions file)
  but fallbacks to slower `get_preset_version_for` which takes legacy formats
  into account.
* Shim exec recommends which plugins or versions to set when command is
  not found.

Fixed Bugs

* Allow many plugins to provide shims with same executable name (#431)
2019-01-19 13:22:12 -06:00
Trevor Brown
8bcf8caba4 Write test for the exec-path functionality in the which command 2019-01-05 10:54:02 -05:00
Raphx
ec6662d4c0
Continue list even when version is not found
Previous implementation exits abruptly when no version is installed for
a plugin. This prevented the list command from listing the versions for
some other plugins.

This commit allows list command to continue executing even when no
version is installed for some plugins.

Example, plugin a with 1.0, b with none, and c with 2.0.

Previous implementation:

```
$ asdf list

a
  1.0
b
No versions installed
```

After commit changes:

```
$ asdf list

a
  1.0
b
No versions installed
c
  2.0
```
2018-12-28 09:21:43 +08:00
Trevor Brown
54fc0f43dd Add tests for versions set by environment variables
Fixes #327
2018-12-22 15:11:28 -05:00
Trevor Brown
7ca88746a8
Merge pull request #411 from rliebz/update
Fix issues with update command
2018-12-02 14:12:23 -05:00
Robert Liebowitz
321e3b0e46 Exit 1 for failed update 2018-12-01 21:17:27 -05:00
Robert Liebowitz
697772fe8c Fix git dir for update and add error handling 2018-12-01 21:07:44 -05:00
Robert Liebowitz
76c3d426c1 Fix update test setup
Rather than using the project's current `.git` directory, create a new
one. This avoids issues with submodules and potentially other problems.
2018-12-01 21:05:58 -05:00
Daniel Perez
2eae89c432 Fix which for when "system" version is present 2018-11-29 00:31:31 +00:00
Daniel Perez
11882c1151
Merge pull request #382 from fcrespo82/better-which-command
Updated which command.
2018-11-29 00:18:51 +00:00
Trevor Brown
22b709f94e
Merge pull request #403 from burnettk/support-tool-versions-without-newline
support .tool-versions content even if it does not end in a newline
2018-11-20 09:18:41 -05:00
Kevin Burnett
f1b2c59b1d support .tool-versions if it does not end in newline 2018-11-15 21:47:48 -05:00
Fernando Crespo
03394831a8 Merge remote-tracking branch 'upstream/master' into better-which-command 2018-11-12 15:35:19 -02:00
Daniel Perez
18587d4d6f Fix current behavior when multiple versions of a plugin are set 2018-11-10 11:32:02 +00:00
Trevor Brown
359191104b
Merge pull request #389 from mig4/where-default-version-to-current
Make where command default to current version
2018-11-03 10:07:44 -04:00
mig4
a58e9e3c17
Make where command default to current version
Allow not specifying the version on command line in which case fall back
to looking it up.

Also add tests for the `where` command.
2018-10-28 17:47:21 +00:00
mig4
f994b07a2c
Optimise listing all plugins
When checking if a plugin is installed (to display a flag) it is not
necessary to loop through all installed plugins, since we already have
a name we can check directly.

Also expand test case to test this code path too.
2018-10-27 20:05:02 +01:00
Fernando Crespo
46e5f7427f Updated which command.
Should fix #205
2018-10-21 00:47:13 -03:00
Trevor Brown
60e67c4f5b Add primitive tests for plugin_test_command. 2018-10-19 22:44:26 -04:00
Trevor Brown
fc078c5e72 Implement 'asdf local -p'. 2018-10-19 20:41:49 -04:00
Trevor Brown
e8905b42bc Add tests for 'asdf local -p' command. 2018-10-19 20:41:49 -04:00
Trevor Brown
f708e3c15f
Merge pull request #371 from phunehehe/version-set-by
commands/current: add space before parenthesis
2018-10-10 18:21:46 -04:00
Hoang Xuan Phu
1330083229 commands/current: add space before parenthesis
It seems to have been lost in 88d47bbd69.
Probably by accident?

I also pulled the literal bits into the format string. It looks more
readable to me that way. I'm happy to remove that if it's not desired.
2018-10-10 17:28:23 -04:00
Trevor Brown
2bc679084f Add test for the resolve_symlink function. 2018-10-07 21:47:57 -04:00
Trevor Brown
39687b5a94 Add test for not installing system versions. 2018-10-07 14:31:30 -04:00
Trevor Brown
af5393d563 Move current_command test into current_command.bats. 2018-10-07 14:22:31 -04:00
Jose Luis Salas
448d3215d8
Fix asdf current behaviour
Closes: #353
2018-10-04 21:00:29 +02:00
Trevor Brown
266e3cffa5
Merge pull request #360 from teixeiradiego/reshim-fix
Fix reshim to generate shims only for executable files and not directories.
2018-09-19 08:16:33 -04:00
Diego Nogueira Teixeira
20bb61963d Implemented tests for shim generation only for executable files, not directories. 2018-09-19 09:00:11 -03:00
Matt Wean
c468ae7d6a Add another test for the ASDF_DATA_DIR functionality. 2018-09-18 20:21:46 -04:00
Jose Luis Salas
d1782f456e
Retrieve asdf_data_dir from environment variable 2018-09-16 18:39:21 +02:00
Jose Luis Salas
c86707c55f
Add config option to install plugins in $HOME/.asdf 2018-08-11 15:37:56 +02:00
Trevor Brown
c7fb348ffd Add tests for symlink preservation. 2018-06-16 22:48:16 -04:00
Trevor Brown
4a4f453a93 Add readlink to list of banned commands. 2018-06-16 20:19:33 -04:00
Trevor Brown
c1ce9de4d4
Merge pull request #331 from brennanfee/fix-330-asdf-list
Fix for #330 - "asdf list" spacing
2018-06-16 15:30:35 -04:00
Trevor Brown
1b44fa7549 Fix shellcheck warnings. 2018-06-16 15:26:02 -04:00
Brennan Fee
ba1b181b58 Fixing unit tests for 'asdf list'
Now that we put spacing in front of the version #'s the tests need to
reflect that.
2018-06-01 10:15:40 -05:00
Melissa Xie
f79dda865a Include plugin name in error message if plugin doesn't exist
Previously, if we ran a command like `asdf install` and we encountered a
plugin that didn't exist, asdf produces an error saying "No such
plugin". Without knowing which plugin it could be referring too, we'd
have to manually go through each plugin in `.tool-versions` to find the
culprit.

With this commit, we'll now also include the plugin name as part of the
messaging for easier debugging.
2018-04-30 12:49:40 -04:00