Add metadata to shims

When a shim is created, add plugin metadata so we can later know which shims belong to which plugins, this will help aid with removing unused shims on uninstall. See #67

```
# asdf-plugin: ${plugin_name}”
```

Thanks to @duijf for the metadata proposal.
This commit is contained in:
Victor Borja 2016-12-10 12:17:50 -06:00 committed by Stratus3D
parent e4501c7d6a
commit 2826f66849
3 changed files with 19 additions and 2 deletions

View File

@ -48,9 +48,11 @@ write_shim_script() {
if [ -f $plugin_shims_path/$executable_name ]; then
cp $plugin_shims_path/$executable_name $shim_path
else
echo """#!/usr/bin/env bash
cat <<EOF > $shim_path
#!/usr/bin/env bash
# asdf-plugin: ${plugin_name}
exec $(asdf_dir)/bin/private/asdf-exec ${plugin_name} ${executable_path} \"\$@\"
""" > $shim_path
EOF
fi
chmod +x $shim_path

View File

@ -3,3 +3,10 @@
mkdir -p $ASDF_INSTALL_PATH
env > $ASDF_INSTALL_PATH/env
echo $ASDF_INSTALL_VERSION > $ASDF_INSTALL_PATH/version
# create the dummy executable
mkdir -p $ASDF_INSTALL_PATH/bin
cat <<EOF > $ASDF_INSTALL_PATH/bin/dummy
exec echo dummy
EOF
chmod 755 $ASDF_INSTALL_PATH/bin/dummy

View File

@ -42,3 +42,11 @@ teardown() {
[ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.2/version) = "1.2" ]
}
@test "install_command should create a shim with metadada" {
run install_command dummy 1.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.0/env ]
run grep "# asdf-plugin: dummy" $ASDF_DIR/shims/dummy
[ "$status" -eq 0 ]
}