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

Determine fnm's default version programmatically #1196

Open
isaacl opened this issue Jul 21, 2024 · 8 comments · May be fixed by #1268
Open

Determine fnm's default version programmatically #1196

isaacl opened this issue Jul 21, 2024 · 8 comments · May be fixed by #1268

Comments

@isaacl
Copy link

isaacl commented Jul 21, 2024

I use fnm default <version>. I then regularly run a script to check if my default version is out of date. However, I can't find a programmatic way to determine what fmn default is set to. I'm using fnm current, but this doesn't always work, if I'm in shell or location that has an overridden version.

Expected behavior

  • fnm default (without further arguments) should return fnm's current default version.
  • Or alternatively, there should be documented file I can cat to see fnm's default version.

Actual behavior

fnm default prints help, no file is documented.

@MunifTanjim
Copy link

fnm list | grep default

@Schniz
Copy link
Owner

Schniz commented Oct 6, 2024

what do you think about using exec? This way you know the actual version by invoking Node.js itself.

✡ fnm exec --using=default node -v
v20.16.0

@isaacl
Copy link
Author

isaacl commented Oct 6, 2024

Either of these meet my needs, but I still think it should be baked into a fnm command. Similar tools, like pyenv or rbenv offer this functionality directly.

@Schniz
Copy link
Owner

Schniz commented Oct 6, 2024

So fnm default is what you expect it to be? sgtm. Wanna contribute that?

@MunifTanjim
Copy link

If default is just an alias, a more generic command would be to print the target version for an alias.

Something like fnm alias <alias> ?

isaacl added a commit to isaacl/fnm that referenced this issue Oct 6, 2024
@isaacl isaacl linked a pull request Oct 6, 2024 that will close this issue
@isaacl
Copy link
Author

isaacl commented Oct 6, 2024

@Schniz OK

@isaacl
Copy link
Author

isaacl commented Oct 6, 2024

@MunifTanjim fnm has a dedicated default function that doesn't require knowing default is just an alias. So I think the command to retrieve the default version should not require invoking the alias command. But if you look at my PR, it would be pretty simple to use it to implement your proposal for fnm alias too, if you desired that.

isaacl added a commit to isaacl/fnm that referenced this issue Oct 6, 2024
@isaacl
Copy link
Author

isaacl commented Nov 7, 2024

@Schniz you asked me to write a patch, I did so, and it's been sitting for a month.

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 a pull request may close this issue.

3 participants