locate_lockfile_for_manifest

Function locate_lockfile_for_manifest 

Source
pub fn locate_lockfile_for_manifest(
    manifest_uri: &Uri,
    lockfile_names: &[&str],
) -> Option<PathBuf>
Expand description

Generic lock file locator.

Searches for lock files in the following order:

  1. Same directory as the manifest
  2. Parent directories (up to MAX_WORKSPACE_DEPTH levels) for workspace root

This function is ecosystem-agnostic and works with any lock file name.

§Arguments

  • manifest_uri - URI of the manifest file
  • lockfile_names - List of possible lock file names to search for

§Returns

Path to the first found lock file, or None if not found.

§Examples

use deps_core::lockfile::locate_lockfile_for_manifest;
use tower_lsp_server::ls_types::Uri;

let manifest_uri = Uri::from_file_path("/path/to/Cargo.toml").unwrap();
let lockfile_names = &["Cargo.lock"];

if let Some(path) = locate_lockfile_for_manifest(&manifest_uri, lockfile_names) {
    println!("Found lock file at: {}", path.display());
}