Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 1 addition & 37 deletions crates/vp_js_runtime/src/dev_engines.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Node.js version file reading and writing utilities.
//! Node.js version file reading utilities.
//!
//! This module provides utilities for working with `.node-version` and
//! `.nvmrc` files, which are used to specify Node.js versions for projects.
Expand All @@ -10,8 +10,6 @@ pub use vp_shared::PackageJson;
use vt_path::AbsolutePath;
use vt_str::Str;

use crate::Error;

/// Parse the content of a `.node-version` file.
///
/// # Supported Formats
Expand Down Expand Up @@ -82,26 +80,6 @@ pub async fn read_nvmrc_file(project_path: &AbsolutePath) -> Option<Str> {
}
}

/// Write a version to the `.node-version` file.
///
/// Creates the file if it doesn't exist, overwrites if it does.
/// Uses three-part version without `v` prefix and Unix line ending.
///
/// # Arguments
/// * `project_path` - The path to the project directory
/// * `version` - The version string (e.g., "22.13.1")
///
/// # Errors
/// Returns an error if the file cannot be written.
pub async fn write_node_version_file(
project_path: &AbsolutePath,
version: &str,
) -> Result<(), Error> {
let path = project_path.join(".node-version");
tokio::fs::write(&path, format!("{version}\n")).await?;
Ok(())
}

#[cfg(test)]
mod tests {
use tempfile::TempDir;
Expand Down Expand Up @@ -189,20 +167,6 @@ mod tests {
assert!(read_nvmrc_file(&temp_path).await.is_none());
}

#[tokio::test]
async fn test_write_node_version_file() {
let temp_dir = TempDir::new().unwrap();
let temp_path = AbsolutePathBuf::new(temp_dir.path().to_path_buf()).unwrap();

write_node_version_file(&temp_path, "22.13.1").await.unwrap();

let content = tokio::fs::read_to_string(temp_path.join(".node-version")).await.unwrap();
assert_eq!(content, "22.13.1\n");

// Verify it can be read back
assert_eq!(read_node_version_file(&temp_path).await, Some("22.13.1".into()));
}

// ========================================================================
// LTS Alias Tests - These test support for lts/* syntax in .node-version
// ========================================================================
Expand Down
4 changes: 1 addition & 3 deletions crates/vp_js_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ mod provider;
mod providers;
mod runtime;

pub use dev_engines::{
parse_node_version_content, read_node_version_file, read_nvmrc_file, write_node_version_file,
};
pub use dev_engines::{parse_node_version_content, read_node_version_file, read_nvmrc_file};
pub use error::Error;
pub use platform::{Arch, Os, Platform};
pub use provider::{
Expand Down
Loading