-
Notifications
You must be signed in to change notification settings - Fork 359
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
Provide an install.ps1 PowerShell script to install opam on Windows #5906
Conversation
I have a branch used for kit-ty-kate/opam@windows-installer...windows-installer.debug, which improves the behaviour of the current script on Github Action, however I'm not particularly happy with the code and hasn't been tested outside of Github Action. It would be nice to have the two version merged |
I merged the necessary changes for the script to also work on GitHub Actions as well as some improvements as directed by David in kit-ty-kate/opam@windows-installer...windows-installer-2
EDIT: i merged the two. This is ready to review |
45acb3a
to
d8c5851
Compare
@mtelvers - please could you give this a final look over? (and many thanks for the suggestions and improvements so far!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
shell/install.ps1
Outdated
$PATH = [Environment]::GetEnvironmentVariable('PATH', $loc) | ||
if (-not ($PATH -split ';' -contains $OpamBinDir)) { | ||
[Environment]::SetEnvironmentVariable('PATH', "$OpamBinDir;$PATH", $loc) | ||
if ($loc -eq 'PROCESS') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could dispense with the if ($loc -eq 'PROCESS')
comparison by moving the Write-Host
block to after the foreach
loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, that should be -ne
... the idea was the message is only displayed if the registry is actually updated... although maybe that's over-thinking it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The registry will be updated exactly once by the loop either machine or user.
It can still be after and use $EnvTarget
rather than $loc
in the Write-Host
.
It's a trivial point. Let's not spend more time on it. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not on a subsequent install though - if the user uses the script a second time (registry already updated), then the registry is updated zero times and at that point I was trying to suppress the message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, very good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, working smoothly!
Fixes #5800