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

[install script] Refactors NVM_DIR #566

Merged
merged 1 commit into from
Jun 29, 2016
Merged

Conversation

xcambar
Copy link
Contributor

@xcambar xcambar commented Oct 31, 2014

After the PR:

  • Uses a function to define the install dir (aka NVM_DIR)
  • Does not replace an empty yet defined NVM_DIR variable, but uses a default value instead
  • NVM_DIR is used at a single point in the install script

@xcambar xcambar changed the title [install script] testing NVM_DIR [install script] Refactors NVM_DIR Oct 31, 2014
@@ -27,40 +27,44 @@ nvm_download() {
}

install_nvm_from_git() {
local install_dir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's name this NVM_INSTALL_DIR - in ksh the local doesn't work, so the var will remain afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better then that we unset it at the end of the function?

I've struggled to decide whether (not-environment) variables should be uppercased (as per the rest of the script) or lowercased (as per the accepted scripting conventions).

ksh is an edge case here. It should not be neglected, but maybe nvm could stick to the shell scripting conventions by usig lowercase for local variables and yet explicitely unset them for ksh.

It's mostly aesthetics, but it could help regular script writers to "feel home" quickly, and will leave ksh users with a cleaner environment, which could avoid bad side-effects at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an idea as well, but not only is that a lot of extra cleanup, but that doesn't work if there's an existing variable set. If someone has install_dir set as an env var, even lowercase, we shouldn't overwrite it - and if we do, as in ksh, we may want to leave a value behind so that it can be used to trace where it's happening, instead of just clearing it.

@ljharb ljharb self-assigned this Nov 1, 2014
@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Nov 2, 2014
@ljharb
Copy link
Member

ljharb commented Dec 21, 2014

@xcambar Are you still interested in landing this PR?

@xcambar
Copy link
Contributor Author

xcambar commented Dec 24, 2014

@ljharb I'm still interested. I'll update the PR during the holidays.

@xcambar xcambar force-pushed the nvm_install_dir branch 2 times, most recently from 5266383 to 620b8a7 Compare January 12, 2015 19:40
@xcambar
Copy link
Contributor Author

xcambar commented Jan 12, 2015

Better late than never, the PR has been updated according to your comments and recent updates.

Yours to review.

printf "\r=> "
cd "$NVM_DIR" && (command git fetch 2> /dev/null || {
echo >&2 "Failed to update nvm, run 'git fetch' in $NVM_DIR yourself." && exit 1
cd "$install_dir" && (git fetch 2> /dev/null || {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently added command to ensure that git isn't aliased - can you ensure that all git commands are prefixed with command?

@ljharb
Copy link
Member

ljharb commented Jun 26, 2016

@xcambar do you have any interest in completing this PR?

@xcambar
Copy link
Contributor Author

xcambar commented Jun 27, 2016

I can give it a try and rebase.

@xcambar
Copy link
Contributor Author

xcambar commented Jun 27, 2016

Rebased and well :)

if [ -d "$NVM_DIR/.git" ]; then
echo "=> nvm is already installed in $NVM_DIR, trying to update using git"
local INSTALL_DIR
INSTALL_DIR=$(nvm_install_dir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be surrounded in quotes, in case it has spaces in it

@ljharb
Copy link
Member

ljharb commented Jun 28, 2016

LGTM pending one comment :-)

@xcambar
Copy link
Contributor Author

xcambar commented Jun 28, 2016

Done. I also cleaned up the function in nvm_reset, FYI.

Although I'm sure it's on purpose (ie, harmless), I'd like to bring to your attention that there are some non-quoted variables left in the script. If you want to see it fixed, I can open another PR for this, it won' take long.

@ljharb ljharb added installing node Issues with installing node/io.js versions. needs rebase Please rebase your branch onto latest master! This removes merge commits, & keeps the git log clean. and removed needs followup We need some info or action from whoever filed this issue/PR. labels Jun 28, 2016
@ljharb
Copy link
Member

ljharb commented Jun 28, 2016

Thanks, this looks great! Let's get the open install script PRs merged first, then we can fix the vars in another one.

Let's rebase this down to one commit and get it in :-)

@ljharb ljharb removed the needs rebase Please rebase your branch onto latest master! This removes merge commits, & keeps the git log clean. label Jun 29, 2016
@ljharb ljharb merged commit 39c119c into nvm-sh:master Jun 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing node Issues with installing node/io.js versions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants