修复:fnm 用户 Node.js 检测 + Release Notes 生成失败

fnm 修复:
- 移除错误的 ~/.fnm/current/bin 路径
- macOS/Linux: 扫描  或 ~/.local/share/fnm/node-versions/*/installation/bin
- Windows: 扫描 %FNM_DIR% 或 %APPDATA%\fnm\node-versions\*\installation

release.yml 修复:
- grep 无匹配时返回 exit 1,GitHub Actions pipefail 导致脚本终止
- 用 { grep ... || true; } 包裹,中文 commit message 不再触发失败
This commit is contained in:
晴天
2026-03-06 00:00:26 +08:00
parent b4e959ec99
commit d7d403e8a0
2 changed files with 52 additions and 6 deletions

View File

@@ -161,9 +161,9 @@ jobs:
get_logs() {
local prefix="$1"
if [ -n "$RANGE" ]; then
git log "$RANGE" --pretty=format:"%s" --no-merges | grep -iE "^${prefix}" | sed "s/^${prefix}[:(] */- /" | head -20
git log "$RANGE" --pretty=format:"%s" --no-merges | { grep -iE "^${prefix}" || true; } | sed "s/^${prefix}[:(] */- /" | head -20
else
git log --pretty=format:"%s" --no-merges -30 | grep -iE "^${prefix}" | sed "s/^${prefix}[:(] */- /" | head -20
git log --pretty=format:"%s" --no-merges -30 | { grep -iE "^${prefix}" || true; } | sed "s/^${prefix}[:(] */- /" | head -20
fi
}
@@ -171,9 +171,9 @@ jobs:
FIXES=$(get_logs "fix")
OTHERS=$(
if [ -n "$RANGE" ]; then
git log "$RANGE" --pretty=format:"%s" --no-merges | grep -ivE "^(feat|fix|style|chore|ci|docs|test|build)" | sed 's/^/- /' | head -10
git log "$RANGE" --pretty=format:"%s" --no-merges | { grep -ivE "^(feat|fix|style|chore|ci|docs|test|build)" || true; } | sed 's/^/- /' | head -10
else
git log --pretty=format:"%s" --no-merges -30 | grep -ivE "^(feat|fix|style|chore|ci|docs|test|build)" | sed 's/^/- /' | head -10
git log --pretty=format:"%s" --no-merges -30 | { grep -ivE "^(feat|fix|style|chore|ci|docs|test|build)" || true; } | sed 's/^/- /' | head -10
fi
)

View File

@@ -43,7 +43,6 @@ pub fn enhanced_path() -> String {
format!("{}/.nvm/current/bin", home.display()),
format!("{}/.volta/bin", home.display()),
format!("{}/.nodenv/shims", home.display()),
format!("{}/.fnm/current/bin", home.display()),
format!("{}/n/bin", home.display()),
];
// 扫描 nvm 实际安装的版本目录(兼容无 current 符号链接的情况)
@@ -58,6 +57,22 @@ pub fn enhanced_path() -> String {
}
}
}
// fnm: 扫描 $FNM_DIR 或默认 ~/.local/share/fnm 下的版本目录
let fnm_dir = std::env::var("FNM_DIR")
.ok()
.map(std::path::PathBuf::from)
.unwrap_or_else(|| home.join(".local/share/fnm"));
let fnm_versions = fnm_dir.join("node-versions");
if fnm_versions.is_dir() {
if let Ok(entries) = std::fs::read_dir(&fnm_versions) {
for entry in entries.flatten() {
let bin = entry.path().join("installation/bin");
if bin.is_dir() {
extra.push(bin.to_string_lossy().to_string());
}
}
}
}
let mut parts: Vec<&str> = vec![];
if let Some(ref cp) = custom_path {
parts.push(cp.as_str());
@@ -79,7 +94,6 @@ pub fn enhanced_path() -> String {
format!("{}/.nvm/current/bin", home.display()),
format!("{}/.volta/bin", home.display()),
format!("{}/.nodenv/shims", home.display()),
format!("{}/.fnm/current/bin", home.display()),
format!("{}/n/bin", home.display()),
];
// NVM_DIR 环境变量(用户可能自定义了 nvm 安装目录)
@@ -98,6 +112,22 @@ pub fn enhanced_path() -> String {
}
}
}
// fnm: 扫描 $FNM_DIR 或默认 ~/.local/share/fnm 下的版本目录
let fnm_dir = std::env::var("FNM_DIR")
.ok()
.map(std::path::PathBuf::from)
.unwrap_or_else(|| home.join(".local/share/fnm"));
let fnm_versions = fnm_dir.join("node-versions");
if fnm_versions.is_dir() {
if let Ok(entries) = std::fs::read_dir(&fnm_versions) {
for entry in entries.flatten() {
let bin = entry.path().join("installation/bin");
if bin.is_dir() {
extra.push(bin.to_string_lossy().to_string());
}
}
}
}
// nodesource / 手动安装的 Node.js 可能在 /usr/local/lib/nodejs/ 下
let nodejs_lib = std::path::Path::new("/usr/local/lib/nodejs");
if nodejs_lib.is_dir() {
@@ -165,6 +195,22 @@ pub fn enhanced_path() -> String {
}
}
extra.push(format!(r"{}\.volta\bin", home.display()));
// fnm: 扫描 %FNM_DIR% 或默认 %APPDATA%\fnm 下的版本目录
let fnm_base = std::env::var("FNM_DIR")
.ok()
.map(std::path::PathBuf::from)
.unwrap_or_else(|| std::path::Path::new(&appdata).join("fnm"));
let fnm_versions = fnm_base.join("node-versions");
if fnm_versions.is_dir() {
if let Ok(entries) = std::fs::read_dir(&fnm_versions) {
for entry in entries.flatten() {
let inst = entry.path().join("installation");
if inst.is_dir() && inst.join("node.exe").exists() {
extra.push(inst.to_string_lossy().to_string());
}
}
}
}
// 扫描常见盘符下的 Node 安装(用户可能装在 D:\、F:\ 等)
for drive in &["C", "D", "E", "F"] {