Commit Graph

186 Commits

Author SHA1 Message Date
Jochen Schalanda
3c3f0e67f6
Rename custom plugin-add/plugin-remove for plugins (#684)
Rename custom scripts for `plugin-add` and `plugin-remove` phases in plugins to make clear when they are executed:

`plugin-add` -> `post-plugin-add`
`plugin-remove` -> `pre-plugin-remove`
2020-03-22 12:57:54 +11:00
Jochen Schalanda
95d4c07294
Set Git user and email in tests 2020-03-21 15:12:01 +01:00
Jochen Schalanda
57186be6d9
Support customizing plugin-add and plugin-remove
* Add support for custom `plugin-add` and `plugin-remove` in plugins
* Add configurable command hooks for plugin installation and removal

```shell
pre_asdf_plugin_remove = echo will remove plugin ${1}
pre_asdf_plugin_remove_foo = echo will remove plugin foo
post_asdf_plugin_remove = echo removed plugin ${1}
post_asdf_plugin_remove_foo = echo removed plugin foo
```

Closes #670
2020-03-21 14:59:33 +01:00
Victor Hugo Borja
a26bed6586 Make sure extension commands are properly displayed by asdf help 2020-03-15 11:45:09 -06:00
Jochen Schalanda
609e41e276 Use different exit code if updates are disabled
If asdf-vm was installed with a package manager and the user doesn't
have the necessary permissions to update it with `asdf update`, asdf-vm
emits an informational message and exits with exit code 1.

This makes it hard to programmatically detect whether the update failed
or wasn't even attempted because it's not possible.

With this change, asdf-vm would exit with the exit code 42 if updates are
disabled instead of exit code 1, which signals an error during update.

Refs r-darwish/topgrade#367
2020-03-13 10:14:28 +01:00
Trevor Brown
8b90d883ee Require .bash extension for plugin extension commands 2020-03-02 13:13:20 -05:00
Trevor Brown
52cbf1165c Add .bash file extensions to files containing code executed by Bash 2020-03-02 12:48:05 -05:00
Victor Borja
62c4fdb163
Merge pull request #623 from jonmast/prevent-exec-recursion
Ignore shim directory for executable lookups
2020-02-14 14:26:03 -06:00
Trevor Brown
42182f31c4 Add test for shim exec of path versions 2020-02-07 22:32:04 -05:00
Trevor Brown
e4a9ad6e58
Merge pull request #649 from asdf-vm/tb/misc-test-improvements
Misc. Test Improvements
2020-02-05 07:51:42 -05:00
Trevor Brown
6d8d77f51d Unset ASDF_DIR variable before running tests 2020-02-04 11:23:09 -05:00
Trevor Brown
f787b719ac
Merge pull request #640 from asdf-vm/improve-export-shell
Fix asdf shell xx --unset for fish
2020-02-04 08:17:54 -05:00
Trevor Brown
79ffc55f82 Add another test for asdf_data_dir function 2020-01-31 14:03:33 -05:00
Trevor Brown
84ab5b7753 Fix hanging 'asdf update is a noop for non-git repos' test 2020-01-29 09:58:59 -05:00
Daniel Perez
e53de6726f Fix asdf shell xx --unset for fish 2020-01-25 20:42:43 +00:00
Timo Sand
09db5d6bfc
Switches to actually use latest instead of first 2019-12-30 23:25:56 +02:00
Timo Sand
340b027b5f
Removes echo overcomplication 2019-12-30 21:03:38 +02:00
Jonathan Mast
069c74f45e
Ignore shim directory for executable lookups
Previously, the shims directory was only excluded for system versions,
which meant that `asdf exec` would fall back to a shim if the install
didn't have the desired binary. If the shims are up to date this isn't a
problem since we check the metadata, but it causes issues if those are
out of sync for whatever reason.

I've checked all the uses of this function and I'm not seeing anywhere
we should need the old behavior.
2019-12-21 15:24:55 -05:00
Jonathan Mast
67e0e50445
Run config tests in BATS_TMPDIR for clean environment
This avoids issues with it picking up config files from parent
directories.
2019-12-21 14:22:32 -05:00
Luke Bonaccorsi
c728018627 Fix issue with preset version warning assuming that the shim name and plugin name are the same 2019-12-20 17:26:00 +00:00
Victor Borja
ff57001691
Merge pull request #609 from tejanium/clearer-warning
Clarify instructions when <version> of a <shim_name> is missing.
2019-12-13 12:02:16 -06:00
Teja Sophista
026aa78f35 Output different warning for empty and missing version
1. when `.tool-versions` is not set
2. when `.tool-versions` set version that is not installed
2019-12-04 14:18:58 +00:00
Victor Hugo Borja
5ab01f49df Allow eval only on asdf function at lib/asdf.sh.
It's needed for `asdf shell` command.
2019-12-03 11:04:04 -06:00
Victor Hugo Borja
3d3595c7a3 Improvements to asdf plugin commands. 2019-11-30 14:18:37 -06:00
Victor Hugo Borja
b8dc5f1604 Run shfmt on bash files 2019-11-29 10:15:38 -06:00
Victor Hugo Borja
83dc1712e3 Change to test HOME on test setup 2019-11-27 12:25:34 -06:00
Victor Hugo Borja
e968fe6142 Subcommand-aware command line interface. 2019-11-27 12:17:17 -06:00
Victor Hugo Borja
70099027c2 Move plugin extension command into it's own file.
Add a test for calling default command with arguments.
2019-11-25 12:07:55 -06:00
Victor Hugo Borja
a22733f819 Resolve asdf PLUGIN_NAME default command.
When calling `asdf foo` and the `foo` plugin provides a `bin/default-command`
2019-11-25 02:47:55 -06:00
Victor Hugo Borja
0e8e1f8f84 New feature: asdf extension commands
It's possible for plugins to define new asdf commands. This way plugins can extend asdf capabilities or expose utilities related to their managed tool.

For example, a `foo` plugin might expose the command `asdf foo bar` by providing an executable file at `bin/bar`.
If `bin/bar` is a file but has no executable bit set, then its considered a source-able bash script, and will be sourced
with all the functions in `$ASDF_DIR/lib/utils.sh` already loaded.

A good example of this feature is the `nodejs` plugin, where people must import the release team keyring before
installing a nodejs version. People can execute the following command without having to know where exactly is the plugin located.
2019-11-25 02:24:46 -06:00
Kevin Lane
c11409583f
Add unit tests for managing latest stable versions 2019-11-22 10:37:53 -08:00
Trevor Brown
72e876b0ae Handle dashes in executable names properly 2019-10-24 12:05:44 -04:00
Trevor Brown
edb5839239 Rename find_version to find_versions since it can return multiple versions 2019-10-22 19:03:05 -04:00
Trevor Brown
cea9b9574f Install multiple versions when multiple versions are present in a .tool-versions file 2019-10-22 18:58:30 -04:00
OZAWA Sakuro
bc309c0fe5 Remove quotes from --unset option 2019-09-02 11:55:42 +09:00
OZAWA Sakuro
503263a68d Add --unset option to shell command 2019-08-17 22:46:00 +09:00
Trevor Brown
549d86e733 Add tests for duplicate colon path issue 2019-08-14 19:31:23 -04:00
Trevor Brown
3516c08c6b Fix failing test 2019-06-17 20:38:17 -04:00
Leonid Shevtsov
d506aa183a tests for install command:
- remove test for install command edge case from parsing tool-versions (no longer relevant)
- add test for install command honoring legacy version files
- clean up test names to differentiate between installing a single version vs all dependencies
2019-06-01 07:48:17 +03:00
Daniel Perez
100776de93
Merge pull request #524 from paulswartz/517-prefix-versions
fix: check shims for the full version
2019-05-18 01:25:46 +01:00
Paul Swartz
4e9d04ccaa fix: also fix bug with cleaning up old versions
It had a similiar issue with removing plugins based on the prefix and not the
full version string.
2019-05-17 14:34:44 -04:00
Paul Swartz
e5863f3701 fix: check shims for the full version
The current behavior in shims is to check if there's an existing shim for
which the shim we're currently checking is a prefix. For example, if the shim
has

    # asdf-plugin: erlang 21.2.6

Then adding a shim for `erlang 21.2` will fail.

This updates the `grep` check to match the end of the line as well so we
always get a full version check.

Fixes #517
2019-05-17 14:30:05 -04:00
Daniel Perez
7876fcdd90 Fix fish test 2019-04-07 22:33:26 +01:00
Trevor Brown
ff553324a7 Add tests for code in asdf.fish 2019-04-07 15:01:19 -04:00
Trevor Brown
62015a750d Add test for not adding duplicate paths to PATH 2019-04-06 13:23:30 -04:00
Trevor Brown
13b3d14cac Add tests for code in asdf.sh 2019-04-06 12:43:39 -04:00
Daniel Perez
b8ee616318 Fix current when .tool-versions contains comments 2019-03-31 20:39:36 +01:00
Daniel Perez
f2674374b0
Merge pull request #502 from asdf-vm/use-exec
Revert to using exec when running a shim
2019-03-31 20:15:46 +01:00
Trevor Brown
28cf1a74b9 Create function for removing comments from .tool-versions files 2019-03-27 08:50:15 -04:00
Trevor Brown
1a4a9435f3 Make install command ignore comments 2019-03-27 08:50:15 -04:00