1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
use std::path::{Path, PathBuf}; pub fn find_node_toolchain_root(start: &Path) -> Option<PathBuf> { for candidate in start.ancestors() { if candidate.join(".nvmrc").is_file() && candidate.join("scripts/run-with-nvm.mjs").is_file() { return Some(candidate.to_path_buf()); } } None } pub fn node_toolchain_wrapper_path(start: &Path) -> Option<PathBuf> { find_node_toolchain_root(start).map(|root| root.join("scripts/run-with-nvm.mjs")) } pub fn is_node_toolchain_command(command: &str) -> bool { let normalized = command.trim(); if normalized.is_empty() { return false; } if normalized.contains("cargo ") || normalized == "cargo" { return false; } normalized.contains("pnpm") || normalized.contains("node ") || normalized == "node" || normalized.contains("npm ") || normalized == "npm" || normalized.contains("npx ") || normalized == "npx" || normalized.contains("wrangler") || normalized.contains("vite") || normalized.contains("tsc") || normalized.contains("vitest") || normalized.contains("biome") || normalized.contains("next") || normalized.contains("turbo") || normalized.contains("bun ") || normalized == "bun" }