-
Notifications
You must be signed in to change notification settings - Fork 448
Check for a .nvmrc or .node-version file to determine the Node.js version #1374
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Mathiyarasy ,
Change looks fine. Left one small comment alone.
"node": { | ||
"version": "project-file" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason why we are adding these test cases such that the container is built from Dockerfile only & not using the image tag directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @Kaniska244
Using Docker File I can include the .nvmrc (or .node-version) file in the image during the build process which is then gets used in feature.
# Determine the Node.js version using the .nvmrc or .node-version file if present. | ||
if [[ "${NODE_VERSION}" == "project-file" ]]; then | ||
echo "Finding Node version from .nvmrc or .node-version file..." | ||
NODE_VERSION_PATH=$(find . -type f -name ".node-version" | head -n 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure find
is the best option. Can we not assume the files need to be in the root directory? What if the project is huge, find
would take a long time. if there are multiple of these files, find
might order them differently based on where it is running, so something like:
for version_file in ".node-version" ".nvmrc"; do
if [[ -f "$version_file" && -s "$version_file" ]]; then
file_version=$(tr -d '[:space:]' < "$version_file")
if [[ -n "$file_version" ]]; then
echo "Using Node version from $version_file: $file_version"
NODE_VERSION="$file_version"
break
else
echo "$version_file exists but contains only whitespace. Continuing search..."
fi
fi
done
might work more predictably
Feature Name
Description of Changes
Changelog