-
Notifications
You must be signed in to change notification settings - Fork 457
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
Open
Mathiyarasy
wants to merge
11
commits into
devcontainers:main
Choose a base branch
from
Mathiyarasy:dev/Mathi/NodePOC
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f32eb2c
Based on nvmrc file
Mathiyarasy f81c735
nodeversion path
Mathiyarasy 0af147a
update test cases
Mathiyarasy b53b4f5
Change default to false
Mathiyarasy 95fa5bc
introduce none condition check
Mathiyarasy 97d81bd
remove flag and an new option in version
Mathiyarasy c103184
Remove hardcoded node lts version from test scripts
Mathiyarasy 7a45e54
update version
Mathiyarasy 9fc7ae9
Merge branch 'main' into dev/Mathi/NodePOC
Mathiyarasy a46abe2
Merge branch 'main' into dev/Mathi/NodePOC
Mathiyarasy c7c3f4c
remove find
Mathiyarasy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
cd test_node_project_nodev | ||
|
||
# Check that .nvmrc exists | ||
if [ ! -f .node-version ]; then | ||
echo ".node-version file not found!" | ||
exit 1 | ||
fi | ||
|
||
# Read the version from .nvmrc and compare with current node version | ||
N_VERSION=$(cat .node-version | tr -d 'v') | ||
NODE_VERSION=$(node -v | tr -d 'v') | ||
|
||
if [ "$N_VERSION" != "$NODE_VERSION" ]; then | ||
echo "Node version mismatch: .node-version specifies $N_VERSION, but current node is $NODE_VERSION" | ||
exit 1 | ||
fi | ||
|
||
echo ".node-version is used and matches the current Node.js version." | ||
# Report result | ||
reportResults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20.19.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM debian:11 | ||
|
||
COPY .node-version /tmp/dev-container-features/node_0/.node-version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
cd test_node_project_nvm_nodev | ||
|
||
# Check that .node-version exists | ||
if [ ! -f .node-version ]; then | ||
echo ".node-version file not found!" | ||
exit 1 | ||
fi | ||
|
||
# Read the version from .node-version and compare with current node version | ||
N_VERSION=$(cat .node-version | tr -d 'v') | ||
NODE_VERSION=$(node -v | tr -d 'v') | ||
|
||
if [ "$N_VERSION" != "$NODE_VERSION" ]; then | ||
echo "Node version mismatch: .nvmrc specifies $N_VERSION, but current node is $NODE_VERSION" | ||
exit 1 | ||
fi | ||
|
||
echo ".node-version is used and matches the current Node.js version." | ||
# Report result | ||
reportResults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20.19.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
22.9.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM debian:11 | ||
|
||
COPY .nvmrc .node-version /tmp/dev-container-features/node_0/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
cd test_node_project_nvmrc | ||
|
||
# Check that .nvmrc exists | ||
if [ ! -f .nvmrc ]; then | ||
echo ".nvmrc file not found!" | ||
exit 1 | ||
fi | ||
|
||
# Read the version from .nvmrc and compare with current node version | ||
NVMRC_VERSION=$(cat .nvmrc | tr -d 'v') | ||
NODE_VERSION=$(node -v | tr -d 'v') | ||
|
||
if [ "$NVMRC_VERSION" != "$NODE_VERSION" ]; then | ||
echo "Node version mismatch: .nvmrc specifies $NVMRC_VERSION, but current node is $NODE_VERSION" | ||
exit 1 | ||
fi | ||
|
||
echo ".nvmrc is used and matches the current Node.js version." | ||
# Report result | ||
reportResults |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
22.9.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM debian:11 | ||
|
||
COPY .nvmrc /tmp/dev-container-features/node_0/.nvmrc |
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.
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.