morph-cli 0.1.0

AST-based codebase migration and codemod tool for JavaScript and TypeScript projects.
Documentation
use std::path::{Path, PathBuf};

pub fn resolve_relative_import(current_file: &Path, import_src: &str) -> Option<PathBuf> {
    let parent = current_file.parent().unwrap_or(Path::new("."));
    let base_path = parent.join(import_src);
    
    // Check direct file
    if base_path.exists() && base_path.is_file() { return Some(base_path); }
    
    // Check with extensions
    for ext in &["js", "ts", "jsx", "tsx", "mjs", "cjs"] {
        let p = base_path.with_extension(ext);
        if p.exists() { return Some(p); }
    }
    
    // Check index files
    let index_path = base_path.join("index");
    for ext in &["js", "ts", "jsx", "tsx", "mjs", "cjs"] {
        let p = index_path.with_extension(ext);
        if p.exists() { return Some(p); }
    }

    None
}