Skip to content

Commit 866ae22

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents 7fd16cd + bfb1860 commit 866ae22

24 files changed

Lines changed: 963 additions & 627 deletions

.changeset/brave-timers-move.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fnm": patch
3+
---
4+
5+
support `x64-glibc-217` arch by adding a `--arch x64-glibc-217` to fnm env

.changeset/cuddly-cars-ring.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fnm": patch
3+
---
4+
5+
prefer explicit shell flags in installer-generated shell setup and fix ARM installer CI platform selection

.changeset/fair-carrots-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fnm": patch
3+
---
4+
5+
Clarify the interactive `fnm use` missing-version prompt by prefixing the message with `fnm` so it is obvious which tool is asking to install Node.

.ci/install.sh

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -e
44

55
RELEASE="latest"
66
OS="$(uname -s)"
7-
USE_HOMEBREW=""
8-
FORCE_INSTALL=""
9-
SHOULD_EXIT=""
10-
SKIP_SHELL=""
117

128
case "${OS}" in
139
MINGW* | Win*) OS="Windows" ;;
@@ -25,7 +21,7 @@ fi
2521

2622
# Parse Flags
2723
parse_args() {
28-
while [ "$#" -gt 0 ]; do
24+
while [[ $# -gt 0 ]]; do
2925
key="$1"
3026

3127
case $key in
@@ -88,40 +84,6 @@ set_filename() {
8884
fi
8985
}
9086

91-
# Portable temp dir creator (uses mktemp if available, with a fallback)
92-
mktempdir() {
93-
# Prefer mktemp if available; try common variants
94-
if command -v mktemp >/dev/null 2>&1; then
95-
if tmp=$(mktemp -d "${TMPDIR:-/tmp}/fnm.XXXXXXXX" 2>/dev/null); then
96-
printf '%s\n' "$tmp"
97-
return 0
98-
fi
99-
if tmp=$(TMPDIR="${TMPDIR:-/tmp}" mktemp -d -t fnm 2>/dev/null); then
100-
printf '%s\n' "$tmp"
101-
return 0
102-
fi
103-
if tmp=$(mktemp -d 2>/dev/null); then
104-
printf '%s\n' "$tmp"
105-
return 0
106-
fi
107-
fi
108-
109-
# Fallback: predictable, but private-perms directory creation loop
110-
base="${TMPDIR:-/tmp}/fnm.$$"
111-
i=0
112-
while [ "$i" -lt 1000 ]; do
113-
dir="${base}.${i}"
114-
if (umask 077; mkdir "$dir" 2>/dev/null); then
115-
printf '%s\n' "$dir"
116-
return 0
117-
fi
118-
i=$((i + 1))
119-
done
120-
121-
printf '%s\n' "mktempdir: could not create a temp directory under ${TMPDIR:-/tmp}" >&2
122-
return 1
123-
}
124-
12587
download_fnm() {
12688
if [ "$USE_HOMEBREW" = "true" ]; then
12789
brew install fnm
@@ -133,15 +95,12 @@ download_fnm() {
13395
URL="https://github.com/Schniz/fnm/releases/download/$RELEASE/$FILENAME.zip"
13496
fi
13597

136-
DOWNLOAD_DIR=$(mktempdir) || { echo "Unable to create a temporary directory under ${TMPDIR:-/tmp}."; exit 1; }
137-
trap "rm -rf '$DOWNLOAD_DIR'" EXIT INT HUP TERM
138-
139-
echo "Installing fnm to $INSTALL_DIR"
140-
141-
mkdir -p "$INSTALL_DIR" >/dev/null 2>&1
98+
DOWNLOAD_DIR=$(mktemp -d)
14299

143100
echo "Downloading $URL..."
144101

102+
mkdir -p "$INSTALL_DIR" &>/dev/null
103+
145104
if ! curl --progress-bar --fail -L "$URL" -o "$DOWNLOAD_DIR/$FILENAME.zip"; then
146105
echo "Download failed. Check that the release/filename are correct."
147106
exit 1
@@ -162,25 +121,25 @@ download_fnm() {
162121
check_dependencies() {
163122
echo "Checking dependencies for the installation script..."
164123

165-
printf "Checking availability of curl... "
166-
if command -v curl >/dev/null 2>&1; then
124+
echo -n "Checking availability of curl... "
125+
if hash curl 2>/dev/null; then
167126
echo "OK!"
168127
else
169128
echo "Missing!"
170129
SHOULD_EXIT="true"
171130
fi
172131

173-
printf "Checking availability of unzip... "
174-
if command -v unzip >/dev/null 2>&1; then
132+
echo -n "Checking availability of unzip... "
133+
if hash unzip 2>/dev/null; then
175134
echo "OK!"
176135
else
177136
echo "Missing!"
178137
SHOULD_EXIT="true"
179138
fi
180139

181140
if [ "$USE_HOMEBREW" = "true" ]; then
182-
printf "Checking availability of Homebrew (brew)... "
183-
if command -v brew >/dev/null 2>&1; then
141+
echo -n "Checking availability of Homebrew (brew)... "
142+
if hash brew 2>/dev/null; then
184143
echo "OK!"
185144
else
186145
echo "Missing!"
@@ -195,10 +154,11 @@ check_dependencies() {
195154
}
196155

197156
ensure_containing_dir_exists() {
198-
containing_dir="$(dirname "$1")"
199-
if [ ! -d "$containing_dir" ]; then
200-
echo " >> Creating directory $containing_dir"
201-
mkdir -p "$containing_dir"
157+
local CONTAINING_DIR
158+
CONTAINING_DIR="$(dirname "$1")"
159+
if [ ! -d "$CONTAINING_DIR" ]; then
160+
echo " >> Creating directory $CONTAINING_DIR"
161+
mkdir -p "$CONTAINING_DIR"
202162
fi
203163
}
204164

@@ -217,7 +177,7 @@ setup_shell() {
217177
if [ "$USE_HOMEBREW" != "true" ]; then
218178
echo ' export PATH="$FNM_PATH:$PATH"'
219179
fi
220-
echo ' eval "$(fnm env)"'
180+
echo ' eval "$(fnm env --shell zsh)"'
221181
echo 'fi'
222182
} | tee -a "$CONF_FILE"
223183

@@ -233,7 +193,7 @@ setup_shell() {
233193
if [ "$USE_HOMEBREW" != "true" ]; then
234194
echo ' set PATH "$FNM_PATH" $PATH'
235195
fi
236-
echo ' fnm env | source'
196+
echo ' fnm env --shell fish | source'
237197
echo 'end'
238198
} | tee -a "$CONF_FILE"
239199

@@ -253,7 +213,7 @@ setup_shell() {
253213
if [ "$USE_HOMEBREW" != "true" ]; then
254214
echo ' export PATH="$FNM_PATH:$PATH"'
255215
fi
256-
echo ' eval "$(fnm env)"'
216+
echo ' eval "$(fnm env --shell bash)"'
257217
echo 'fi'
258218
} | tee -a "$CONF_FILE"
259219

@@ -265,11 +225,7 @@ setup_shell() {
265225
echo ""
266226
echo "In order to apply the changes, open a new terminal or run the following command:"
267227
echo ""
268-
if [ "$CURRENT_SHELL" = "fish" ]; then
269-
echo " source $CONF_FILE"
270-
else
271-
echo " . $CONF_FILE"
272-
fi
228+
echo " source $CONF_FILE"
273229
}
274230

275231
parse_args "$@"

.github/workflows/installation_script.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Installation script
2-
on:
2+
on:
33
pull_request:
44
paths:
55
- .ci/install.sh
@@ -13,9 +13,11 @@ jobs:
1313
test_against_latest_release_arm:
1414
strategy:
1515
matrix:
16-
docker_image:
17-
- arm64v8/ubuntu
18-
- arm32v7/ubuntu
16+
include:
17+
- docker_image: arm64v8/ubuntu
18+
docker_platform: linux/arm64/v8
19+
- docker_image: arm32v7/ubuntu
20+
docker_platform: linux/arm/v7
1921
name: Test against latest release (ARM)
2022
runs-on: ubuntu-latest
2123
steps:
@@ -25,7 +27,7 @@ jobs:
2527
- uses: actions/checkout@v4
2628
- name: Run installation script in Docker
2729
run: |
28-
docker run --rm -v $(pwd):$(pwd) -e "RUST_LOG=fnm=debug" --workdir $(pwd) ${{matrix.docker_image}} bash -c '
30+
docker run --rm --platform ${{ matrix.docker_platform }} -v $(pwd):$(pwd) -e "RUST_LOG=fnm=debug" --workdir $(pwd) ${{matrix.docker_image}} bash -c '
2931
set -e
3032
3133
apt update && apt install -y unzip curl libatomic1
@@ -53,13 +55,13 @@ jobs:
5355
strategy:
5456
matrix:
5557
shell: [fish, zsh, bash]
56-
setup:
58+
setup:
5759
- os: ubuntu
58-
script_arguments: ''
60+
script_arguments: ""
5961
- os: macos
60-
script_arguments: ''
62+
script_arguments: ""
6163
- os: macos
62-
script_arguments: '--force-no-brew'
64+
script_arguments: "--force-no-brew"
6365
runs-on: ${{ matrix.setup.os }}-latest
6466
steps:
6567
- uses: actions/checkout@v4
@@ -84,4 +86,4 @@ jobs:
8486
- run: "env SHELL=$(which ${{ matrix.shell }}) bash ./.ci/install.sh ${{ matrix.setup.script_arguments }}"
8587
name: Run the installation script
8688
- run: ./.ci/test_installation_script.sh ${{ matrix.shell }}
87-
name: 'Test installation script'
89+
name: "Test installation script"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44

55
### Minor Changes
66

7+
- [#1516](https://github.com/Schniz/fnm/pull/1516) [`10c68cb`](https://github.com/Schniz/fnm/commit/10c68cb6630be811799afdccf212a399e08bef99) Thanks [@Schniz](https://github.com/Schniz)! - Reduce shell startup overhead for `env --use-on-cd` by applying the initial version during `fnm env`, instead of requiring an immediate extra `fnm use` subprocess from shell hook output.
8+
79
- [#1435](https://github.com/Schniz/fnm/pull/1435) [`1ebc90d`](https://github.com/Schniz/fnm/commit/1ebc90decf58c2176dcbd4f8ac00ecb3adb1de12) Thanks [@SunsetTechuila](https://github.com/SunsetTechuila)! - add `use` flag to the `install` command
810

911
### Patch Changes
1012

1113
- [#1268](https://github.com/Schniz/fnm/pull/1268) [`ddab191`](https://github.com/Schniz/fnm/commit/ddab1911dc33a24aeec9d2b8139df1916c518d64) Thanks [@isaacl](https://github.com/isaacl)! - Make `fnm default` with no trailing positional argument to return the default version
1214

15+
- [#1517](https://github.com/Schniz/fnm/pull/1517) [`d3747af`](https://github.com/Schniz/fnm/commit/d3747affd604223c752171c14944bd5773096b09) Thanks [@Schniz](https://github.com/Schniz)! - Improve `--use-on-cd` shell hook robustness by de-duplicating the zsh hook on re-source and fixing Windows CMD hook behavior for paths with spaces and drive changes.
16+
1317
- [#1441](https://github.com/Schniz/fnm/pull/1441) [`bc4d19a`](https://github.com/Schniz/fnm/commit/bc4d19a481c11b4182f51683f03a8d366f1208d2) Thanks [@Schniz](https://github.com/Schniz)! - bump Rust toolchain to 1.88
1418

1519
## 1.38.1

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "fnm"
3-
version = "1.38.1"
4-
authors = ["Dargon789 <dargon789.uni.eth>"]
3+
version = "1.39.0"
4+
authors = ["Gal Schlezinger <gal@spitfire.co.il>"]
55
edition = "2021"
66
build = "build.rs"
77
license = "GPL-3.0"
8-
repository = "https://github.com/Dargon789/fnm.git"
9-
description = "Fast and simple Node.js version manager, built in Rust"
8+
repository = "https://github.com/Schniz/fnm"
9+
description = "Fast and simple Node.js version manager"
1010

1111
[dependencies]
1212
serde = { version = "1.0.203", features = ["derive"] }
@@ -16,27 +16,27 @@ chrono = { version = "0.4.38", features = ["serde", "now"], default-features = f
1616
tar = "0.4.40"
1717
xz2 = "0.1.7"
1818
node-semver = "2.1.0"
19-
etcetera = "0.11.0"
19+
etcetera = "0.8.0"
2020
colored = "2.1.0"
21-
zip = "6.0.0"
21+
zip = "2.1.0"
2222
tempfile = "3.10.1"
23-
indoc = "2.0.7"
23+
indoc = "2.0.5"
2424
log = "0.4.21"
2525
env_logger = "0.11.3"
2626
encoding_rs_io = "0.1.7"
27-
reqwest = { version = "0.13.0", features = ["blocking", "json", "rustls-tls", "rustls-tls-native-roots", "brotli"], default-features = false }
27+
reqwest = { version = "0.12.4", features = ["blocking", "json", "rustls-tls", "rustls-tls-native-roots", "brotli"], default-features = false }
2828
url = "2.5.0"
29-
sysinfo = "0.38.0"
29+
sysinfo = "0.30.12"
3030
thiserror = "1.0.61"
3131
clap_complete = "4.5.2"
3232
anyhow = "1.0.86"
33-
indicatif = { version = "0.18.0", features = ["improved_unicode"] }
34-
flate2 = "1.1.5"
33+
indicatif = { version = "0.17.8", features = ["improved_unicode"] }
34+
flate2 = "1.0.30"
3535
miette = { version = "7.2.0", features = ["fancy"] }
3636

3737
[dev-dependencies]
3838
pretty_assertions = "1.4.0"
39-
duct = "1.0.0"
39+
duct = "0.13.7"
4040
test-log = "0.2.16"
4141
http = "1.1.0"
4242

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ Please follow your shell instructions to install them.
140140
Environment variables need to be setup before you can start using fnm.
141141
This is done by evaluating the output of `fnm env`.
142142

143+
> [!TIP]
144+
> Prefer passing an explicit shell (for example `fnm env --shell bash`) instead of relying on shell inference at runtime. It is a bit faster and avoids process tree detection.
145+
143146
> [!NOTE]
144147
> Check out the [Configuration](./docs/configuration.md) section to enable highly
145148
> recommended features, like automatic version switching.
@@ -201,7 +204,7 @@ fnm env --use-on-cd --shell powershell | Out-String | Invoke-Expression
201204

202205
#### Windows Command Prompt aka Batch aka WinCMD
203206

204-
fnm is also supported but is not entirely covered. You can set up a startup script for [cmd.exe]( https://superuser.com/a/144348) or [Windows Terminal](https://superuser.com/a/1855283) and append the following lines:
207+
fnm is also supported but is not entirely covered. You can set up a startup script for [cmd.exe](https://superuser.com/a/144348) or [Windows Terminal](https://superuser.com/a/1855283) and append the following lines:
205208

206209
```batch
207210
@echo off

0 commit comments

Comments
 (0)