feat: default node version to .nvmrc when available, fixes #6071 #6108
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Issue
Projects with a
.nvmrc
need to duplicate the node version into DDEV config as well.When collaborating with developers who aren't using DDEV, there is a risk of the
.nvmrc
value being updated without updating the reference in.ddev/config.yaml
for that project.There are other scenarios as well where this desync could be problematic.
How This PR Solves The Issue
If a
.nvmrc
exists in the project root and nonodejs_version
is defined in the project's.ddev/config.yaml
file, the.nvmrc
file is used to define the default node js version.If that file doesn't exist, the existing hardcoded DDEV default value is used.
Manual Testing Instructions
Run
ddev status
in a project with/without a.nvmrc
file and see the nodejs version update.Validate that adding
nodejs_version
in config.yaml still overrides any default values.Automated Testing Overview
I'm not sure how to test this. Options include:
getNodeJSDefault
a public function so it can be called directly by testsRelated Issue Link(s)
nodejs_version
to use external file as reference for node version #6071Release/Deployment Notes
Projects which have a
.nvmrc
file in the project root and which have not explicitly defined the nodejs version for that project withnodejs_version
will swap to using the version defined in.nvmrc
instead of the hardcoded DDEV default value.