fnm icon indicating copy to clipboard operation
fnm copied to clipboard

Add powershell script for installation on windows

Open Yakiyo opened this issue 1 year ago • 6 comments

This adds a powershell script for installing fnm on windows. The ps script tries to follow the bash script as much as possible. Supported flags are:

  • -version | -v for setting version (string)
  • -skipShell | -s for skipping shell setup (bool)
  • -installDir for setting installation dir (string)

Using only one - seems odd to me but thats how powershell parses arguments. As far as i've tested, it even works with only the first argument too, as in -version, -v and -V all do the same thing.

To install fnm via the script, users would do

$ irm url/to/the/script | iex

The bash script uses the install endpoint, the ps script could do ig https://fnm.vercel.app/install.ps or something.

I've tested the script a few times and ensured that it works.

Yakiyo avatar Jul 26 '23 05:07 Yakiyo

⚠️ No Changeset found

Latest commit: 311976c6ddb5627b109b350325fa6d69e6457fea

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 26 '23 05:07 changeset-bot[bot]

First of all, I'd like to thank you for the time and effort and making the hard thing possible and contributing!

However, in my opinion, any installation script is a toll and out of this project scope, and I originally built the installation script to ease the installation process and it only makes sense for Linux nowadays. Since Windows has WinGet baked in as a standard installation mechanism, I don't really see the point in having a custom PowerShell installer. Do you? can you please explain why should we have an installation script and not offload to WinGet?

Schniz avatar Aug 21 '23 06:08 Schniz

ig stuff like scoop and winget does exist which allows people to install fnm. But i dont think everyone uses them. Winget is certainly popular but its yet to be used by everyone, while powershell is always there in windows and a one liner script can just be used to quickly do installations. package managers are great but you wouldnt install one just to get a single app. the script itself wasnt much work, if u wanna use it, sure. if not then its all good. tldr theres no disadvantages but nor too many advantages either. good when u need it done quick, thats all.

Yakiyo avatar Aug 22 '23 14:08 Yakiyo

can you please explain why should we have an installation script and not offload to WinGet?

Hi @Yakiyo, I would like to install fnm under %HOMEPATH%/.fnm and node versions under %HOMEPATH%/.fnm/versions (or something like that). -installDir would allow me to do that, but winget doesn't.

Also, since the bash script install fnm under $HOME/.fnm I don't understand why on Windows in installed under %APPDATA%/fnm. It should be, by default, under %HOMEPATH%/.fnm. The homepath approach is an approach also used by pyenv-win.

Am I missing something?

beegotsy avatar Jan 02 '24 18:01 beegotsy

Also, since the bash script install fnm under $HOME/.fnm I don't understand why on Windows in installed under %APPDATA%/fnm. It should be, by default, under %HOMEPATH%/.fnm. The homepath approach is an approach also used by pyenv-win.

Actually default was changed a while ago and now bash script prefers $XDG_DATA_HOME/fnm (which is roughly an equivalent to %APPDATA%/fnm) for fresh installations. It uses $HOME/.fnm for backward compatibility only if the directory already exists.

See https://github.com/Schniz/fnm/blob/master/.ci/install.sh#L8-L16

alexeyten avatar Jan 02 '24 18:01 alexeyten

Actually default was changed a while ago and now bash script prefers $XDG_DATA_HOME/fnm (which is roughly an equivalent to %APPDATA%/fnm) for fresh installations.

Okay, now it is clear; I based my previous sentence on the README file without opening the actual scripts. Thanks for your reply.

beegotsy avatar Jan 03 '24 08:01 beegotsy