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

Add variable for the expected Node.js version #5066

Closed
axiac opened this issue Apr 5, 2023 · 2 comments · Fixed by #5081
Closed

Add variable for the expected Node.js version #5066

axiac opened this issue Apr 5, 2023 · 2 comments · Fixed by #5081
Labels
✨ enhancement A new feature implementation.

Comments

@axiac
Copy link

axiac commented Apr 5, 2023

Feature Request

For Node.js, Starship provides the variable version and the options style and not_capable_style. version is the version of the installed Node.js and it is displayed using the format specified in style when it matches the version specified in package.json (property $.engines.node) or using the format specified in not_capable_style when it does not match.

This is helpful in itself but it could be more helpful than than. When the version of the interpreter does not match the project requirements, the first execution of any yarn command in the directory tells not only that the current version of Node.js is not appropriate for the project but it also tells what version is expected.

Starship could bring the same information without even running yarn.
It already knows what is written in package.json and has the information in memory. This is how it detects if the current version of Node.js is good or not and decides to render it using style or not_capable_style. All it needs is to provide a variable similar to version that contains the Node.js version required by the project (the value of property $.engines.node from package.json).

Please add a new variable (it could be named expected_version) that contains the value of property $.engines.node from package.json).


A similar solution can be implemented for other languages that declare the version of the interpreter that they need to run (PHP, Python, Ruby etc.)

@axiac axiac added the ✨ enhancement A new feature implementation. label Apr 5, 2023
@axiac
Copy link
Author

axiac commented Apr 6, 2023

It would be useful to show only version if the Node.js version matches the version expected by the project and to show both version and expected_version if the version of the interpreter does not match the requirements of the project.

Is this possible?

@marcybelardo
Copy link
Contributor

Sounded straightforward so I tried this~ Currently have a working implementation, shows expected version if engines.node and current node version don't match, and if the variable is included in the module format. Not including the $expected_version variable in format doesn't change the normal rendering.

Was thinking about adding an option to allow people to enable/disable it but if you don't put the variable in format then it won't show regardless? Just have to clean some stuff up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement A new feature implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants