Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/ProcessManagement/NodeResolver/
QueryNodeVersion.rs

1//! Run `node --version` on the resolved binary and return its reported
2//! version string (e.g. `v24.8.0`). Returns `None` when the binary cannot be
3//! spawned (bare `node` fallback under a misconfigured PATH) or when it exits
4//! non-zero. No timeout - `node --version` never blocks.
5
6use std::path::Path;
7
8pub fn Fn(NodePath:&Path) -> Option<String> {
9	let Output = std::process::Command::new(NodePath).arg("--version").output().ok()?;
10
11	if !Output.status.success() {
12		return None;
13	}
14
15	let Reported = String::from_utf8(Output.stdout).ok()?.trim().to_string();
16
17	if Reported.is_empty() { None } else { Some(Reported) }
18}