Skip to content

Commit b5f4bc5

Browse files
BlankParticleTheAlexLichterfengmk2
authored
feat: add support for .nvmrc as node version source (#2244)
fixes #2207 adds `.nvmrc` as a supported source for node version resolution, behaviour is as discussed in the issue implemented after discussion with @TheAlexLichter on voidzero discord (#2207 (comment)) thanks to @devmcclu who did a parallel implementation in #2213, i took some tests from that PR --------- Co-authored-by: Alexander Lichter <github@lichter.io> Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
1 parent dba8ba9 commit b5f4bc5

21 files changed

Lines changed: 417 additions & 96 deletions

File tree

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/cli_helper_message/snapshots/cli_helper_message.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Examples:
467467
468468
Manage:
469469
vp env pin lts # Pin to latest LTS version
470-
vp env install # Install version from .node-version / package.json
470+
vp env install # Install version from .node-version / package.json / .nvmrc
471471
vp env use 20 # Use Node.js 20 for this shell session
472472
vp env use --unset # Remove session override
473473
vp env clean # Remove unused managed caches
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "command-env-install-nvmrc"
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[[case]]
2+
name = "command_env_install_nvmrc"
3+
vp = "global"
4+
skip-platforms = ["windows"]
5+
seed-runtime = false
6+
steps = [
7+
{ argv = ["vp", "env", "install"], comment = "Install version from .nvmrc (22.x)", continue-on-failure = true },
8+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# command_env_install_nvmrc
2+
3+
## `vp env install`
4+
5+
Install version from .nvmrc (22.x)
6+
7+
```
8+
VITE+ - The Unified Toolchain for the Web
9+
10+
Installing Node.js <version>...
11+
Installed Node.js <version>
12+
```

crates/vite_cli_snapshots/tests/cli_snapshots/fixtures/command_env_use/snapshots/command_env_use.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Usage: vp env use [OPTIONS] [VERSION]
1212
Use a specific Node.js version for this shell session
1313
1414
Arguments:
15-
[VERSION] Version to use (e.g., "20", "20.18.0", "lts", "latest"). If omitted, reads from .node-version or package.json
15+
[VERSION] Version to use (e.g., "20", "20.18.0", "lts", "latest"). If omitted, reads from .node-version, package.json, or .nvmrc
1616
1717
Options:
1818
--unset Remove session override (revert to file-based resolution)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20.18.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[case]]
2+
name = "command_env_which_nvmrc"
3+
vp = "global"
4+
local-registry = true
5+
skip-platforms = ["windows"]
6+
steps = [
7+
{ argv = ["vp", "env", "exec", "node", "--version"], comment = "Ensure Node.js is installed first", continue-on-failure = true },
8+
{ argv = ["vp", "env", "which", "node"], comment = "Core tool - shows resolved Node.js binary path from .nvmrc", continue-on-failure = true },
9+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# command_env_which_nvmrc
2+
3+
## `vp env exec node --version`
4+
5+
Ensure Node.js is installed first
6+
7+
```
8+
<version>
9+
```
10+
11+
## `vp env which node`
12+
13+
Core tool - shows resolved Node.js binary path from .nvmrc
14+
15+
```
16+
VITE+ - The Unified Toolchain for the Web
17+
18+
<home>/.vite-plus/js_runtime/node/<version>/bin/node
19+
Version: 20.18.0
20+
Source: <workspace>/.nvmrc
21+
```

0 commit comments

Comments
 (0)