mirror of https://github.com/Trivernis/nenv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
499 B
Rust
20 lines
499 B
Rust
use std::str::FromStr;
|
|
|
|
use miette::{Context, IntoDiagnostic};
|
|
|
|
use crate::repository::NodeVersion;
|
|
|
|
use super::VersionDetector;
|
|
|
|
pub struct EnvDetector;
|
|
|
|
#[async_trait::async_trait]
|
|
impl VersionDetector for EnvDetector {
|
|
async fn detect_version() -> miette::Result<Option<crate::repository::NodeVersion>> {
|
|
std::env::var("NODE_VERSION")
|
|
.into_diagnostic()
|
|
.context("Reading version from environment")
|
|
.map(|v| NodeVersion::from_str(&v).ok())
|
|
}
|
|
}
|