Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Learn how to rename a node after installation #284

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

jasonkarns
Copy link
Member

The rename_node function is part of node-build that way the build
definitions simply need to define their after_install_package function
to invoke rename_node.

The function accepts a specific name as the new name, but defaults the
name to the actual response from node --version.

PREFIX_PATH must be updated after the move such that the rest of
node-build knows about the new location.

After moving the installed node, a symlink is created at the original
location pointing to the new location. This allows end users to set
their selected node using the same name as the build definition.
Further, this "hack" allows any other plugins that hook into
after-install to continue operating unchanged. Without the symlink,
PREFIX and NODENV_VERSION would be incorrect for all after-install
hooks. However, as they now refer to an existing directory (symlink),
the hooks will operate on the newly installed node correctly.

Fixes #237
Unblocks #145

todo

  • handle the "new name" already existing

The rename_node function is part of node-build that way the build
definitions simply need to define their after_install_package function
to invoke rename_node.

The function accepts a specific name as the new name, but defaults the
name to the actual response from `node --version`.

PREFIX_PATH must be updated after the move such that the rest of
node-build knows about the new location.

After moving the installed node, a symlink is created at the original
location pointing to the new location. This allows end users to set
their selected node using the same name as the build definition.
Further, this "hack" allows any other plugins that hook into
after-install to continue operating unchanged. Without the symlink,
`PREFIX` and `NODENV_VERSION` would be incorrect for all after-install
hooks. However, as they now refer to an existing directory (symlink),
the hooks will operate on the newly installed node correctly.

TODO: handle the "new name" already existing
@jasonkarns
Copy link
Member Author

Now checking (and exiting) if the new_path already exists. Currently checking via -d.

Questions:

  • Should we export the FORCE and SKIP_EXISTING flags from the nodenv-install plugin? that way it can silently proceed?
  • Should it fail if either the fullname or label exist? Or just if the fullname exists?
  • Should it prompt to continue? Or proceed silently as node-build does?
  • Should we change the install plugin to check for more than -d when prompting to overwrite? Since a broken symlink does not report as true in this case. And it will become more common as these dynamic defs are used more. Should check for -d || -L.
  • Should we have nodenv-uninstall also handle cleanup of these symlinks? Or rely on nodenv-aliases to do that? Should it just run --auto after uninstallation? Or expose secondary command to just cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support prefix moving
1 participant