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

Non-interactive fnm use -- avoid prompting to install version #1333

Open
philipmat opened this issue Nov 22, 2024 · 1 comment
Open

Non-interactive fnm use -- avoid prompting to install version #1333

philipmat opened this issue Nov 22, 2024 · 1 comment

Comments

@philipmat
Copy link

philipmat commented Nov 22, 2024

Problem: fnm use prompts to install version.

❯ fnm use 22
Can't find an installed Node version matching v22.x.x.
Do you want to install it? answer [y/N]: ^C

Would prefer: a way to disable this prompt, effectively the opposite of --install-if-missing and for fnm to return a non-zero exit code if it didn't use nor installed the specified version.

Scenario: I'm writing a CI script that wants to make use of specific versions, in an order of preferences, but not install any.
For example: fnm use 22 || fnm use 20 || fnm use 18 --install-if-missing

If it was just one, I could use echo "n" || fnm use 22, but it requires a lot more scripting to make the chain work due to fnm returning a 0 exit code.

@Schniz
Copy link
Owner

Schniz commented Nov 22, 2024

I remember making “install if missing” by checking if stdout is tty. That should cover your case. I wonder why it isnt. Maybe because of the last piped command in your example which is actually interactive (it pipes to stdout/stderr which are interactive)

What a test case would be?

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

No branches or pull requests

2 participants